OpenAPITools / OpenAPITools/openapi-generator
[BUG][Kotlin] "date-time" type integrity violated when using default dateLibrary (java8)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When generating the domain model using default configuration of dateLibrary (=java8 according to https://openapi-generator.tech/docs/generators/kotlin/) the generated date-time objects are represented by java.time.OffsetDateTime.
These objects are evaluated to strings that look like this:
2024-11-08T06:54:06.831187+01:00
Date times should follow the format of RFC 3339 according to https://swagger.io/docs/specification/v3_0/data-models/data-types/#strings
In other words they should look like this:
2017-07-21T17:32:28Z
Workaround: Specify another date library, such as kotlinx-datetime which represents date-times with kotlinx.datetime.Instant
openapi-generator version
7.9.0
OpenAPI declaration file content or url
foo:
type: string
format: 'date-time'
description: Example
Generation Details
Generated using Gradle plugin
Steps to reproduce
gradlew openApiGenerate
Related issues/PRs
Suggest a fix
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
Start by running gradlew openApiGenerate with the shown OpenAPI declaration and inspect the generated Kotlin domain model and its date-time handling. Trace how the default java8 date library represents and serializes date-time values. Done means generated values follow the stated RFC 3339 form without requiring the kotlinx-datetime workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100