Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
@Getter @Setter
public String arrayModelType;
public boolean isAlias; // Is this effectively an alias of another simple type
public boolean isVariant; // Does this represent a schema variant?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please add a comment showing an example of a schema variant to put everyone on the same page?

public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble, isDate, isDateTime,
isDecimal, isShort, isUnboundedInteger, isPrimitiveType, isBoolean, isFreeFormObject;
private boolean additionalPropertiesIsAnyType;
Expand Down Expand Up @@ -866,6 +867,7 @@ public boolean equals(Object o) {
if (!(o instanceof CodegenModel)) return false;
CodegenModel that = (CodegenModel) o;
return isAlias == that.isAlias &&
isVariant == that.isVariant &&
isString == that.isString &&
isInteger == that.isInteger &&
isShort == that.isShort &&
Expand Down Expand Up @@ -978,7 +980,7 @@ public int hashCode() {
getInterfaceModels(), getChildren(), anyOf, oneOf, allOf, getName(), getSchemaName(), getClassname(), getTitle(),
getDescription(), getClassVarName(), getModelJson(), getDataType(), getXmlPrefix(), getXmlNamespace(),
getXmlName(), getClassFilename(), getUnescapedDescription(), getDiscriminator(), getDefaultValue(),
getArrayModelType(), isAlias, isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble,
getArrayModelType(), isAlias, isVariant, isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble,
isDate, isDateTime, isNull, hasValidation, isShort, isUnboundedInteger, isBoolean,
getVars(), getAllVars(), getNonNullableVars(), getRequiredVars(), getOptionalVars(), getReadOnlyVars(), getReadWriteVars(),
getParentVars(), getAllowableValues(), getMandatory(), getAllMandatory(), getImports(), hasVars,
Expand Down Expand Up @@ -1023,6 +1025,7 @@ public String toString() {
sb.append(", defaultValue='").append(defaultValue).append('\'');
sb.append(", arrayModelType='").append(arrayModelType).append('\'');
sb.append(", isAlias=").append(isAlias);
sb.append(", isVariant=").append(isVariant);
sb.append(", isString=").append(isString);
sb.append(", isInteger=").append(isInteger);
sb.append(", isShort=").append(isShort);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
* See <a href="https://web.archive.org/web/20240502205731/https://json-schema.org/draft/2020-12/json-schema-validation#name-multipleof">JSON Schema Validation Spec, Section 6.2.1</a>
*/
public Number multipleOf;
/**
* If this is a body parameter, we might have several different variants
* depending on which content type is used.
*/
public List<CodegenParameter> schemaVariants;
/**
* If this is a schema variant, this gives the schema variant type
*/
public String variantType;
private Integer maxProperties;
private Integer minProperties;
public boolean isNull;
Expand Down Expand Up @@ -241,6 +250,9 @@ public CodegenParameter copy() {
if (this.ref != null) {
output.setRef(this.ref);
}
if (this.schemaVariants != null) {
output.schemaVariants = new ArrayList(this.schemaVariants);
}
output.hasValidation = this.hasValidation;
output.isNullable = this.isNullable;
output.isDeprecated = this.isDeprecated;
Expand Down Expand Up @@ -274,6 +286,7 @@ public CodegenParameter copy() {
output.isMatrix = this.isMatrix;
output.isAllowEmptyValue = this.isAllowEmptyValue;
output.contentType = this.contentType;
output.variantType = this.variantType;

return output;
}
Expand All @@ -295,7 +308,8 @@ public int hashCode() {
additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger,
hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes, schema, content,
requiredVarsMap, ref, uniqueItemsBoolean, schemaIsFromAdditionalProperties,
nameInPascalCase, nameInCamelCase, nameInLowerCase, nameInSnakeCase);
nameInPascalCase, nameInCamelCase, nameInLowerCase, nameInSnakeCase,
schemaVariants, variantType);
}

@Override
Expand Down Expand Up @@ -401,7 +415,9 @@ public boolean equals(Object o) {
Objects.equals(getMaxItems(), that.getMaxItems()) &&
Objects.equals(getMinItems(), that.getMinItems()) &&
Objects.equals(contentType, that.contentType) &&
Objects.equals(multipleOf, that.multipleOf);
Objects.equals(multipleOf, that.multipleOf) &&
Objects.equals(schemaVariants, that.schemaVariants) &&
Objects.equals(variantType, that.variantType);
}

/**
Expand Down Expand Up @@ -515,6 +531,8 @@ public String toString() {
sb.append(", requiredVarsMap=").append(requiredVarsMap);
sb.append(", ref=").append(ref);
sb.append(", schemaIsFromAdditionalProperties=").append(schemaIsFromAdditionalProperties);
sb.append(", schemaVariants=").append(schemaVariants);
sb.append(", variantType=").append(variantType);
sb.append('}');
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,25 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
public CodegenProperty returnProperty;
private boolean schemaIsFromAdditionalProperties;

/**
* mime-type of this response.
*
* Null if there are multiple options, in which case schemaVariants
* will contain a CodegenResponse for each option
*/
public String contentType;

/**
* If the response has multiple possible mime types, this array represents
* the options
*/
public List<CodegenResponse> schemaVariants;

/**
* Name of the variant type if this is one of multiple variants
*/
public String variantType;

@Override
public int hashCode() {
return Objects.hash(headers, code, message, examples, dataType, baseType, containerType, containerTypeMapped, hasHeaders,
Expand All @@ -116,7 +135,8 @@ public int hashCode() {
getMinLength(), exclusiveMinimum, exclusiveMaximum, getMinimum(), getMaximum(), getPattern(),
is1xx, is2xx, is3xx, is4xx, is5xx, additionalPropertiesIsAnyType, hasVars, hasRequired,
hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes, responseHeaders, content,
requiredVarsMap, ref, uniqueItemsBoolean, schemaIsFromAdditionalProperties);
requiredVarsMap, ref, uniqueItemsBoolean, schemaIsFromAdditionalProperties,
contentType, schemaVariants, variantType);
}

@Override
Expand Down Expand Up @@ -200,7 +220,10 @@ public boolean equals(Object o) {
Objects.equals(getMinimum(), that.getMinimum()) &&
Objects.equals(getMaximum(), that.getMaximum()) &&
Objects.equals(getPattern(), that.getPattern()) &&
Objects.equals(getMultipleOf(), that.getMultipleOf());
Objects.equals(getMultipleOf(), that.getMultipleOf()) &&
Objects.equals(schemaVariants, that.schemaVariants) &&
Objects.equals(contentType, that.contentType) &&
Objects.equals(variantType, that.variantType);

}

Expand Down Expand Up @@ -635,6 +658,9 @@ public String toString() {
sb.append(", requiredVarsMap=").append(requiredVarsMap);
sb.append(", ref=").append(ref);
sb.append(", schemaIsFromAdditionalProperties=").append(schemaIsFromAdditionalProperties);
sb.append(", contentType='").append(contentType).append('\'');
sb.append(", variantType='").append(variantType).append('\'');
sb.append(", schemaVariants=").append(schemaVariants);
sb.append('}');
return sb.toString();
}
Expand Down
Loading