[Kotlin] Models with "additionalProperties" result in invalid Kotlin code
Description
When using the kotlin-spring generator, OpenAPI models including additionalProperties are generated as invalid Kotlin code.
openapi-generator version
5.4.0 and 6.0.1
OpenAPI declaration file content or url
components:
schemas:
MyObject:
type: object
properties:
value:
type: string
additionalProperties: true
required:
- value
...is generated into...
data class MyObject(
@field:JsonProperty("value", required = true) val `value`: kotlin.String,
) : kotlin.collections.HashMap<String, kotlin.Any>{
}
Note the missing () after kotlin.collections.HashMap<String, kotlin.Any>.
Suggest a fix/enhancement
I'd propose the fix as just adding the missing () to the kotlin-spring's dataClass.mustache file, but I'm not sure if it should be fixed there or in the general Kotlin code for the variable being provided to the template.
yes please fix this ... I am eagerly waiting for this bug to be fixed ... this is the reason why we have to resort to some dirty workarounds to make our openapi spec file work and cannot define some of the fixed properties at least.
@benjamineckstein did you test the fix (https://github.com/OpenAPITools/openapi-generator/pull/13822) to see if it works for your use cases?
Is this fix going to happen?
The problem also exists if JSON contains empty additionalProperties like:
additionalProperties: {}