From 8add9119dffeba56470da376164cafe447d1b1cb Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 30 Jun 2023 09:38:39 +0800 Subject: [PATCH] Add containerTypeMapped (#15881) * add containerTypeMapped * update samples * update java inflector sample --- .../codegen/CodegenParameter.java | 6 +- .../openapitools/codegen/CodegenProperty.java | 15 +- .../openapitools/codegen/CodegenResponse.java | 5 +- .../openapitools/codegen/DefaultCodegen.java | 17 +- .../python/PythonClientCodegenTest.java | 4 + .../java-inflector/.openapi-generator/FILES | 3 - .../java-inflector/.openapi-generator/VERSION | 2 +- .../petstore/java-inflector/inflector.yaml | 3 - .../java/org/openapitools/model/Animal.java | 1 + .../java/org/openapitools/model/BigCat.java | 1 - .../gen/java/org/openapitools/model/Cat.java | 1 - .../gen/java/org/openapitools/model/Dog.java | 1 - .../java/org/openapitools/model/MapTest.java | 1 - ...ropertiesAndAdditionalPropertiesClass.java | 1 - .../org/openapitools/model/ModelList.java | 1 + .../src/main/openapi/openapi.yaml | 336 +++++++++--------- .../handler/PathHandlerInterface.java | 4 +- 17 files changed, 218 insertions(+), 184 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java index 2443d44e90e6..eaebae67c721 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java @@ -55,6 +55,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties { public boolean isNullable; public boolean isDeprecated; public String containerType; + public String containerTypeMapped; // language-specified container type (e.g. `dict` in python for map) private CodegenProperty schema; private boolean additionalPropertiesIsAnyType; @@ -143,6 +144,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties { output.unescapedDescription = this.unescapedDescription; output.baseType = this.baseType; output.containerType = this.containerType; + output.containerTypeMapped = this.containerTypeMapped; output.isFormParam = this.isFormParam; output.isQueryParam = this.isQueryParam; output.isPathParam = this.isPathParam; @@ -257,7 +259,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties { @Override public int hashCode() { - return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, containerType, defaultValue, enumDefaultValue, enumName, style, isDeepObject, isAllowEmptyValue, example, examples, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, isEnumRef, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, isVoid, additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger, hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes, schema, content, requiredVarsMap, ref, uniqueItemsBoolean, schemaIsFromAdditionalProperties); + return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, containerType, containerTypeMapped, defaultValue, enumDefaultValue, enumName, style, isDeepObject, isAllowEmptyValue, example, examples, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, isEnumRef, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, isVoid, additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger, hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes, schema, content, requiredVarsMap, ref, uniqueItemsBoolean, schemaIsFromAdditionalProperties); } @Override @@ -333,6 +335,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties { Objects.equals(unescapedDescription, that.unescapedDescription) && Objects.equals(baseType, that.baseType) && Objects.equals(containerType, that.containerType) && + Objects.equals(containerTypeMapped, that.containerTypeMapped) && Objects.equals(defaultValue, that.defaultValue) && Objects.equals(enumDefaultValue, that.enumDefaultValue) && Objects.equals(enumName, that.enumName) && @@ -396,6 +399,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties { sb.append(", unescapedDescription='").append(unescapedDescription).append('\''); sb.append(", baseType='").append(baseType).append('\''); sb.append(", containerType='").append(containerType).append('\''); + sb.append(", containerTypeMapped='").append(containerTypeMapped).append('\''); sb.append(", defaultValue='").append(defaultValue).append('\''); sb.append(", enumDefaultValue='").append(enumDefaultValue).append('\''); sb.append(", enumName='").append(enumName).append('\''); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java index 3c731563368d..2f33d729a3a7 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java @@ -50,6 +50,8 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti public String defaultValueWithParam; public String baseType; public String containerType; + public String containerTypeMapped; // language-specified container type (e.g. `dict` in python for map) + /** * The value of the 'title' attribute in the OpenAPI schema. */ @@ -391,6 +393,15 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti this.containerType = containerType; } + public String getContainerTypeMapped() { + return containerTypeMapped; + } + + public void setContainerTypeMapped(String containerTypeMapped) { + this.containerTypeMapped = containerTypeMapped; + } + + public String getTitle() { return title; } @@ -1034,6 +1045,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti sb.append(", defaultValueWithParam='").append(defaultValueWithParam).append('\''); sb.append(", baseType='").append(baseType).append('\''); sb.append(", containerType='").append(containerType).append('\''); + sb.append(", containerTypeMapped='").append(containerTypeMapped).append('\''); sb.append(", title='").append(title).append('\''); sb.append(", unescapedDescription='").append(unescapedDescription).append('\''); sb.append(", maxLength=").append(maxLength); @@ -1217,6 +1229,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti Objects.equals(defaultValueWithParam, that.defaultValueWithParam) && Objects.equals(baseType, that.baseType) && Objects.equals(containerType, that.containerType) && + Objects.equals(containerTypeMapped, that.containerTypeMapped) && Objects.equals(title, that.title) && Objects.equals(unescapedDescription, that.unescapedDescription) && Objects.equals(maxLength, that.maxLength) && @@ -1251,7 +1264,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti return Objects.hash(openApiType, baseName, complexType, getter, setter, description, dataType, datatypeWithEnum, dataFormat, name, min, max, defaultValue, - defaultValueWithParam, baseType, containerType, title, unescapedDescription, + defaultValueWithParam, baseType, containerType, containerTypeMapped, title, unescapedDescription, maxLength, minLength, pattern, example, jsonSchema, minimum, maximum, exclusiveMinimum, exclusiveMaximum, required, deprecated, hasMoreNonReadOnly, isPrimitiveType, isModel, isContainer, isString, isNumeric, diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java index 8212d0b8a1e0..c43c22bb7fb8 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java @@ -33,6 +33,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties { public String dataType; public String baseType; public String containerType; + public String containerTypeMapped; // language-specified container type (e.g. `dict` in python for map) public boolean hasHeaders; public boolean isString; public boolean isNumeric; @@ -98,7 +99,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties { @Override public int hashCode() { - return Objects.hash(headers, code, message, examples, dataType, baseType, containerType, hasHeaders, + return Objects.hash(headers, code, message, examples, dataType, baseType, containerType, containerTypeMapped, hasHeaders, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBoolean, isDate, isDateTime, isUuid, isEmail, isPassword, isModel, isFreeFormObject, isAnyType, isDefault, simpleType, primitiveType, isMap, isArray, isBinary, isFile, schema, jsonSchema, vendorExtensions, items, additionalProperties, @@ -174,6 +175,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties { Objects.equals(dataType, that.dataType) && Objects.equals(baseType, that.baseType) && Objects.equals(containerType, that.containerType) && + Objects.equals(containerTypeMapped, that.containerTypeMapped) && Objects.equals(schema, that.schema) && Objects.equals(jsonSchema, that.jsonSchema) && Objects.equals(vendorExtensions, that.vendorExtensions) && @@ -555,6 +557,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties { sb.append(", dataType='").append(dataType).append('\''); sb.append(", baseType='").append(baseType).append('\''); sb.append(", containerType='").append(containerType).append('\''); + sb.append(", containerTypeMapped='").append(containerTypeMapped).append('\''); sb.append(", hasHeaders=").append(hasHeaders); sb.append(", isString=").append(isString); sb.append(", isNumeric=").append(isNumeric); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 10050e57963f..4ab4aa550a48 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -3679,6 +3679,7 @@ public class DefaultCodegen implements CodegenConfig { } property.isContainer = true; property.containerType = "map"; + property.containerTypeMapped = typeMapping.get(property.containerType); // TODO remove this hack in the future, code should use minProperties and maxProperties for object schemas property.minItems = p.getMinProperties(); property.maxItems = p.getMaxProperties(); @@ -4025,8 +4026,10 @@ public class DefaultCodegen implements CodegenConfig { property.isContainer = true; if (ModelUtils.isSet(p)) { property.containerType = "set"; + property.containerTypeMapped = typeMapping.get(property.containerType); } else { property.containerType = "array"; + property.containerTypeMapped = typeMapping.get(property.containerType); } property.baseType = getSchemaType(p); @@ -4816,6 +4819,7 @@ public class DefaultCodegen implements CodegenConfig { r.simpleType = false; r.isArray = true; r.containerType = cp.containerType; + r.containerTypeMapped = typeMapping.get(cp.containerType); ArraySchema as = (ArraySchema) responseSchema; CodegenProperty items = fromProperty("response", getSchemaItems(as), false); r.setItems(items); @@ -4877,6 +4881,7 @@ public class DefaultCodegen implements CodegenConfig { } r.simpleType = false; r.containerType = cp.containerType; + r.containerTypeMapped = cp.containerTypeMapped; addVarsRequiredVarsAdditionalProps(responseSchema, r); } else if (ModelUtils.isAnyType(responseSchema)) { addVarsRequiredVarsAdditionalProps(responseSchema, r); @@ -5236,6 +5241,7 @@ public class DefaultCodegen implements CodegenConfig { // set containerType codegenParameter.containerType = codegenProperty.containerType; + codegenParameter.containerTypeMapped = codegenProperty.containerTypeMapped; // enum updateCodegenPropertyEnum(codegenProperty); @@ -5644,15 +5650,13 @@ public class DefaultCodegen implements CodegenConfig { addImport(model, property.complexType); model.parent = toInstantiationType(schema); if (!addSchemaImportsFromV3SpecLocations) { - final String containerType = property.containerType; - final String instantiationType = instantiationTypes.get(containerType); + final String instantiationType = instantiationTypes.get(property.containerType); if (instantiationType != null) { addImport(model, instantiationType); } - final String mappedType = typeMapping.get(containerType); - if (mappedType != null) { - addImport(model, mappedType); + if (property.containerTypeMapped != null) { + addImport(model, property.containerTypeMapped); } } } @@ -7041,6 +7045,7 @@ public class DefaultCodegen implements CodegenConfig { codegenParameter.unescapedDescription = codegenProperty.getDescription(); codegenParameter.jsonSchema = Json.pretty(propertySchema); codegenParameter.containerType = codegenProperty.containerType; + codegenParameter.containerTypeMapped = codegenProperty.containerTypeMapped; if (codegenProperty.getVendorExtensions() != null && !codegenProperty.getVendorExtensions().isEmpty()) { codegenParameter.vendorExtensions = codegenProperty.getVendorExtensions(); @@ -7195,6 +7200,7 @@ public class DefaultCodegen implements CodegenConfig { codegenParameter.isMap = Boolean.TRUE; codegenParameter.isNullable = codegenProperty.isNullable; codegenParameter.containerType = codegenProperty.containerType; + codegenParameter.containerTypeMapped = codegenProperty.containerTypeMapped; // set nullable setParameterNullable(codegenParameter, codegenProperty); @@ -7305,6 +7311,7 @@ public class DefaultCodegen implements CodegenConfig { codegenParameter.isContainer = Boolean.TRUE; codegenParameter.isNullable = codegenProperty.isNullable; codegenParameter.containerType = codegenProperty.containerType; + codegenParameter.containerTypeMapped = codegenProperty.containerTypeMapped; // set nullable setParameterNullable(codegenParameter, codegenProperty); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java index f895e511f222..a34bb665f964 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java @@ -460,12 +460,15 @@ public class PythonClientCodegenTest { op = codegen.fromOperation(path, "post", p, null); Assert.assertEquals(op.allParams.get(0).baseName, "User"); Assert.assertEquals(op.allParams.get(0).containerType, "array"); + Assert.assertEquals(op.allParams.get(0).containerTypeMapped, "List"); path = "/pet"; p = openAPI.getPaths().get(path).getPost(); op = codegen.fromOperation(path, "post", p, null); Assert.assertEquals(op.allParams.get(0).baseName, "Pet"); Assert.assertEquals(op.allParams.get(0).containerType, null); + Assert.assertEquals(op.allParams.get(0).containerTypeMapped, null); + } @Test(description = "test containerType (dict) in parameters") @@ -478,6 +481,7 @@ public class PythonClientCodegenTest { Operation p = openAPI.getPaths().get(path).getGet(); CodegenOperation op = codegen.fromOperation(path, "get", p, null); Assert.assertEquals(op.allParams.get(0).containerType, "map"); + Assert.assertEquals(op.allParams.get(0).containerTypeMapped, "Dict"); Assert.assertEquals(op.allParams.get(0).baseName, "dict_string_integer"); } } diff --git a/samples/server/petstore/java-inflector/.openapi-generator/FILES b/samples/server/petstore/java-inflector/.openapi-generator/FILES index fdb8efbe6b28..7536825cbf87 100644 --- a/samples/server/petstore/java-inflector/.openapi-generator/FILES +++ b/samples/server/petstore/java-inflector/.openapi-generator/FILES @@ -15,15 +15,12 @@ src/gen/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java src/gen/java/org/openapitools/model/ArrayOfNumberOnly.java src/gen/java/org/openapitools/model/ArrayTest.java src/gen/java/org/openapitools/model/BigCat.java -src/gen/java/org/openapitools/model/BigCatAllOf.java src/gen/java/org/openapitools/model/Capitalization.java src/gen/java/org/openapitools/model/Cat.java -src/gen/java/org/openapitools/model/CatAllOf.java src/gen/java/org/openapitools/model/Category.java src/gen/java/org/openapitools/model/ClassModel.java src/gen/java/org/openapitools/model/Client.java src/gen/java/org/openapitools/model/Dog.java -src/gen/java/org/openapitools/model/DogAllOf.java src/gen/java/org/openapitools/model/EnumArrays.java src/gen/java/org/openapitools/model/EnumClass.java src/gen/java/org/openapitools/model/EnumTest.java diff --git a/samples/server/petstore/java-inflector/.openapi-generator/VERSION b/samples/server/petstore/java-inflector/.openapi-generator/VERSION index 5f68295fc196..757e67400401 100644 --- a/samples/server/petstore/java-inflector/.openapi-generator/VERSION +++ b/samples/server/petstore/java-inflector/.openapi-generator/VERSION @@ -1 +1 @@ -6.0.0-SNAPSHOT \ No newline at end of file +7.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/java-inflector/inflector.yaml b/samples/server/petstore/java-inflector/inflector.yaml index b7d071b0c4e6..63278f330a0f 100644 --- a/samples/server/petstore/java-inflector/inflector.yaml +++ b/samples/server/petstore/java-inflector/inflector.yaml @@ -17,15 +17,12 @@ ArrayOfArrayOfNumberOnly : org.openapitools.model.ArrayOfArrayOfNumberOnly ArrayOfNumberOnly : org.openapitools.model.ArrayOfNumberOnly ArrayTest : org.openapitools.model.ArrayTest BigCat : org.openapitools.model.BigCat -BigCatAllOf : org.openapitools.model.BigCatAllOf Capitalization : org.openapitools.model.Capitalization Cat : org.openapitools.model.Cat -CatAllOf : org.openapitools.model.CatAllOf Category : org.openapitools.model.Category ClassModel : org.openapitools.model.ClassModel Client : org.openapitools.model.Client Dog : org.openapitools.model.Dog -DogAllOf : org.openapitools.model.DogAllOf EnumArrays : org.openapitools.model.EnumArrays EnumClass : org.openapitools.model.EnumClass EnumTest : org.openapitools.model.EnumTest diff --git a/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/Animal.java b/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/Animal.java index 57da88bd04c1..83a35cb8fb16 100644 --- a/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/Animal.java +++ b/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/Animal.java @@ -1,6 +1,7 @@ package org.openapitools.model; import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonSubTypes; diff --git a/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/BigCat.java b/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/BigCat.java index 505ff7a4ecb0..1066d414917d 100644 --- a/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/BigCat.java +++ b/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/BigCat.java @@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.openapitools.model.BigCatAllOf; import org.openapitools.model.Cat; diff --git a/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/Cat.java b/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/Cat.java index 7ccefb1064cb..c2128a55abf5 100644 --- a/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/Cat.java +++ b/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/Cat.java @@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import org.openapitools.model.Animal; -import org.openapitools.model.CatAllOf; diff --git a/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/Dog.java b/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/Dog.java index ac40fdebe91f..d0309bdf1336 100644 --- a/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/Dog.java +++ b/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/Dog.java @@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import org.openapitools.model.Animal; -import org.openapitools.model.DogAllOf; diff --git a/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/MapTest.java b/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/MapTest.java index 23c120a4f2c5..dad11aaad01b 100644 --- a/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/MapTest.java +++ b/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/MapTest.java @@ -7,7 +7,6 @@ import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.util.HashMap; -import java.util.List; import java.util.Map; diff --git a/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java index 4136f162932e..4533e418bb34 100644 --- a/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -7,7 +7,6 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.util.Date; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; import org.openapitools.model.Animal; diff --git a/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/ModelList.java b/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/ModelList.java index 5ae57a336eb8..999c8b087bb8 100644 --- a/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/ModelList.java +++ b/samples/server/petstore/java-inflector/src/gen/java/org/openapitools/model/ModelList.java @@ -3,6 +3,7 @@ package org.openapitools.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/server/petstore/java-inflector/src/main/openapi/openapi.yaml b/samples/server/petstore/java-inflector/src/main/openapi/openapi.yaml index 82d6b7b8bcc7..432de96b6f01 100644 --- a/samples/server/petstore/java-inflector/src/main/openapi/openapi.yaml +++ b/samples/server/petstore/java-inflector/src/main/openapi/openapi.yaml @@ -46,7 +46,7 @@ paths: tags: - pet x-codegen-request-body-name: body - x-contentType: application/json + x-content-type: application/json x-accepts: application/json put: operationId: updatePet @@ -81,7 +81,7 @@ paths: tags: - pet x-codegen-request-body-name: body - x-contentType: application/json + x-content-type: application/json x-accepts: application/json /pet/findByStatus: get: @@ -250,13 +250,7 @@ paths: content: application/x-www-form-urlencoded: schema: - properties: - name: - description: Updated name of the pet - type: string - status: - description: Updated status of the pet - type: string + $ref: '#/components/schemas/updatePetWithForm_request' responses: "405": content: {} @@ -268,7 +262,7 @@ paths: summary: Updates a pet in the store with form data tags: - pet - x-contentType: application/x-www-form-urlencoded + x-content-type: application/x-www-form-urlencoded x-accepts: application/json /pet/{petId}/uploadImage: post: @@ -285,14 +279,7 @@ paths: content: multipart/form-data: schema: - properties: - additionalMetadata: - description: Additional data to pass to server - type: string - file: - description: file to upload - format: binary - type: string + $ref: '#/components/schemas/uploadFile_request' responses: "200": content: @@ -307,7 +294,7 @@ paths: summary: uploads an image tags: - pet - x-contentType: multipart/form-data + x-content-type: multipart/form-data x-accepts: application/json /store/inventory: get: @@ -356,7 +343,7 @@ paths: tags: - store x-codegen-request-body-name: body - x-contentType: '*/*' + x-content-type: '*/*' x-accepts: application/json /store/order/{order_id}: delete: @@ -434,7 +421,7 @@ paths: tags: - user x-codegen-request-body-name: body - x-contentType: '*/*' + x-content-type: '*/*' x-accepts: application/json /user/createWithArray: post: @@ -456,7 +443,7 @@ paths: tags: - user x-codegen-request-body-name: body - x-contentType: '*/*' + x-content-type: '*/*' x-accepts: application/json /user/createWithList: post: @@ -478,7 +465,7 @@ paths: tags: - user x-codegen-request-body-name: body - x-contentType: '*/*' + x-content-type: '*/*' x-accepts: application/json /user/login: get: @@ -614,7 +601,7 @@ paths: tags: - user x-codegen-request-body-name: body - x-contentType: '*/*' + x-content-type: '*/*' x-accepts: application/json /fake_classname_test: patch: @@ -640,7 +627,7 @@ paths: tags: - fake_classname_tags 123#$%^ x-codegen-request-body-name: body - x-contentType: application/json + x-content-type: application/json x-accepts: application/json /fake: delete: @@ -763,24 +750,7 @@ paths: content: application/x-www-form-urlencoded: schema: - properties: - enum_form_string_array: - description: Form parameter enum test (string array) - items: - default: $ - enum: - - '>' - - $ - type: string - type: array - enum_form_string: - default: -efg - description: Form parameter enum test (string) - enum: - - _abc - - -efg - - (xyz) - type: string + $ref: '#/components/schemas/testEnumParameters_request' responses: "400": content: {} @@ -791,7 +761,7 @@ paths: summary: To test enum parameters tags: - fake - x-contentType: application/x-www-form-urlencoded + x-content-type: application/x-www-form-urlencoded x-accepts: application/json patch: description: To test "client" model @@ -814,7 +784,7 @@ paths: tags: - fake x-codegen-request-body-name: body - x-contentType: application/json + x-content-type: application/json x-accepts: application/json post: description: |- @@ -827,77 +797,7 @@ paths: content: application/x-www-form-urlencoded: schema: - properties: - integer: - description: None - format: int32 - maximum: 100 - minimum: 10 - type: integer - int32: - description: None - format: int32 - maximum: 200 - minimum: 20 - type: integer - int64: - description: None - format: int64 - type: integer - number: - description: None - maximum: 543.2 - minimum: 32.1 - type: number - float: - description: None - format: float - maximum: 987.6 - type: number - double: - description: None - format: double - maximum: 123.4 - minimum: 67.8 - type: number - string: - description: None - pattern: "/[a-z]/i" - type: string - pattern_without_delimiter: - description: None - pattern: "^[A-Z].*" - type: string - byte: - description: None - format: byte - type: string - binary: - description: None - format: binary - type: string - date: - description: None - format: date - type: string - dateTime: - description: None - format: date-time - type: string - password: - description: None - format: password - maxLength: 64 - minLength: 10 - type: string - callback: - description: None - type: string - required: - - byte - - double - - number - - pattern_without_delimiter + $ref: '#/components/schemas/testEndpointParameters_request' required: true responses: "400": @@ -915,7 +815,7 @@ paths: 가짜 엔드 포인트 tags: - fake - x-contentType: application/x-www-form-urlencoded + x-content-type: application/x-www-form-urlencoded x-accepts: application/json /fake/outer/number: post: @@ -938,7 +838,7 @@ paths: tags: - fake x-codegen-request-body-name: body - x-contentType: '*/*' + x-content-type: '*/*' x-accepts: '*/*' /fake/outer/string: post: @@ -961,7 +861,7 @@ paths: tags: - fake x-codegen-request-body-name: body - x-contentType: '*/*' + x-content-type: '*/*' x-accepts: '*/*' /fake/outer/boolean: post: @@ -984,7 +884,7 @@ paths: tags: - fake x-codegen-request-body-name: body - x-contentType: '*/*' + x-content-type: '*/*' x-accepts: '*/*' /fake/outer/composite: post: @@ -1007,7 +907,7 @@ paths: tags: - fake x-codegen-request-body-name: body - x-contentType: '*/*' + x-content-type: '*/*' x-accepts: '*/*' /fake/jsonFormData: get: @@ -1016,16 +916,7 @@ paths: content: application/x-www-form-urlencoded: schema: - properties: - param: - description: field1 - type: string - param2: - description: field2 - type: string - required: - - param - - param2 + $ref: '#/components/schemas/testJsonFormData_request' required: true responses: "200": @@ -1034,7 +925,7 @@ paths: summary: test json serialization of form data tags: - fake - x-contentType: application/x-www-form-urlencoded + x-content-type: application/x-www-form-urlencoded x-accepts: application/json /fake/inline-additionalProperties: post: @@ -1056,7 +947,7 @@ paths: tags: - fake x-codegen-request-body-name: param - x-contentType: application/json + x-content-type: application/json x-accepts: application/json /fake/body-with-query-params: put: @@ -1080,7 +971,7 @@ paths: tags: - fake x-codegen-request-body-name: body - x-contentType: application/json + x-content-type: application/json x-accepts: application/json /fake/create_xml_item: post: @@ -1116,7 +1007,7 @@ paths: tags: - fake x-codegen-request-body-name: XmlItem - x-contentType: application/xml + x-content-type: application/xml x-accepts: application/json /another-fake/dummy: patch: @@ -1140,7 +1031,7 @@ paths: tags: - $another-fake? x-codegen-request-body-name: body - x-contentType: application/json + x-content-type: application/json x-accepts: application/json /fake/body-with-file-schema: put: @@ -1160,7 +1051,7 @@ paths: tags: - fake x-codegen-request-body-name: body - x-contentType: application/json + x-content-type: application/json x-accepts: application/json /fake/test-query-parameters: put: @@ -1231,16 +1122,7 @@ paths: content: multipart/form-data: schema: - properties: - additionalMetadata: - description: Additional data to pass to server - type: string - requiredFile: - description: file to upload - format: binary - type: string - required: - - requiredFile + $ref: '#/components/schemas/uploadFileWithRequiredFile_request' required: true responses: "200": @@ -1256,7 +1138,7 @@ paths: summary: uploads an image (required) tags: - pet - x-contentType: multipart/form-data + x-content-type: multipart/form-data x-accepts: application/json components: schemas: @@ -1482,15 +1364,29 @@ components: Dog: allOf: - $ref: '#/components/schemas/Animal' - - $ref: '#/components/schemas/Dog_allOf' + - properties: + breed: + type: string + type: object Cat: allOf: - $ref: '#/components/schemas/Animal' - - $ref: '#/components/schemas/Cat_allOf' + - properties: + declawed: + type: boolean + type: object BigCat: allOf: - $ref: '#/components/schemas/Cat' - - $ref: '#/components/schemas/BigCat_allOf' + - properties: + kind: + enum: + - lions + - tigers + - leopards + - jaguars + type: string + type: object Animal: discriminator: propertyName: className @@ -2147,26 +2043,142 @@ components: xml: namespace: http://a.com/schema prefix: pre - Dog_allOf: + updatePetWithForm_request: properties: - breed: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet type: string type: object - Cat_allOf: + uploadFile_request: properties: - declawed: - type: boolean + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string type: object - BigCat_allOf: + testEnumParameters_request: properties: - kind: + enum_form_string_array: + description: Form parameter enum test (string array) + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + enum_form_string: + default: -efg + description: Form parameter enum test (string) enum: - - lions - - tigers - - leopards - - jaguars + - _abc + - -efg + - (xyz) type: string type: object + testEndpointParameters_request: + properties: + integer: + description: None + format: int32 + maximum: 100 + minimum: 10 + type: integer + int32: + description: None + format: int32 + maximum: 200 + minimum: 20 + type: integer + int64: + description: None + format: int64 + type: integer + number: + description: None + maximum: 543.2 + minimum: 32.1 + type: number + float: + description: None + format: float + maximum: 987.6 + type: number + double: + description: None + format: double + maximum: 123.4 + minimum: 67.8 + type: number + string: + description: None + pattern: "/[a-z]/i" + type: string + pattern_without_delimiter: + description: None + pattern: "^[A-Z].*" + type: string + byte: + description: None + format: byte + type: string + binary: + description: None + format: binary + type: string + date: + description: None + format: date + type: string + dateTime: + description: None + format: date-time + type: string + password: + description: None + format: password + maxLength: 64 + minLength: 10 + type: string + callback: + description: None + type: string + required: + - byte + - double + - number + - pattern_without_delimiter + type: object + testJsonFormData_request: + properties: + param: + description: field1 + type: string + param2: + description: field2 + type: string + required: + - param + - param2 + type: object + uploadFileWithRequiredFile_request: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + requiredFile: + description: file to upload + format: binary + type: string + required: + - requiredFile + type: object securitySchemes: petstore_auth: flows: diff --git a/samples/server/petstore/java-undertow/src/main/java/org/openapitools/handler/PathHandlerInterface.java b/samples/server/petstore/java-undertow/src/main/java/org/openapitools/handler/PathHandlerInterface.java index f63becce9409..8c6930f2c951 100644 --- a/samples/server/petstore/java-undertow/src/main/java/org/openapitools/handler/PathHandlerInterface.java +++ b/samples/server/petstore/java-undertow/src/main/java/org/openapitools/handler/PathHandlerInterface.java @@ -536,10 +536,10 @@ public interface PathHandlerInterface { *

* * - *

Response headers: [CodegenProperty{openApiType='integer', baseName='X-Rate-Limit', complexType='null', getter='getxRateLimit', setter='setxRateLimit', description='calls per hour allowed by the user', dataType='Integer', datatypeWithEnum='Integer', dataFormat='int32', name='xRateLimit', min='null', max='null', defaultValue='null', defaultValueWithParam=' = data.X-Rate-Limit;', baseType='Integer', containerType='null', title='null', unescapedDescription='calls per hour allowed by the user', maxLength=null, minLength=null, pattern='null', example='null', jsonSchema='{ + *

Response headers: [CodegenProperty{openApiType='integer', baseName='X-Rate-Limit', complexType='null', getter='getxRateLimit', setter='setxRateLimit', description='calls per hour allowed by the user', dataType='Integer', datatypeWithEnum='Integer', dataFormat='int32', name='xRateLimit', min='null', max='null', defaultValue='null', defaultValueWithParam=' = data.X-Rate-Limit;', baseType='Integer', containerType='null', containerTypeMapped='null', title='null', unescapedDescription='calls per hour allowed by the user', maxLength=null, minLength=null, pattern='null', example='null', jsonSchema='{ "type" : "integer", "format" : "int32" -}', minimum='null', maximum='null', exclusiveMinimum=false, exclusiveMaximum=false, required=false, deprecated=false, hasMoreNonReadOnly=false, isPrimitiveType=true, isModel=false, isContainer=false, isString=false, isNumeric=true, isInteger=true, isShort=true, 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, isPassword=false, isFreeFormObject=false, isArray=false, isMap=false, isEnum=false, isInnerEnum=false, isEnumRef=false, isAnyType=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, isNew=false, isOverridden=null, _enum=null, allowableValues=null, items=null, additionalProperties=null, vars=[], requiredVars=[], mostInnerItems=null, vendorExtensions={}, hasValidation=false, isInherited=false, discriminatorValue='null', nameInCamelCase='XRateLimit', nameInSnakeCase='X_RATE_LIMIT', enumName='null', maxItems=null, minItems=null, maxProperties=null, minProperties=null, uniqueItems=false, uniqueItemsBoolean=null, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, isVoid=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false, getHasDiscriminatorWithNonEmptyMapping=false, composedSchemas=null, hasMultipleTypes=false, requiredVarsMap=null, ref=null, schemaIsFromAdditionalProperties=false, isBooleanSchemaTrue=false, isBooleanSchemaFalse=false, format=int32, dependentRequired=null, contains=null}, CodegenProperty{openApiType='string', baseName='X-Expires-After', complexType='Date', getter='getxExpiresAfter', setter='setxExpiresAfter', description='date in UTC when token expires', dataType='Date', datatypeWithEnum='Date', dataFormat='date-time', name='xExpiresAfter', min='null', max='null', defaultValue='null', defaultValueWithParam=' = data.X-Expires-After;', baseType='Date', containerType='null', title='null', unescapedDescription='date in UTC when token expires', maxLength=null, minLength=null, pattern='null', example='null', jsonSchema='{ +}', minimum='null', maximum='null', exclusiveMinimum=false, exclusiveMaximum=false, required=false, deprecated=false, hasMoreNonReadOnly=false, isPrimitiveType=true, isModel=false, isContainer=false, isString=false, isNumeric=true, isInteger=true, isShort=true, 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, isPassword=false, isFreeFormObject=false, isArray=false, isMap=false, isEnum=false, isInnerEnum=false, isEnumRef=false, isAnyType=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, isNew=false, isOverridden=null, _enum=null, allowableValues=null, items=null, additionalProperties=null, vars=[], requiredVars=[], mostInnerItems=null, vendorExtensions={}, hasValidation=false, isInherited=false, discriminatorValue='null', nameInCamelCase='XRateLimit', nameInSnakeCase='X_RATE_LIMIT', enumName='null', maxItems=null, minItems=null, maxProperties=null, minProperties=null, uniqueItems=false, uniqueItemsBoolean=null, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, isVoid=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false, getHasDiscriminatorWithNonEmptyMapping=false, composedSchemas=null, hasMultipleTypes=false, requiredVarsMap=null, ref=null, schemaIsFromAdditionalProperties=false, isBooleanSchemaTrue=false, isBooleanSchemaFalse=false, format=int32, dependentRequired=null, contains=null}, CodegenProperty{openApiType='string', baseName='X-Expires-After', complexType='Date', getter='getxExpiresAfter', setter='setxExpiresAfter', description='date in UTC when token expires', dataType='Date', datatypeWithEnum='Date', dataFormat='date-time', name='xExpiresAfter', min='null', max='null', defaultValue='null', defaultValueWithParam=' = data.X-Expires-After;', baseType='Date', containerType='null', containerTypeMapped='null', title='null', unescapedDescription='date in UTC when token expires', maxLength=null, minLength=null, pattern='null', example='null', jsonSchema='{ "type" : "string", "format" : "date-time" }', minimum='null', maximum='null', exclusiveMinimum=false, exclusiveMaximum=false, required=false, deprecated=false, hasMoreNonReadOnly=false, isPrimitiveType=false, isModel=false, isContainer=false, isString=false, 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=true, isUuid=false, isUri=false, isEmail=false, isPassword=false, isFreeFormObject=false, isArray=false, isMap=false, isEnum=false, isInnerEnum=false, isEnumRef=false, isAnyType=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, isNew=false, isOverridden=null, _enum=null, allowableValues=null, items=null, additionalProperties=null, vars=[], requiredVars=[], mostInnerItems=null, vendorExtensions={}, hasValidation=false, isInherited=false, discriminatorValue='null', nameInCamelCase='XExpiresAfter', nameInSnakeCase='X_EXPIRES_AFTER', enumName='null', maxItems=null, minItems=null, maxProperties=null, minProperties=null, uniqueItems=false, uniqueItemsBoolean=null, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, isVoid=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false, getHasDiscriminatorWithNonEmptyMapping=false, composedSchemas=null, hasMultipleTypes=false, requiredVarsMap=null, ref=null, schemaIsFromAdditionalProperties=false, isBooleanSchemaTrue=false, isBooleanSchemaFalse=false, format=date-time, dependentRequired=null, contains=null}]