Is your feature request related to a problem? Please describe.
When generating a Kotlin data class from an OpenAPI definition with an object with a free-form dictionary field using additionalProperties, the field that is generated has a type of Map<String, Any>.
This goes a long way, but from what I have seen there is no way to allow assignment of nullable values.
OpenAPI definition:
"Response": {
"type": "object",
"required": ["fields"],
"properties": {
"fields": {
"type": "object",
"description": "Free-form dictionary",
"additionalProperties": true
}
}
},
The above definition generates the following Kotlin data class:
data class Response (
/* Free-form dictionary */
@field:JsonProperty("fields")
val fields: kotlin.collections.Map<kotlin.String, kotlin.Any>
)
Describe the solution you'd like
I would like a way to generate a type of Map<String, Any?> so that it is possible to assign nullable values.
Describe alternatives you've considered
I'm not sure if there is an elegant way to specify this behaviour using the OpenAPI specification, but perhaps it can be solved using a configuration that is passed to the kotlin generator?
Additional context
Screenshot of compile-time error when attempting to assign a nullable type to a field in the map.

Additional context
I believe the same issue exists when specifying the type of the dictionary, where there is no way to specify that the value type should be nullable.
OpenAPI definition:
"Response": {
"type": "object",
"required": ["fields"],
"properties": {
"fields": {
"type": "object",
"description": "Free-form dictionary",
"additionalProperties": {
"type": "string"
}
}
}
},
The above definition generates the following Kotlin data class:
data class Response (
/* Free-form dictionary */
@field:JsonProperty("fields")
val fields: kotlin.collections.Map<kotlin.String, kotlin.String>
)
In this case I would like the type of the map to be Map<String, String?>.
Is your feature request related to a problem? Please describe.
When generating a Kotlin data class from an OpenAPI definition with an object with a free-form dictionary field using
additionalProperties, the field that is generated has a type ofMap<String, Any>.This goes a long way, but from what I have seen there is no way to allow assignment of nullable values.
OpenAPI definition:
The above definition generates the following Kotlin data class:
Describe the solution you'd like
I would like a way to generate a type of
Map<String, Any?>so that it is possible to assign nullable values.Describe alternatives you've considered
I'm not sure if there is an elegant way to specify this behaviour using the OpenAPI specification, but perhaps it can be solved using a configuration that is passed to the
kotlingenerator?Additional context
Screenshot of compile-time error when attempting to assign a nullable type to a field in the map.

Additional context
I believe the same issue exists when specifying the type of the dictionary, where there is no way to specify that the value type should be nullable.
OpenAPI definition:
The above definition generates the following Kotlin data class:
In this case I would like the type of the map to be
Map<String, String?>.