Skip to content
GitLab
    • Explore Projects Groups Snippets
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 6 years ago by Administrator@rootContributor
  • New related issue

  • Report abuse to administrator

  • New related issue

  • Report abuse to administrator

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

Closed

[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.

  1. Oh no!

    You are trying to upload something other than an image. Please upload a .png, .jpg, .jpeg, .gif, .bmp, .tiff or .ico.

    Incoming!

    Drop your designs to start your upload.
Tasks
0

No tasks are currently assigned. Use tasks to break down this issue into smaller parts.

Linked items
0

Link issues together to show that they're related. Learn more.

Activity


Please register or sign in to reply
0 Assignees
None
Assign to
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
Due date
None
None
None
Time tracking
No estimate or time spent
Confidentiality
Not confidential
Not confidential

You are going to turn on confidentiality. Only project members with at least the Reporter role, the author, and assignees can view or be notified about this issue.

Lock issue
Unlocked
1
1 participant
Administrator
Reference: OpenAPITools/openapi-generator#1271

Menu

Explore Projects Groups Snippets