OpenAPITools / OpenAPITools/openapi-generator
[BUG][kotlin-spring] Generating schema model with additional properties in component leads to compile error
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
Generating schema model with additional properties leads to compile error.
Steps to reproduce:
swagger.yaml:
JsonObjectItem:
description: example item of Json Object (could be anything)
properties:
something1:
type: string
something2:
type: string
additionalProperties:
type: string
generates
`data class JsonObjectItem (
@JsonProperty("something1") val something1: kotlin.String? = null,
@JsonProperty("something2") val something2: kotlin.String? = null
) : kotlin.mapOf<String, kotlin.String>{
}`
which leads to
JsonObjectItem.kt: (23, 12): Unresolved reference: mapOf
openapi-generator version
4.1.3
OpenAPI declaration file content or url
--> https://gist.github.com/Alexichlol/a4ce6f2a3742cc28a757fa736923a436
Command line used for generation
gradle plugin
Steps to reproduce
in description but basically just generate code and try to compile
Related issues/PRs
Suggest a fix
don't really know the idea behind current implementation but maybe either not using data class if want to inherit from map and inherit from hashmap like in spring java or use composition and have map as the field
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 with the swagger.yaml schema and the generated JsonObjectItem.kt from the linked reproduction, then locate the Kotlin Spring generator entry point that handles additionalProperties. Reproduce generation with the Gradle plugin and compile the result. Done means the model generated for this schema compiles while retaining the intended additional-properties behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, spring
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100