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
  • #9242
Closed
Open
Issue created Apr 12, 2021 by Administrator@rootContributor

[BUG][KOTLIN CLIENT] Generator generates invalid code when using kotlinx.serialization

Created by: msrd0

Description

Generator generates invalid code when using kotlinx.serialization

openapi-generator version

5.1.0 installed from the official ArchLinux package repository

OpenAPI declaration file content or url

https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml

Generation Details

openapi-generator generate -g kotlin -i petstore.yaml -p serializationLibrary=kotlinx_serialization

Steps to reproduce
  • Run above command to generate the source code
  • Run gradle build
  • Observe the following error message
e: /tmp/oas/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt: (118, 29): Expecting an element
e: /tmp/oas/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt: (101, 82): Type mismatch: inferred type is T but DeserializationStrategy<TypeVariable(T)> was expected
e: /tmp/oas/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt: (101, 89): No value passed for parameter 'string'
e: /tmp/oas/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt: (101, 91): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
public final fun ByteArray.toRequestBody(contentType: MediaType? = ..., offset: Int = ..., byteCount: Int = ...): RequestBody defined in okhttp3.RequestBody.Companion
public final fun String.toRequestBody(contentType: MediaType? = ...): RequestBody defined in okhttp3.RequestBody.Companion
public final fun ByteString.toRequestBody(contentType: MediaType? = ...): RequestBody defined in okhttp3.RequestBody.Companion
e: /tmp/oas/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt: (249, 50): Type mismatch: inferred type is T but SerializationStrategy<TypeVariable(T)> was expected
e: /tmp/oas/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt: (249, 55): No value passed for parameter 'value'
Suggest a fix

This line is probably missing support for kotlinx.serialization: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache#L175

Assignee
Assign to
Time tracking