Created by: ityuhui
There is a custom data type from Kubernetes swagger specification:
"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"
},
And the model log (-DdebugModels) of openapi-generator-cli shows:
{
"openApiType" : "string",
"baseName" : "targetPort",
"complexType" : "int_or_string",
"getter" : "getTargetPort",
"setter" : "setTargetPort",
"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.",
"dataType" : "int_or_string",
"datatypeWithEnum" : "int_or_string",
"dataFormat" : "int-or-string",
"name" : "target_port",
"defaultValueWithParam" : " = data.targetPort;",
"baseType" : "int_or_string",
"unescapedDescription" : "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.",
"example" : "\"0\"",
"jsonSchema" : "{\n \"type\" : \"string\",\n \"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.\",\n \"format\" : \"int-or-string\"\n}",
"exclusiveMinimum" : false,
"exclusiveMaximum" : false,
"required" : false,
"deprecated" : false,
"hasMoreNonReadOnly" : false,
"isPrimitiveType" : false,
"isModel" : false,
"isContainer" : false,
"isString" : true,
"isNumeric" : false,
"isInteger" : false,
"isShort" : false,
"isLong" : false,
"isUnboundedInteger" : false,
"isNumber" : false,
"isFloat" : false,
"isDouble" : false,
"isDecimal" : false,
"isByteArray" : false,
"isBinary" : false,
"isFile" : false,
"isBoolean" : false,
"isDate" : false,
"isDateTime" : false,
"isUuid" : false,
"isUri" : false,
"isEmail" : false,
"isNull" : false,
"isFreeFormObject" : false,
"isAnyType" : false,
"isArray" : false,
"isMap" : false,
"isEnum" : false,
"isReadOnly" : false,
"isWriteOnly" : false,
"isNullable" : false,
"isSelfReference" : false,
"isCircularReference" : false,
"isDiscriminator" : false,
"vars" : [ ],
"requiredVars" : [ ],
"vendorExtensions" : { },
"hasValidation" : false,
"isInherited" : false,
"nameInCamelCase" : "TargetPort",
"nameInSnakeCase" : "TARGET_PORT",
"uniqueItems" : false,
"isXmlAttribute" : false,
"isXmlWrapped" : false,
"additionalPropertiesIsAnyType" : false,
"hasVars" : false,
"hasRequired" : false,
"hasDiscriminatorWithNonEmptyMapping" : false,
"hasMultipleTypes" : false,
"datatype" : "int_or_string",
"iexclusiveMaximum" : false
}
So this is a data type with below attributes:
- isContainer: false
- isPrimitiveType: false
- isModel: false
- isFreeFormObject: false
I add the support for this data type in C generator.
BTW: The header and implementation files of the custom data type cannot be provided by this PR because they need to be implemented by users themselves.
Hi @wing328 @zhemant @michelealbano
Could you please reivew this code change ? Thanks !
PR checklist
-
Read the contribution guidelines. -
Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community. -
Run the following to build the project and update samples: ./mvnw clean package ./bin/generate-samples.sh ./bin/utils/export_docs_generators.sh
./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH. -
File the PR against the correct branch: master
(5.3.0),6.0.x
-
If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.