Created by: fabiokung
Fixes #2858. UPDATE: I was wrong and misundertood the code, this PR does not fix the issue, but https://github.com/OpenAPITools/openapi-generator/pull/4182#issuecomment-546092134 discusses an alternative on how to accomplish the same. I'd still consider the original issue to be a bug, it should be possible to define type mappings for any type definition in the spec.
This will allow kubernetes-client-java
to switch to openapi-generator (kubernetes-client/java#709).
The kubernetes API swagger spec has types aliased to primitive types, e.g.:
"intstr.IntOrString": {
"description": "IntOrString is a type that can hold an int32 or a string. When used in JSON or YAML marshalling and unmarshalling, it produces or consumes the inner type. This allows you to have, for example, a JSON field that can accept a name or number.",
"format": "int-or-string",
"type": "string"
},
However, these types need to be mapped to custom types in the Java client, so we can have custom serialization for them. The generator is being invoked with the following options:
<type-mappings>intstr.IntOrString=IntOrString,resource.Quantity=Quantity</type-mappings>
<import-mappings>IntOrString=io.kubernetes.client.custom.IntOrString,Quantity=io.kubernetes.client.custom.Quantity</import-mappings>
Without changes in this PR, type-mappings
gets ignored, since IntOrString
is first resolved to its alias (string
), before mappings are evaluated.
cc @wing328 @brendandburns @yue9944882