-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Description
Description
I have model class with a date-time property which is defined as:
creationdate:
format: date-time
description: the creation date
type: string
example: '2022-10-07T01:00:00.000+02:00'
the maven config looks like:
<configuration>
<output>${project.build.directory}/generated-sources/</output>
<inputSpec>${project.basedir}/src/main/resources/openapi.yaml</inputSpec>
<generatorName>java</generatorName>
<configOptions>
<library>native</library>
<sourceFolder>/src/main/java</sourceFolder>
<serializableModel>true</serializableModel>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
<allowUnicodeIdentifiers>true</allowUnicodeIdentifiers>
<useJakartaEe>true</useJakartaEe>
<supportUrlQuery>false</supportUrlQuery>
<annotationLibrary>swagger2</annotationLibrary>
<sortModelPropertiesByRequiredFlag>false</sortModelPropertiesByRequiredFlag>
<skipDefaultInterface>true</skipDefaultInterface>
</configOptions>
<modelPackage>com.github.saskiabikle.openapi.test.model</modelPackage>
<generateApis>false</generateApis>
<generateSupportingFiles>false</generateSupportingFiles>
<generateModelDocumentation>false</generateModelDocumentation>
<generateModelTests>false</generateModelTests>
<skipValidateSpec>false</skipValidateSpec>
</configuration>
the generated annotation looks like:
@Schema(example = "2022-10-07T01:00+02:00", requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "the creation date")
As you can see the seconds are missing.
If I check the definition of the default date-time (https://spec.openapis.org/registry/format/date-time) it refers to https://www.rfc-editor.org/rfc/rfc3339#section-5.6. There are seconds required.
openapi-generator version
I used 7.14.0 and the current master branch. The result is the same
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: Blank API
version: 1.0.0
description: This is a simple API descriptor.
paths:
/:
get:
responses:
'200':
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/MyModel'
description: getAll
summary: getAll
components:
schemas:
MyModel:
title: Root Type for MyModel
description: My Testmodel
type: object
properties:
creationdate:
format: date-time
description: the creation date
type: string
example: '2022-10-07T01:00:00.000+02:00'
Steps to reproduce
If you use the example as mention the seconds are missing.
If you change the seconds from '00' to '01' the seconds the output is valid, because seconds are present.
Suggest a fix
I you can point me to code/unit test I would be able to create a PR.