OpenAPITools / OpenAPITools/openapi-generator
[BUG][KOTLIN] Generated enum does not compile if type mapping is not defined
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
Description
The Kotlin generated code does not compile if the type mapping is not explicitly defined, or if it is explicitly set to BigDecimal. By default, the generator uses String to construct the enum.
openapi-generator version
7.17.0
OpenAPI declaration file content or url
openapi: 3.0.0
paths:
'/':
get:
operationId: operation
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/ModelWithEnumBigDecimalValue'
components:
schemas:
ModelWithEnumBigDecimalValue:
properties:
mode:
type: number
enum:
- -1
- 0
- 1.1
- 0.4
this results to this error :
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running OpenAPI Generator 7.17.0 with the YAML declaration in the issue and inspect the generated Kotlin enum for ModelWithEnumBigDecimalValue. Compare the output when no type mapping is supplied with the explicit BigDecimal case. Done means the generated Kotlin code for the numeric enum compiles in both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100