Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

[unused] changes complexType to refClass #52

Merged
merged 1 commit into from
Oct 24, 2022
Merged
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
4 changes: 2 additions & 2 deletions docs/new-generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
{{#parent}}
{{#parentVars}}
**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{refClass}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
{{/parentVars}}
{{/parent}}
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{refClass}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
{{/vars}}

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/templating.md
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ Supporting files can either be processed through the templating engine or copied

> This is a very limited list of variable name explanations. Feel free to [open a pull request](https://github.com/OpenAPITools/openapi-generator/pull/new/master) to add to this documentation!

- **complexType**: stores the name of the model (e.g. Pet)
- **refClass**: stores the name of the model (e.g. Pet)
- **isContainer**: true if the parameter or property is an array or a map.
- **isPrimitiveType**: true if the parameter or property type is a primitive type (e.g. string, integer, etc) as defined in the spec.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
*/
public String openApiType;
public String baseName;
public String complexType;
public String refClass;
public String getter;
public String setter;
/**
Expand Down Expand Up @@ -258,12 +258,12 @@ public void setBaseName(String baseName) {
this.baseName = baseName;
}

public String getComplexType() {
return complexType;
public String getRefClass() {
return refClass;
}

public void setComplexType(String complexType) {
this.complexType = complexType;
public void setRefClass(String refClass) {
this.refClass = refClass;
}

public String getGetter() {
Expand Down Expand Up @@ -978,7 +978,7 @@ public String toString() {
final StringBuilder sb = new StringBuilder("CodegenProperty{");
sb.append("openApiType='").append(openApiType).append('\'');
sb.append(", baseName='").append(baseName).append('\'');
sb.append(", complexType='").append(complexType).append('\'');
sb.append(", refClass='").append(refClass).append('\'');
sb.append(", getter='").append(getter).append('\'');
sb.append(", setter='").append(setter).append('\'');
sb.append(", description='").append(description).append('\'');
Expand Down Expand Up @@ -1151,7 +1151,7 @@ public boolean equals(Object o) {
Objects.equals(composedSchemas, that.composedSchemas) &&
Objects.equals(openApiType, that.openApiType) &&
Objects.equals(baseName, that.baseName) &&
Objects.equals(complexType, that.complexType) &&
Objects.equals(refClass, that.refClass) &&
Objects.equals(getter, that.getter) &&
Objects.equals(setter, that.setter) &&
Objects.equals(description, that.description) &&
Expand Down Expand Up @@ -1197,7 +1197,7 @@ public boolean equals(Object o) {
@Override
public int hashCode() {

return Objects.hash(openApiType, baseName, complexType, getter, setter, description,
return Objects.hash(openApiType, baseName, refClass, getter, setter, description,
dataType, datatypeWithEnum, dataFormat, name, min, max, defaultValue,
defaultValueWithParam, baseType, containerType, title, unescapedDescription,
maxLength, minLength, pattern, example, jsonSchema, minimum, maximum,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2579,7 +2579,7 @@ protected void updateModelForComposedSchema(CodegenModel m, Schema schema, Map<S
CodegenProperty interfaceProperty = fromProperty(languageType, interfaceSchema, false);
if (ModelUtils.isArraySchema(interfaceSchema) || ModelUtils.isMapSchema(interfaceSchema)) {
while (interfaceProperty != null) {
addImport(m, interfaceProperty.complexType);
addImport(m, interfaceProperty.refClass);
interfaceProperty = interfaceProperty.items;
}
}
Expand Down Expand Up @@ -2921,7 +2921,7 @@ public CodegenModel fromModel(String name, Schema schema) {
if (ModelUtils.isArraySchema(schema)) {
CodegenProperty arrayProperty = fromProperty("items", schema, false);
m.setItems(arrayProperty.items);
m.arrayModelType = arrayProperty.complexType;
m.arrayModelType = arrayProperty.refClass;
addParentContainer(m, name, schema);
} else if (ModelUtils.isIntegerSchema(schema)) { // integer type
updateModelForInteger(m, schema);
Expand Down Expand Up @@ -3884,7 +3884,7 @@ protected void updatePropertyForArray(CodegenProperty property, CodegenProperty
}
property.dataFormat = innerProperty.dataFormat;
if (!languageSpecificPrimitives.contains(innerProperty.baseType)) {
property.complexType = innerProperty.baseType;
property.refClass = innerProperty.baseType;
} else {
property.isPrimitiveType = true;
}
Expand Down Expand Up @@ -3919,7 +3919,7 @@ protected void updatePropertyForMap(CodegenProperty property, CodegenProperty in
return;
}
if (!languageSpecificPrimitives.contains(innerProperty.baseType)) {
property.complexType = innerProperty.baseType;
property.refClass = innerProperty.baseType;
} else {
property.isPrimitiveType = true;
}
Expand Down Expand Up @@ -4031,7 +4031,7 @@ protected void setNonArrayMapProperty(CodegenProperty property, String type) {
if (languageSpecificPrimitives().contains(type)) {
property.isPrimitiveType = true;
} else {
property.complexType = property.baseType;
property.refClass = property.baseType;
property.isModel = true;
}
}
Expand Down Expand Up @@ -4099,8 +4099,8 @@ protected void handleMethodResponse(Operation operation,
CodegenProperty innerProperty = fromProperty("response", getAdditionalProperties(responseSchema), false);
op.returnBaseType = innerProperty.baseType;
} else {
if (cm.complexType != null) {
op.returnBaseType = cm.complexType;
if (cm.refClass != null) {
op.returnBaseType = cm.refClass;
} else {
op.returnBaseType = cm.baseType;
}
Expand Down Expand Up @@ -4536,11 +4536,11 @@ public CodegenResponse fromResponse(String responseCode, ApiResponse response) {
r.dataType = getTypeDeclaration(responseSchema);

if (!ModelUtils.isArraySchema(responseSchema)) {
if (cp.complexType != null) {
if (cp.refClass != null) {
if (cp.items != null) {
r.baseType = cp.items.complexType;
r.baseType = cp.items.refClass;
} else {
r.baseType = cp.complexType;
r.baseType = cp.refClass;
}
r.isModel = true;
} else {
Expand Down Expand Up @@ -4953,7 +4953,7 @@ public CodegenParameter fromParameter(Parameter parameter, Set<String> imports,
if (parameterModelName != null) {
codegenParameter.dataType = parameterModelName;
if (ModelUtils.isObjectSchema(parameterSchema)) {
codegenProperty.complexType = codegenParameter.dataType;
codegenProperty.refClass = codegenParameter.dataType;
}
} else {
codegenParameter.dataType = codegenProperty.dataType;
Expand Down Expand Up @@ -4996,8 +4996,8 @@ public CodegenParameter fromParameter(Parameter parameter, Set<String> imports,
codegenParameter.paramName = toParamName(priorJsonPathFragment);
if (!addSchemaImportsFromV3SpecLocations) {
// import
if (codegenProperty.complexType != null) {
imports.add(codegenProperty.complexType);
if (codegenProperty.refClass != null) {
imports.add(codegenProperty.refClass);
}
}
codegenParameter.pattern = toRegularExpression(parameterSchema.getPattern());
Expand Down Expand Up @@ -5367,7 +5367,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
*/
protected void addParentContainer(CodegenModel model, String name, Schema schema) {
final CodegenProperty property = fromProperty(name, schema, false);
addImport(model, property.complexType);
addImport(model, property.refClass);
model.parent = toInstantiationType(schema);
if (!addSchemaImportsFromV3SpecLocations) {
final String containerType = property.containerType;
Expand Down Expand Up @@ -6757,8 +6757,8 @@ public CodegenParameter fromFormProperty(String name, Schema propertySchema, Set

if (!addSchemaImportsFromV3SpecLocations) {
// import
if (codegenProperty.complexType != null) {
imports.add(codegenProperty.complexType);
if (codegenProperty.refClass != null) {
imports.add(codegenProperty.refClass);
}
}
setParameterExampleValue(codegenParameter);
Expand Down Expand Up @@ -6795,13 +6795,13 @@ protected void addBodyModelSchema(CodegenParameter codegenParameter, String name
} else {
CodegenProperty codegenProperty = fromProperty("property", schema, false);

if (codegenProperty != null && codegenProperty.getComplexType() != null && codegenProperty.getComplexType().contains(" | ")) {
if (codegenProperty != null && codegenProperty.getRefClass() != null && codegenProperty.getRefClass().contains(" | ")) {
if (!addSchemaImportsFromV3SpecLocations) {
// TODO move this splitting logic to the generator that needs it only
List<String> parts = Arrays.asList(codegenProperty.getComplexType().split(" \\| "));
List<String> parts = Arrays.asList(codegenProperty.getRefClass().split(" \\| "));
imports.addAll(parts);
}
String codegenModelName = codegenProperty.getComplexType();
String codegenModelName = codegenProperty.getRefClass();
codegenParameter.baseName = codegenModelName;
codegenParameter.paramName = toParamName(codegenParameter.baseName);
codegenParameter.baseType = codegenParameter.baseName;
Expand Down Expand Up @@ -6841,8 +6841,8 @@ protected void addBodyModelSchema(CodegenParameter codegenParameter, String name
if (!addSchemaImportsFromV3SpecLocations) {
imports.add(codegenParameter.baseType);

if (codegenProperty.complexType != null) {
imports.add(codegenProperty.complexType);
if (codegenProperty.refClass != null) {
imports.add(codegenProperty.refClass);
}
}
}
Expand All @@ -6869,8 +6869,8 @@ protected void updateRequestBodyForMap(CodegenParameter codegenParameter, Schema
imports.add(codegenProperty.baseType);
CodegenProperty innerCp = codegenProperty;
while (innerCp != null) {
if (innerCp.complexType != null) {
imports.add(innerCp.complexType);
if (innerCp.refClass != null) {
imports.add(innerCp.refClass);
}
innerCp = innerCp.items;
}
Expand Down Expand Up @@ -6912,8 +6912,8 @@ protected void updateRequestBodyForPrimitiveType(CodegenParameter codegenParamet
codegenParameter.isNullable = codegenProperty.isNullable;

if (!addSchemaImportsFromV3SpecLocations) {
if (codegenProperty.complexType != null) {
imports.add(codegenProperty.complexType);
if (codegenProperty.refClass != null) {
imports.add(codegenProperty.refClass);
}
}
}
Expand Down Expand Up @@ -6974,8 +6974,8 @@ protected void updateRequestBodyForArray(CodegenParameter codegenParameter, Sche
// also find the most inner item
while (innerCp != null) {
if (!addSchemaImportsFromV3SpecLocations) {
if (innerCp.complexType != null) {
imports.add(innerCp.complexType);
if (innerCp.refClass != null) {
imports.add(innerCp.refClass);
}
}
mostInnerItem = innerCp;
Expand All @@ -6987,10 +6987,10 @@ protected void updateRequestBodyForArray(CodegenParameter codegenParameter, Sche
}

if (StringUtils.isEmpty(bodyParameterName)) {
if (StringUtils.isEmpty(mostInnerItem.complexType)) {
if (StringUtils.isEmpty(mostInnerItem.refClass)) {
codegenParameter.baseName = "request_body";
} else {
codegenParameter.baseName = mostInnerItem.complexType;
codegenParameter.baseName = mostInnerItem.refClass;
}
} else {
codegenParameter.baseName = bodyParameterName;
Expand Down Expand Up @@ -7235,7 +7235,7 @@ protected void addRequiredVarsMap(Schema schema, IJsonSchemaValidationProperties
/*
this should be called after vars and additionalProperties are set
Features added by storing codegenProperty values:
- complexType stores reference to additionalProperties definition
- refClass stores reference to additionalProperties definition
- baseName stores original name (can be invalid in a programming language)
- nameInSnakeCase can store valid name for a programming language
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ default String getBaseType() {
/**
* @return complex type that can contain type parameters - like {@code List<Items>} for Java
*/
default String getComplexType() {
default String getRefClass() {
return getBaseType();
};

Expand Down Expand Up @@ -344,13 +344,13 @@ default Set<String> getImports(boolean importContainerType, boolean importBaseTy
if (this.getIsArray() || this.getIsMap()) {
if (importContainerType) {
/*
use-case for this complexType block:
use-case for this refClass block:
DefaultCodegenTest.objectQueryParamIdentifyAsObject
DefaultCodegenTest.mapParamImportInnerObject
*/
String complexType = this.getComplexType();
if (complexType != null) {
imports.add(complexType);
String refClass = this.getRefClass();
if (refClass != null) {
imports.add(refClass);
}
/*
use-case:
Expand All @@ -363,9 +363,9 @@ default Set<String> getImports(boolean importContainerType, boolean importBaseTy
}
} else {
// referenced or inline schemas
String complexType = this.getComplexType();
if (complexType != null) {
imports.add(complexType);
String refClass = this.getRefClass();
if (refClass != null) {
imports.add(refClass);
}
String baseType = this.getBaseType();
if (importBaseType && baseType != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ public CodegenProperty fromProperty(String name, Schema p, boolean required, boo
if (cp.isAnyType && cp.isNullable) {
cp.isNullable = false;
}
if (cp.isNullable && cp.complexType == null) {
if (cp.isNullable && cp.refClass == null) {
cp.setIsNull(true);
cp.isNullable = false;
cp.setHasMultipleTypes(true);
Expand All @@ -1054,7 +1054,7 @@ public CodegenProperty fromProperty(String name, Schema p, boolean required, boo
}
Schema unaliasedSchema = unaliasSchema(p);
if (cp.isPrimitiveType && unaliasedSchema.get$ref() != null) {
cp.complexType = cp.dataType;
cp.refClass = cp.dataType;
}
return cp;
}
Expand Down Expand Up @@ -1133,10 +1133,10 @@ public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, S
Schema unaliasedSchema = unaliasSchema(schema);
CodegenProperty unaliasedProp = fromProperty("body", unaliasedSchema, false);
Boolean dataTypeMismatch = !cp.dataType.equals(unaliasedProp.dataType);
Boolean baseTypeMismatch = !cp.baseType.equals(unaliasedProp.complexType) && unaliasedProp.complexType != null;
Boolean baseTypeMismatch = !cp.baseType.equals(unaliasedProp.refClass) && unaliasedProp.refClass != null;
if (dataTypeMismatch || baseTypeMismatch) {
cp.dataType = unaliasedProp.dataType;
cp.baseType = unaliasedProp.complexType;
cp.baseType = unaliasedProp.refClass;
}
return cp;
}
Expand Down Expand Up @@ -2440,22 +2440,22 @@ protected void updateModelForComposedSchema(CodegenModel m, Schema schema, Map<S
if (cs != null) {
if (cs.getAllOf() != null && !cs.getAllOf().isEmpty()) {
for (CodegenProperty cp: cs.getAllOf()) {
if (cp.complexType != null) {
addImport(m, cp.complexType);
if (cp.refClass != null) {
addImport(m, cp.refClass);
}
}
}
if (cs.getOneOf() != null && !cs.getOneOf().isEmpty()) {
for (CodegenProperty cp: cs.getOneOf()) {
if (cp.complexType != null) {
addImport(m, cp.complexType);
if (cp.refClass != null) {
addImport(m, cp.refClass);
}
}
}
if (cs.getAnyOf() != null && !cs.getAnyOf().isEmpty()) {
for (CodegenProperty cp: cs.getAnyOf()) {
if (cp.complexType != null) {
addImport(m, cp.complexType);
if (cp.refClass != null) {
addImport(m, cp.refClass);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{name}} = ({{{datatypeWithEnum}}})in.readValue(null);
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{name}} = ({{{datatypeWithEnum}}})in.readValue({{complexType}}.class.getClassLoader());
{{name}} = ({{{datatypeWithEnum}}})in.readValue({{refClass}}.class.getClassLoader());
{{/isPrimitiveType}}
{{/vars}}
{{/isArray}}
Expand Down
Loading