kora-projects / kora

Kora Framework
https://kora-projects.github.io/kora-docs
Apache License 2.0
62 stars 9 forks source link

OpenAPI date-time mappings #130

Closed ovrays closed 3 weeks ago

ovrays commented 4 weeks ago

Versions:

Описание проблемы / Describe the bug:

The use of mapping to have the DateTime type in OpenAPI represented as java.time.Instant is ignored The generated type still remains java.time.OffsetDateTime

openApiGenerate {
    generatorName = "kora"

    ..

    configOptions = mapOf(
        "mode" to "kotlin-server",
        "dateLibrary" to "java8",
        "typeMappings" to "DateTime=Instant",
        "importMappings" to "Instant=java.time.Instant"
    )
}

Текущее поведение / Current behavior:

The use of mappings is ignored

Ожидаемое поведение / Expected behavior:

The use of mappings isn't ignored

Стек вызова или сгенерированный код или скриншоты / Stacktrace or generated code or screenshots (Optional):

data class StorageFile @ru.tinkoff.kora.json.common.annotation.JsonReader constructor (
  @ru.tinkoff.kora.json.common.annotation.JsonField("name")
  val name: String,
  @ru.tinkoff.kora.json.common.annotation.JsonField("createdAt")
  val createdAt: java.time.OffsetDateTime,
  @ru.tinkoff.kora.json.common.annotation.JsonField("updatedAt")
  val updatedAt: java.time.OffsetDateTime,
  @ru.tinkoff.kora.json.common.annotation.JsonField("isDirectory")
  val isDirectory: Boolean
)
GoodforGod commented 2 weeks ago

Correct usage:

openApiGenerate{
    typeMappings = [ "DateTime" : "java.time.Instant" ]
}