Bug Report Checklist
Description
When using the generator for kotlin with the kotlinx serialization method, integer enums will be correctly serialized from integer to kotlin integer, but will be incorrectly deserialized from kotlin integer to string
This:
@Serializable
enum class SomeCode(val value: kotlin.Int) {
@SerialName(value = "0")
_0(0)
}
Should be this:
@Serializable
enum class SomeCode(val value: kotlin.Int) {
@SerialName(value = 0)
_0(0),
}
openapi-generator version
Latest (7.12.0)
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: Demo
version: v1
components:
schemas:
Code:
type: integer
enum:
- 0
paths:
/do:
get:
summary: Do something
responses:
200:
description: Successful response
content:
application/json:
schema:
type: object
required:
- code
properties:
code:
$ref: '#/components/schemas/Code'
Generation Details
Generate with Docker command:
docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate -i /local/Test.yml -g kotlin -o /local/out/kotlin
Steps to reproduce
Generate with Docker command:
docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate -i /local/Test.yml -g kotlin -o /local/out/kotlin
Related issues/PRs
Suggest a fix
The bug seems to be caused by the following line:
@SerialName(value = {{#lambda.doublequote}}{{{value}}}{{/lambda.doublequote}})
Where double quotes are hard-coded
They should be conditionally added, whether it's a dataType string or integer.
I'm not sure if we can do conditional checks like that is the mustaches syntax, let me know if we can, it would be a pleasure to create a PR
Bug Report Checklist
Description
When using the generator for
kotlinwith the kotlinx serialization method, integer enums will be correctly serialized from integer to kotlin integer, but will be incorrectly deserialized from kotlin integer to stringThis:
Should be this:
openapi-generator version
Latest (
7.12.0)OpenAPI declaration file content or url
Generation Details
Generate with Docker command:
docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate -i /local/Test.yml -g kotlin -o /local/out/kotlinSteps to reproduce
Generate with Docker command:
docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate -i /local/Test.yml -g kotlin -o /local/out/kotlinRelated issues/PRs
Suggest a fix
The bug seems to be caused by the following line:
Where double quotes are hard-coded
They should be conditionally added, whether it's a
dataTypestring or integer.I'm not sure if we can do conditional checks like that is the mustaches syntax, let me know if we can, it would be a pleasure to create a PR