我看到在OpenAPI中有一个针对字符串的
date
格式,通过使用dateLibrary=java8
,我们可以使用openapi-generator
生成LocalDate
字段。
但是有没有办法生成LocalTime
字段呢?在OpenAPI中没有time
格式,而date-time
格式会生成OffsetDateTime
。
编辑:由于这个问题涉及到我无法操作的内容,所以很难提供可重现的示例,但是以下是一个说明性的示例:
模式规范:
Visit:
type: object
parameters:
visitor:
type: string
timeOfVisit:
type: string
format: time
但是显然,在OpenAPI规范中没有time
格式。生成的代码应该是这样的:
public class Visit {
private String visitor;
private LocalTime timeOfVisit;
// Getters, setters, etc
}
一定有一种方法可以让openapi-generator
生成这种输出,不是吗?我发现有一些import-mappings
将LocalTime
映射到org.joda.time.*
,因此似乎有一种方法可以生成LocalTime
类型,但我还没有找到它。
OffsetDateTime
并调用myOffsetDateTime.toLocalTime()
。 - deHaar