I am trying get ZonedDateTime in my generated code from OpenApi.
There is a If-Modified-Since header that OpenApi generates on my endpoint but it's in the type of LocalDateTime. This is causing issues on my integration tests.
task buildEndpointsFromYAML(type:
org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
generatorName = "spring"
inputSpec = acquirerYML
outputDir = "$buildDir/generated".toString()
groupId = "$project.group"
id = "$project.name-java-client"
version = "$project.version"
apiPackage = "com.abc.xyz.apiEndpoints"
modelPackage = "com.abc.xyz.apiModels"
enablePostProcessFile = true
skipOverwrite = false
typeMappings = [
OffsetDateTime: "ZonedDateTime"
]
importMappings = [
"java.time.OffsetDateTime" : "java.time.ZonedDateTime"
]
configOptions = [
configPackage : "com.abc.xyz.apiEndpoints.config",
java11 : "true",
dateLibrary : "java8-localdatetime",
serializationLibrary: "jackson",
library : "spring-boot",
useBeanValidation : "true",
interfaceOnly : "true",
serializableModel : "true",
useTags : "true"
]
}
I've tried to some of the suggestions here too: Use java.time.Instant to represent DateTime instead of OffsetDateTime
but either it resulted in compilation errors or the type would go from LocalDateTime to Object as opposed to ZonedDAteTime.
This is part of the swagger.yaml:
parameters:
- name: If-Modified-Since
in: header
description: If-Modified-Since
required: false
type: string
format: date-time