OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.56k stars 6.52k forks source link

For date format the example is not taken into account #5847

Open CamilYed opened 4 years ago

CamilYed commented 4 years ago

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>

https://stackoverflow.com/questions/61082113/bug-in-openapi-generator-wrong-format-for-the-example-value-of-date-datatype

nicolasmafra commented 3 years ago

Any progress on this issue?