From 3a667784acab58d5107daf557cd1ba7bb679e0a1 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Tue, 26 Oct 2021 12:49:32 -0700 Subject: [PATCH] Adds ComposedSchema to store schema composed schemas (#10653) * Adds ComposedSchema and the ability to set it in CodegenModel and CodegenProperty * Adds ComposedSchemas class and adds getters and setters for it in schema implementors * Adds and uses getComposedSchemas * Makes method private * Uses setComposedSchemas for CodegenParameter and CodegenResponse * Samples regeneratoed, tweaked string representation * Removes null default * Removes anyOfProps, oneOfProps, allOfProps * Removes unneeded line --- .../codegen/CodegenComposedSchemas.java | 66 +++++++++++++++++++ .../openapitools/codegen/CodegenModel.java | 28 ++++---- .../codegen/CodegenParameter.java | 18 ++++- .../openapitools/codegen/CodegenProperty.java | 18 ++++- .../openapitools/codegen/CodegenResponse.java | 15 ++++- .../openapitools/codegen/DefaultCodegen.java | 44 +++++++++---- .../IJsonSchemaValidationProperties.java | 5 ++ .../handler/PathHandlerInterface.java | 4 +- 8 files changed, 168 insertions(+), 30 deletions(-) create mode 100644 modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenComposedSchemas.java diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenComposedSchemas.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenComposedSchemas.java new file mode 100644 index 00000000000..f801853dafc --- /dev/null +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenComposedSchemas.java @@ -0,0 +1,66 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.codegen; + +import java.util.*; + +public class CodegenComposedSchemas { + private List allOf; + private List oneOf; + private List anyOf; + + public CodegenComposedSchemas(List allOf, List oneOf, List anyOf) { + this.allOf = allOf; + this.oneOf = oneOf; + this.anyOf = anyOf; + } + + public List getAllOf() { + return allOf; + } + + public List getOneOf() { + return oneOf; + } + + public List getAnyOf() { + return anyOf; + } + + public String toString() { + final StringBuilder sb = new StringBuilder("CodegenComposedSchemas{"); + sb.append("oneOf=").append(oneOf); + sb.append(", anyOf=").append(anyOf); + sb.append(", allOf=").append(allOf); + sb.append('}'); + return sb.toString(); + } + + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + CodegenComposedSchemas that = (CodegenComposedSchemas) o; + return Objects.equals(oneOf, that.oneOf) && + Objects.equals(anyOf, that.anyOf) && + Objects.equals(allOf, that.allOf); + } + + @Override + public int hashCode() { + return Objects.hash(oneOf, anyOf, allOf); + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java index ab9f23fba67..e09c32c96b2 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java @@ -49,11 +49,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties { public Set oneOf = new TreeSet(); public Set allOf = new TreeSet(); - // anyOf, oneOf, allOf with full properties/tags (e.g. isString, etc) - public List anyOfProps = new ArrayList<>(); - public List allOfProps = new ArrayList<>(); - public List oneOfProps = new ArrayList<>(); - // The schema name as written in the OpenAPI document. public String name; // The language-specific name of the class that implements this schema. @@ -110,6 +105,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties { public ExternalDocumentation externalDocumentation; public Map vendorExtensions = new HashMap(); + private CodegenComposedSchemas composedSchemas; /** * The type of the value for the additionalProperties keyword in the OAS document. @@ -810,6 +806,16 @@ public class CodegenModel implements IJsonSchemaValidationProperties { this.isAnyType = isAnyType; } + @Override + public void setComposedSchemas(CodegenComposedSchemas composedSchemas) { + this.composedSchemas = composedSchemas; + } + + @Override + public CodegenComposedSchemas getComposedSchemas() { + return composedSchemas; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -849,6 +855,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties { getUniqueItems() == that.getUniqueItems() && getExclusiveMinimum() == that.getExclusiveMinimum() && getExclusiveMaximum() == that.getExclusiveMaximum() && + Objects.equals(composedSchemas, that.composedSchemas) && Objects.equals(parent, that.parent) && Objects.equals(parentSchema, that.parentSchema) && Objects.equals(interfaces, that.interfaces) && @@ -856,9 +863,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties { Objects.equals(parentModel, that.parentModel) && Objects.equals(interfaceModels, that.interfaceModels) && Objects.equals(children, that.children) && - Objects.equals(anyOf, that.anyOfProps) && - Objects.equals(oneOf, that.oneOfProps) && - Objects.equals(allOf, that.allOfProps) && Objects.equals(anyOf, that.anyOf) && Objects.equals(oneOf, that.oneOf) && Objects.equals(allOf, that.allOf) && @@ -921,8 +925,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties { getAdditionalPropertiesType(), getMaxProperties(), getMinProperties(), getUniqueItems(), getMaxItems(), getMinItems(), getMaxLength(), getMinLength(), getExclusiveMinimum(), getExclusiveMaximum(), getMinimum(), getMaximum(), getPattern(), getMultipleOf(), getItems(), getAdditionalProperties(), getIsModel(), - getAdditionalPropertiesIsAnyType(), hasDiscriminatorWithNonEmptyMapping, anyOfProps, oneOfProps, allOfProps, - isAnyType); + getAdditionalPropertiesIsAnyType(), hasDiscriminatorWithNonEmptyMapping, + isAnyType, getComposedSchemas()); } @Override @@ -938,9 +942,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties { sb.append(", anyOf=").append(anyOf); sb.append(", oneOf=").append(oneOf); sb.append(", allOf=").append(allOf); - sb.append(", anyOf=").append(anyOfProps); - sb.append(", oneOf=").append(oneOfProps); - sb.append(", allOf=").append(allOfProps); sb.append(", name='").append(name).append('\''); sb.append(", classname='").append(classname).append('\''); sb.append(", title='").append(title).append('\''); @@ -1017,6 +1018,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties { sb.append(", getAdditionalPropertiesIsAnyType=").append(getAdditionalPropertiesIsAnyType()); sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping); sb.append(", getIsAnyType=").append(getIsAnyType()); + sb.append(", composedSchemas=").append(composedSchemas); sb.append('}'); return sb.toString(); } 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 ebd01afdfd2..e0f962215df 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 @@ -107,6 +107,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties { public boolean isNull; private boolean hasRequired; private boolean hasDiscriminatorWithNonEmptyMapping; + private CodegenComposedSchemas composedSchemas; public CodegenParameter copy() { CodegenParameter output = new CodegenParameter(); @@ -159,6 +160,9 @@ public class CodegenParameter implements IJsonSchemaValidationProperties { output.setHasRequired(this.hasRequired); output.setHasDiscriminatorWithNonEmptyMapping(this.hasDiscriminatorWithNonEmptyMapping); + if (this.composedSchemas != null) { + output.setComposedSchemas(this.getComposedSchemas()); + } if (this._enum != null) { output._enum = new ArrayList(this._enum); } @@ -216,7 +220,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, defaultValue, enumName, style, isDeepObject, isAllowEmptyValue, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, _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, additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger, hasDiscriminatorWithNonEmptyMapping); + return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName, style, isDeepObject, isAllowEmptyValue, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, _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, additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger, hasDiscriminatorWithNonEmptyMapping, composedSchemas); } @Override @@ -271,6 +275,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties { getExclusiveMaximum() == that.getExclusiveMaximum() && getExclusiveMinimum() == that.getExclusiveMinimum() && getUniqueItems() == that.getUniqueItems() && + Objects.equals(composedSchemas, that.getComposedSchemas()) && Objects.equals(baseName, that.baseName) && Objects.equals(paramName, that.paramName) && Objects.equals(dataType, that.dataType) && @@ -393,6 +398,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties { sb.append(", getHasVars=").append(hasVars); sb.append(", getHasRequired=").append(hasRequired); sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping); + sb.append(", composedSchemas=").append(composedSchemas); sb.append('}'); return sb.toString(); } @@ -706,5 +712,15 @@ public class CodegenParameter implements IJsonSchemaValidationProperties { public void setIsAnyType(boolean isAnyType) { this.isAnyType = isAnyType; } + + @Override + public void setComposedSchemas(CodegenComposedSchemas composedSchemas) { + this.composedSchemas = composedSchemas; + } + + @Override + public CodegenComposedSchemas getComposedSchemas() { + return composedSchemas; + } } 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 ed1636fc6d5..e326a052fca 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 @@ -191,6 +191,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti private boolean hasVars; private boolean hasRequired; private boolean hasDiscriminatorWithNonEmptyMapping; + private CodegenComposedSchemas composedSchemas = null; public String getBaseName() { return baseName; @@ -614,6 +615,16 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti this.xmlNamespace = xmlNamespace; } + @Override + public void setComposedSchemas(CodegenComposedSchemas composedSchemas) { + this.composedSchemas = composedSchemas; + } + + @Override + public CodegenComposedSchemas getComposedSchemas() { + return composedSchemas; + } + @Override public CodegenProperty clone() { try { @@ -642,6 +653,9 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti if (this.vendorExtensions != null) { cp.vendorExtensions = new HashMap(this.vendorExtensions); } + if (this.composedSchemas != null) { + cp.composedSchemas = this.composedSchemas; + } return cp; } catch (CloneNotSupportedException e) { @@ -882,6 +896,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti sb.append(", getHasVars=").append(getHasVars()); sb.append(", getHasRequired=").append(getHasRequired()); sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping); + sb.append(", composedSchemas=").append(composedSchemas); sb.append('}'); return sb.toString(); } @@ -937,6 +952,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() && getHasVars() == that.getHasVars() && getHasRequired() ==that.getHasRequired() && + Objects.equals(composedSchemas, that.composedSchemas) && Objects.equals(openApiType, that.openApiType) && Objects.equals(baseName, that.baseName) && Objects.equals(complexType, that.complexType) && @@ -999,6 +1015,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti vendorExtensions, hasValidation, isInherited, discriminatorValue, nameInCamelCase, nameInSnakeCase, enumName, maxItems, minItems, isXmlAttribute, xmlPrefix, xmlName, xmlNamespace, isXmlWrapped, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired, - hasDiscriminatorWithNonEmptyMapping); + hasDiscriminatorWithNonEmptyMapping, composedSchemas); } } 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 1a99e774e59..545628931c7 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 @@ -85,6 +85,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties { private boolean hasVars; private boolean hasRequired; private boolean hasDiscriminatorWithNonEmptyMapping; + private CodegenComposedSchemas composedSchemas; @Override public int hashCode() { @@ -96,7 +97,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties { getMaxProperties(), getMinProperties(), uniqueItems, getMaxItems(), getMinItems(), getMaxLength(), getMinLength(), exclusiveMinimum, exclusiveMaximum, getMinimum(), getMaximum(), getPattern(), is1xx, is2xx, is3xx, is4xx, is5xx, additionalPropertiesIsAnyType, hasVars, hasRequired, - hasDiscriminatorWithNonEmptyMapping); + hasDiscriminatorWithNonEmptyMapping, composedSchemas); } @Override @@ -144,6 +145,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties { getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() && getHasVars() == that.getHasVars() && getHasRequired() == that.getHasRequired() && + Objects.equals(composedSchemas, that.getComposedSchemas()) && Objects.equals(vars, that.vars) && Objects.equals(requiredVars, that.requiredVars) && Objects.equals(headers, that.headers) && @@ -482,6 +484,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties { sb.append(", getHasVars=").append(hasVars); sb.append(", getHasRequired=").append(hasRequired); sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping); + sb.append(", composedSchemas=").append(composedSchemas); sb.append('}'); return sb.toString(); } @@ -570,4 +573,14 @@ public class CodegenResponse implements IJsonSchemaValidationProperties { public void setIsAnyType(boolean isAnyType) { this.isAnyType = isAnyType; } + + @Override + public void setComposedSchemas(CodegenComposedSchemas composedSchemas) { + this.composedSchemas = composedSchemas; + } + + @Override + public CodegenComposedSchemas getComposedSchemas() { + return composedSchemas; + } } 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 d5920a2abc7..2c530aeaffe 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 @@ -2440,9 +2440,6 @@ public class DefaultCodegen implements CodegenConfig { // interfaces (schemas defined in allOf, anyOf, oneOf) List interfaces = ModelUtils.getInterfaces(composed); - List anyOfProps = new ArrayList<>(); - List allOfProps = new ArrayList<>(); - List oneOfProps = new ArrayList<>(); if (!interfaces.isEmpty()) { // m.interfaces is for backward compatibility if (m.interfaces == null) @@ -2467,7 +2464,6 @@ public class DefaultCodegen implements CodegenConfig { LOGGER.warn("{} (anyOf schema) already has `{}` defined and therefore it's skipped.", m.name, languageType); } else { m.anyOf.add(languageType); - anyOfProps.add(interfaceProperty); } } else if (composed.getOneOf() != null) { @@ -2475,7 +2471,6 @@ public class DefaultCodegen implements CodegenConfig { LOGGER.warn("{} (oneOf schema) already has `{}` defined and therefore it's skipped.", m.name, languageType); } else { m.oneOf.add(languageType); - oneOfProps.add(interfaceProperty); } } else if (composed.getAllOf() != null) { // no need to add primitive type to allOf, which should comprise of schemas (models) only @@ -2511,23 +2506,16 @@ public class DefaultCodegen implements CodegenConfig { if (composed.getAnyOf() != null) { m.anyOf.add(modelName); - anyOfProps.add(interfaceProperty); } else if (composed.getOneOf() != null) { m.oneOf.add(modelName); - oneOfProps.add(interfaceProperty); } else if (composed.getAllOf() != null) { m.allOf.add(modelName); - allOfProps.add(interfaceProperty); } else { LOGGER.error("Composed schema has incorrect anyOf, allOf, oneOf defined: {}", composed); } } } - m.oneOfProps = oneOfProps; - m.allOfProps = allOfProps; - m.anyOfProps = anyOfProps; - if (parent != null && composed.getAllOf() != null) { // set parent for allOf only m.parentSchema = parentName; m.parent = toModelName(parentName); @@ -2696,6 +2684,7 @@ public class DefaultCodegen implements CodegenConfig { } m.setTypeProperties(schema); + m.setComposedSchemas(getComposedSchemas(schema)); if (ModelUtils.isArraySchema(schema)) { CodegenProperty arrayProperty = fromProperty(name, schema); m.setItems(arrayProperty.items); @@ -3514,6 +3503,7 @@ public class DefaultCodegen implements CodegenConfig { } property.setTypeProperties(p); + property.setComposedSchemas(getComposedSchemas(p)); if (ModelUtils.isIntegerSchema(p)) { // integer type property.isNumeric = Boolean.TRUE; if (ModelUtils.isLongSchema(p)) { // int64/long format @@ -4265,6 +4255,7 @@ public class DefaultCodegen implements CodegenConfig { } r.setTypeProperties(responseSchema); + r.setComposedSchemas(getComposedSchemas(responseSchema)); if (ModelUtils.isArraySchema(responseSchema)) { r.simpleType = false; r.containerType = cp.containerType; @@ -4547,6 +4538,7 @@ public class DefaultCodegen implements CodegenConfig { } ModelUtils.syncValidationProperties(parameterSchema, codegenParameter); codegenParameter.setTypeProperties(parameterSchema); + codegenParameter.setComposedSchemas(getComposedSchemas(parameterSchema)); if (Boolean.TRUE.equals(parameterSchema.getNullable())) { // use nullable defined in the spec codegenParameter.isNullable = true; @@ -6156,6 +6148,7 @@ public class DefaultCodegen implements CodegenConfig { Schema ps = unaliasSchema(propertySchema, importMapping); ModelUtils.syncValidationProperties(ps, codegenParameter); codegenParameter.setTypeProperties(ps); + codegenParameter.setComposedSchemas(getComposedSchemas(ps)); if (ps.getPattern() != null) { codegenParameter.pattern = toRegularExpression(ps.getPattern()); } @@ -6590,6 +6583,7 @@ public class DefaultCodegen implements CodegenConfig { ModelUtils.syncValidationProperties(unaliasedSchema, codegenParameter); codegenParameter.setTypeProperties(unaliasedSchema); + codegenParameter.setComposedSchemas(getComposedSchemas(unaliasedSchema)); // TODO in the future switch al the below schema usages to unaliasedSchema // because it keeps models as refs and will not get their referenced schemas if (ModelUtils.isArraySchema(schema)) { @@ -7154,4 +7148,30 @@ public class DefaultCodegen implements CodegenConfig { protected String getCollectionFormat(CodegenParameter codegenParameter) { return null; } + + private CodegenComposedSchemas getComposedSchemas(Schema schema) { + if (!(schema instanceof ComposedSchema)) { + return null; + } + ComposedSchema cs = (ComposedSchema) schema; + return new CodegenComposedSchemas( + getComposedProperties(cs.getAllOf(), "allOf"), + getComposedProperties(cs.getOneOf(), "oneOf"), + getComposedProperties(cs.getAnyOf(), "anyOf") + ); + } + + private List getComposedProperties(List xOfCollection, String collectionName) { + if (xOfCollection == null) { + return null; + } + List xOf = new ArrayList<>(); + int i = 0; + for (Schema xOfSchema: xOfCollection) { + CodegenProperty cp = fromProperty(collectionName + "_" + String.valueOf(i), xOfSchema); + xOf.add(cp); + i += 1; + } + return xOf; + } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java index b3833e47f6f..fe80c549ac6 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java @@ -145,6 +145,11 @@ public interface IJsonSchemaValidationProperties { void setIsAnyType(boolean isAnyType); + CodegenComposedSchemas getComposedSchemas(); + + void setComposedSchemas(CodegenComposedSchemas composedSchemas); + + /** * Syncs all the schema's type properties into the IJsonSchemaValidationProperties instance * for now this only supports types without format information 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 859109086a5..70d25fdaee1 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 @@ -539,10 +539,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='{ "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, isFreeFormObject=false, isArray=false, isMap=false, isEnum=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, _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, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false, getHasDiscriminatorWithNonEmptyMapping=false}, 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, isFreeFormObject=false, isArray=false, isMap=false, isEnum=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, _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, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false, getHasDiscriminatorWithNonEmptyMapping=false, composedSchemas=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='{ "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, isFreeFormObject=false, isArray=false, isMap=false, isEnum=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, _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, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false, getHasDiscriminatorWithNonEmptyMapping=false}]

+}', 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, isFreeFormObject=false, isArray=false, isMap=false, isEnum=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, _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, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false, getHasDiscriminatorWithNonEmptyMapping=false, composedSchemas=null}]

* *

Produces: [{mediaType=application/xml}, {mediaType=application/json}]

*

Returns: {@link String}