OpenAPITools / OpenAPITools/openapi-generator

Kotlin generator incompatible with kotlinx-datetime v0.7.0

Open
#21,509 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

I use org.openapi.generator version 7.14.0

kotlinx-datetime v0.7.0 was recently released and has breaking functionality:

https://github.com/Kotlin/kotlinx-datetime/releases/tag/v0.7.0
Remove kotlinx.datetime.Instant and kotlinx.datetime.Clock in favor of kotlin.time.Instant

It means that having config such as:

openApiGenerate {
    ...
    generatorName.set("kotlin")
    library.set("multiplatform")
    configOptions.set(mapOf(
        "dateLibrary" to "kotlinx-datetime",
        "collectionType" to "list"
    ))
    globalProperties.set(mapOf("models" to "", "client" to ""))
}

results in compilation error

Serializer has not been found for type 'ERROR CLASS: Symbol not found for kotlinx.datetime.Instant'.

when we generate code for openapi spec such as:

          type: string
          format: date-time

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Kotlin generator and reproduce the issue using the shown Gradle configuration and an OpenAPI schema containing a string with format date-time. Check the generated multiplatform code against kotlinx-datetime v0.7.0; done means the generated models compile without references to removed kotlinx.datetime.Instant or Clock types.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.