Bug Report Checklist
Expected output
{
"name": "requestedDate",
"type": {
"type": "int",
"logicalType": "date"
}
}
private java.time.LocalDate requestedDate;
Description
When date-time format is specified in OpenAPI yaml, it is expected the Java class and avro file to be created for datetime instead of string
openapi-generator version
6.6.0
OpenAPI declaration file content or url
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>demo</description>
<properties>
<java.version>17</java.version>
<openapi.style.validator.version>1.7</openapi.style.validator.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.swagger.core.v3/swagger-annotations -->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.2.15</version>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>1.3.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.11.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.11</version>
<executions>
<execution>
<id>convert</id>
<phase>process-resources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/static/openapi.yaml</inputSpec>
<!-- Use "openapi" to convert YAML->JSON or "openapi-yaml" to convert JSON->YAML -->
<language>openapi</language>
<!-- Output directory, relative to the project directory. Default is ${project.build.directory}/generated-sources/swagger -->
<output>${project.build.directory}/specs</output>
<configOptions>
<!-- Default output file name is openapi.json or openapi.yaml -->
<outputFile>generated-api.json</outputFile>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.6.0</version>
<executions>
<execution>
<id>generate-java</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/static/openapi.yaml</inputSpec>
<generatorName>spring</generatorName>
<apiPackage>com.example.demo.api</apiPackage>
<modelPackage>com.example.demo.model</modelPackage>
<configOptions>
<interfaceOnly>true</interfaceOnly>
<sourceFolder>src/gen/java/main</sourceFolder>
<additionalModelTypeAnnotations>
@com.fasterxml.jackson.annotation.JsonIgnoreProperties(ignoreUnknown = true)
</additionalModelTypeAnnotations>
<dateLibrary>java8</dateLibrary>
<useTags>true</useTags>
<skipDefaultInterface>true</skipDefaultInterface>
</configOptions>
<importMappings>
</importMappings>
<typeMappings>
<typeMapping>float=java.math.BigDecimal</typeMapping>
<typeMapping>double=java.math.BigDecimal</typeMapping>
</typeMappings>
</configuration>
</execution>
<execution>
<id>generate-avro</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/static/openapi.yaml</inputSpec>
<generatorName>avro-schema</generatorName>
<configOptions>
<sourceFolder>${project.build.directory}</sourceFolder>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.11.2</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
</goals>
<configuration>
<sourceDirectory>${project.build.directory}</sourceDirectory>
<outputDirectory>${project.build.directory}/generated-sources/openapi/src/gen/java/main</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openapitools.openapistylevalidator</groupId>
<artifactId>openapi-style-validator-maven-plugin</artifactId>
<version>${openapi.style.validator.version}</version>
<dependencies>
<dependency>
<groupId>org.openapitools.openapistylevalidator</groupId>
<artifactId>openapi-style-validator-cli</artifactId>
<version>${openapi.style.validator.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>validate</goal>
</goals>
<configuration>
<inputFile>${project.basedir}/src/main/resources/static/openapi.yaml</inputFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
(for JSON code), so it becomes more readable. If it is longer than about ten lines,
please create a Gist (https://gist.github.com) or upload it somewhere else and
link it here.
-->
##### Generation Details
<!--
Prefer CLI steps, including the language, libraries and various options.
Providing config-based settings allows for simpler testing across CLI and plugins.
For examples, see https://github.com/OpenAPITools/openapi-generator/tree/master/bin/configs
-->
run mvn clean install
##### Steps to reproduce
<!-- unambiguous set of steps to reproduce the bug.-->
##### Related issues/PRs
<!-- has a similar issue/PR been reported/opened before? Please do a search in https://github.com/openapitools/openapi-generator/issues?utf8=%E2%9C%93&q=is%3Aissue%20 -->
##### Suggest a fix
<!-- if you can't fix the bug yourself, perhaps you can point to what might be
causing the problem (line of code or commit), or simply make a suggestion -->
Bug Report Checklist
Actual output
{
"name": "requestedDate",
"type": ["null", "string"],
"doc": "Request",
"default": null
}
Java
private java.lang.CharSequence requestedDate;
Expected output
{
"name": "requestedDate",
"type": {
"type": "int",
"logicalType": "date"
}
}
private java.time.LocalDate requestedDate;
Description
When date-time format is specified in OpenAPI yaml, it is expected the Java class and avro file to be created for datetime instead of string
openapi-generator version
6.6.0
OpenAPI declaration file content or url