Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #1271
Closed
Open
Issue created Oct 19, 2018 by Administrator@rootContributor

[BUG][KOTLIN] No JsonAdapter for LocalDateTime in Moshi serializer

Created by: toXel

Description

date-time fields can't be parsed from a generated Kotlin client with default configuration. It fails with this exception: java.lang.IllegalArgumentException: Platform class java.time.LocalDateTime annotated [] requires explicit JsonAdapter to be registered

The reason for it is that in Serializer.kt.mustache Moshi only gets a JsonAdapter for the java.util.Date type but not for java.time.LocalDateTime (or org.threeten.bp.LocalDateTime when ThreeTen is used).

openapi-generator version

v3.3.1

Command line used for generation

generate -g kotlin -i https://petstore.swagger.io/v2/swagger.yaml -o swaggerClientTest

Steps to reproduce

It can be reproduced with the petstore swagger spec.

  1. Generate Kotlin client with the command above.
  2. Write a simple test like this:
@Test
fun getOrderById() {
    val order = StoreApi().getOrderById(1)
    assertNotNull(order)
}
  1. It will fail with the respective exception.
Suggest a fix/enhancement

A workaround is to implement a JsonAdapter for the respective type and add it to Moshi in the generated Serializer class. Maybe this can be integrated in the generator.

Assignee
Assign to
Time tracking