OpenAPITools / OpenAPITools/openapi-generator
For date format the example is not taken into account
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
0
I'm using a openapi-generator-maven-plugin with 4.2.3 version.
My configuration looks like this:
<typeMappings>
<typeMapping>OffsetDate=LocalDate</typeMapping>
<typeMapping>OffsetDateTime=LocalDateTime</typeMapping>
</typeMappings>
<importMappings>
<importMapping>java.time.OffsetDate=java.time.LocalDate</importMapping>
<importMapping>java.time.OffsetDateTime=java.time.LocalDateTime</importMapping>
</importMappings>
<!-- pass any necessary config options -->
<configOptions>
<java8>true</java8>
<skipDefaultInterface>true</skipDefaultInterface>
<dateLibrary>java8</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<swaggerDocketConfig>false</swaggerDocketConfig>
<hateoas>true</hateoas>
</configOptions>
In ma yaml I defined my property with example parameter:
myDate:
type: "string"
format: "date"
description: "My date"
example: "2012-10-11"
But example is ignored by plugin: In my generated code I have:
@ApiModelProperty(example = "Thu Oct 11 02:00:00 CEST 2012", required = true, value = "My date")
I would like have a example like in my yaml file. In YYYY-MM-DD format.
I'm using:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-webmvc</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.10.2</version>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the shown OpenAPI YAML and the Java Maven plugin configuration, then trace the Java generator's handling of date examples and ApiModelProperty output. Done means the generated annotation preserves the YAML example as "2012-10-11" rather than converting it to a localized date string.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100