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

Commit 65e5780

Browse files
committed
CHanges complexType to refClass (#62)
1 parent 2539419 commit 65e5780

28 files changed

+144
-145
lines changed

docs/new-generator.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,10 @@ Name | Type | Description | Notes
309309
------------ | ------------- | ------------- | -------------
310310
{{#parent}}
311311
{{#parentVars}}
312-
**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
312+
**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{refClass}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
313313
{{/parentVars}}
314314
{{/parent}}
315-
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
315+
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{refClass}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
316316
{{/vars}}
317317
318318
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

docs/templating.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ Supporting files can either be processed through the templating engine or copied
807807
808808
> 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!
809809
810-
- **complexType**: stores the name of the model (e.g. Pet)
810+
- **refClass**: stores the name of the model (e.g. Pet)
811811
- **isContainer**: true if the parameter or property is an array or a map.
812812
- **isPrimitiveType**: true if the parameter or property type is a primitive type (e.g. string, integer, etc) as defined in the spec.
813813

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
2626
*/
2727
public String openApiType;
2828
public String baseName;
29-
public String complexType;
29+
public String refClass;
3030
public String getter;
3131
public String setter;
3232
/**
@@ -258,12 +258,12 @@ public void setBaseName(String baseName) {
258258
this.baseName = baseName;
259259
}
260260

261-
public String getComplexType() {
262-
return complexType;
261+
public String getRefClass() {
262+
return refClass;
263263
}
264264

265-
public void setComplexType(String complexType) {
266-
this.complexType = complexType;
265+
public void setRefClass(String refClass) {
266+
this.refClass = refClass;
267267
}
268268

269269
public String getGetter() {
@@ -978,7 +978,7 @@ public String toString() {
978978
final StringBuilder sb = new StringBuilder("CodegenProperty{");
979979
sb.append("openApiType='").append(openApiType).append('\'');
980980
sb.append(", baseName='").append(baseName).append('\'');
981-
sb.append(", complexType='").append(complexType).append('\'');
981+
sb.append(", refClass='").append(refClass).append('\'');
982982
sb.append(", getter='").append(getter).append('\'');
983983
sb.append(", setter='").append(setter).append('\'');
984984
sb.append(", description='").append(description).append('\'');
@@ -1151,7 +1151,7 @@ public boolean equals(Object o) {
11511151
Objects.equals(composedSchemas, that.composedSchemas) &&
11521152
Objects.equals(openApiType, that.openApiType) &&
11531153
Objects.equals(baseName, that.baseName) &&
1154-
Objects.equals(complexType, that.complexType) &&
1154+
Objects.equals(refClass, that.refClass) &&
11551155
Objects.equals(getter, that.getter) &&
11561156
Objects.equals(setter, that.setter) &&
11571157
Objects.equals(description, that.description) &&
@@ -1197,7 +1197,7 @@ public boolean equals(Object o) {
11971197
@Override
11981198
public int hashCode() {
11991199

1200-
return Objects.hash(openApiType, baseName, complexType, getter, setter, description,
1200+
return Objects.hash(openApiType, baseName, refClass, getter, setter, description,
12011201
dataType, datatypeWithEnum, dataFormat, name, min, max, defaultValue,
12021202
defaultValueWithParam, baseType, containerType, title, unescapedDescription,
12031203
maxLength, minLength, pattern, example, jsonSchema, minimum, maximum,

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java

+30-30
Original file line numberDiff line numberDiff line change
@@ -2579,7 +2579,7 @@ protected void updateModelForComposedSchema(CodegenModel m, Schema schema, Map<S
25792579
CodegenProperty interfaceProperty = fromProperty(languageType, interfaceSchema, false);
25802580
if (ModelUtils.isArraySchema(interfaceSchema) || ModelUtils.isMapSchema(interfaceSchema)) {
25812581
while (interfaceProperty != null) {
2582-
addImport(m, interfaceProperty.complexType);
2582+
addImport(m, interfaceProperty.refClass);
25832583
interfaceProperty = interfaceProperty.items;
25842584
}
25852585
}
@@ -2921,7 +2921,7 @@ public CodegenModel fromModel(String name, Schema schema) {
29212921
if (ModelUtils.isArraySchema(schema)) {
29222922
CodegenProperty arrayProperty = fromProperty("items", schema, false);
29232923
m.setItems(arrayProperty.items);
2924-
m.arrayModelType = arrayProperty.complexType;
2924+
m.arrayModelType = arrayProperty.refClass;
29252925
addParentContainer(m, name, schema);
29262926
} else if (ModelUtils.isIntegerSchema(schema)) { // integer type
29272927
updateModelForInteger(m, schema);
@@ -3884,7 +3884,7 @@ protected void updatePropertyForArray(CodegenProperty property, CodegenProperty
38843884
}
38853885
property.dataFormat = innerProperty.dataFormat;
38863886
if (!languageSpecificPrimitives.contains(innerProperty.baseType)) {
3887-
property.complexType = innerProperty.baseType;
3887+
property.refClass = innerProperty.baseType;
38883888
} else {
38893889
property.isPrimitiveType = true;
38903890
}
@@ -3919,7 +3919,7 @@ protected void updatePropertyForMap(CodegenProperty property, CodegenProperty in
39193919
return;
39203920
}
39213921
if (!languageSpecificPrimitives.contains(innerProperty.baseType)) {
3922-
property.complexType = innerProperty.baseType;
3922+
property.refClass = innerProperty.baseType;
39233923
} else {
39243924
property.isPrimitiveType = true;
39253925
}
@@ -4031,7 +4031,7 @@ protected void setNonArrayMapProperty(CodegenProperty property, String type) {
40314031
if (languageSpecificPrimitives().contains(type)) {
40324032
property.isPrimitiveType = true;
40334033
} else {
4034-
property.complexType = property.baseType;
4034+
property.refClass = property.baseType;
40354035
property.isModel = true;
40364036
}
40374037
}
@@ -4099,8 +4099,8 @@ protected void handleMethodResponse(Operation operation,
40994099
CodegenProperty innerProperty = fromProperty("response", getAdditionalProperties(responseSchema), false);
41004100
op.returnBaseType = innerProperty.baseType;
41014101
} else {
4102-
if (cm.complexType != null) {
4103-
op.returnBaseType = cm.complexType;
4102+
if (cm.refClass != null) {
4103+
op.returnBaseType = cm.refClass;
41044104
} else {
41054105
op.returnBaseType = cm.baseType;
41064106
}
@@ -4536,11 +4536,11 @@ public CodegenResponse fromResponse(String responseCode, ApiResponse response) {
45364536
r.dataType = getTypeDeclaration(responseSchema);
45374537

45384538
if (!ModelUtils.isArraySchema(responseSchema)) {
4539-
if (cp.complexType != null) {
4539+
if (cp.refClass != null) {
45404540
if (cp.items != null) {
4541-
r.baseType = cp.items.complexType;
4541+
r.baseType = cp.items.refClass;
45424542
} else {
4543-
r.baseType = cp.complexType;
4543+
r.baseType = cp.refClass;
45444544
}
45454545
r.isModel = true;
45464546
} else {
@@ -4953,7 +4953,7 @@ public CodegenParameter fromParameter(Parameter parameter, Set<String> imports,
49534953
if (parameterModelName != null) {
49544954
codegenParameter.dataType = parameterModelName;
49554955
if (ModelUtils.isObjectSchema(parameterSchema)) {
4956-
codegenProperty.complexType = codegenParameter.dataType;
4956+
codegenProperty.refClass = codegenParameter.dataType;
49574957
}
49584958
} else {
49594959
codegenParameter.dataType = codegenProperty.dataType;
@@ -4996,8 +4996,8 @@ public CodegenParameter fromParameter(Parameter parameter, Set<String> imports,
49964996
codegenParameter.paramName = toParamName(priorJsonPathFragment);
49974997
if (!addSchemaImportsFromV3SpecLocations) {
49984998
// import
4999-
if (codegenProperty.complexType != null) {
5000-
imports.add(codegenProperty.complexType);
4999+
if (codegenProperty.refClass != null) {
5000+
imports.add(codegenProperty.refClass);
50015001
}
50025002
}
50035003
codegenParameter.pattern = toRegularExpression(parameterSchema.getPattern());
@@ -5367,7 +5367,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
53675367
*/
53685368
protected void addParentContainer(CodegenModel model, String name, Schema schema) {
53695369
final CodegenProperty property = fromProperty(name, schema, false);
5370-
addImport(model, property.complexType);
5370+
addImport(model, property.refClass);
53715371
model.parent = toInstantiationType(schema);
53725372
if (!addSchemaImportsFromV3SpecLocations) {
53735373
final String containerType = property.containerType;
@@ -6757,8 +6757,8 @@ public CodegenParameter fromFormProperty(String name, Schema propertySchema, Set
67576757

67586758
if (!addSchemaImportsFromV3SpecLocations) {
67596759
// import
6760-
if (codegenProperty.complexType != null) {
6761-
imports.add(codegenProperty.complexType);
6760+
if (codegenProperty.refClass != null) {
6761+
imports.add(codegenProperty.refClass);
67626762
}
67636763
}
67646764
setParameterExampleValue(codegenParameter);
@@ -6795,13 +6795,13 @@ protected void addBodyModelSchema(CodegenParameter codegenParameter, String name
67956795
} else {
67966796
CodegenProperty codegenProperty = fromProperty("property", schema, false);
67976797

6798-
if (codegenProperty != null && codegenProperty.getComplexType() != null && codegenProperty.getComplexType().contains(" | ")) {
6798+
if (codegenProperty != null && codegenProperty.getRefClass() != null && codegenProperty.getRefClass().contains(" | ")) {
67996799
if (!addSchemaImportsFromV3SpecLocations) {
68006800
// TODO move this splitting logic to the generator that needs it only
6801-
List<String> parts = Arrays.asList(codegenProperty.getComplexType().split(" \\| "));
6801+
List<String> parts = Arrays.asList(codegenProperty.getRefClass().split(" \\| "));
68026802
imports.addAll(parts);
68036803
}
6804-
String codegenModelName = codegenProperty.getComplexType();
6804+
String codegenModelName = codegenProperty.getRefClass();
68056805
codegenParameter.baseName = codegenModelName;
68066806
codegenParameter.paramName = toParamName(codegenParameter.baseName);
68076807
codegenParameter.baseType = codegenParameter.baseName;
@@ -6841,8 +6841,8 @@ protected void addBodyModelSchema(CodegenParameter codegenParameter, String name
68416841
if (!addSchemaImportsFromV3SpecLocations) {
68426842
imports.add(codegenParameter.baseType);
68436843

6844-
if (codegenProperty.complexType != null) {
6845-
imports.add(codegenProperty.complexType);
6844+
if (codegenProperty.refClass != null) {
6845+
imports.add(codegenProperty.refClass);
68466846
}
68476847
}
68486848
}
@@ -6869,8 +6869,8 @@ protected void updateRequestBodyForMap(CodegenParameter codegenParameter, Schema
68696869
imports.add(codegenProperty.baseType);
68706870
CodegenProperty innerCp = codegenProperty;
68716871
while (innerCp != null) {
6872-
if (innerCp.complexType != null) {
6873-
imports.add(innerCp.complexType);
6872+
if (innerCp.refClass != null) {
6873+
imports.add(innerCp.refClass);
68746874
}
68756875
innerCp = innerCp.items;
68766876
}
@@ -6912,8 +6912,8 @@ protected void updateRequestBodyForPrimitiveType(CodegenParameter codegenParamet
69126912
codegenParameter.isNullable = codegenProperty.isNullable;
69136913

69146914
if (!addSchemaImportsFromV3SpecLocations) {
6915-
if (codegenProperty.complexType != null) {
6916-
imports.add(codegenProperty.complexType);
6915+
if (codegenProperty.refClass != null) {
6916+
imports.add(codegenProperty.refClass);
69176917
}
69186918
}
69196919
}
@@ -6974,8 +6974,8 @@ protected void updateRequestBodyForArray(CodegenParameter codegenParameter, Sche
69746974
// also find the most inner item
69756975
while (innerCp != null) {
69766976
if (!addSchemaImportsFromV3SpecLocations) {
6977-
if (innerCp.complexType != null) {
6978-
imports.add(innerCp.complexType);
6977+
if (innerCp.refClass != null) {
6978+
imports.add(innerCp.refClass);
69796979
}
69806980
}
69816981
mostInnerItem = innerCp;
@@ -6987,10 +6987,10 @@ protected void updateRequestBodyForArray(CodegenParameter codegenParameter, Sche
69876987
}
69886988

69896989
if (StringUtils.isEmpty(bodyParameterName)) {
6990-
if (StringUtils.isEmpty(mostInnerItem.complexType)) {
6990+
if (StringUtils.isEmpty(mostInnerItem.refClass)) {
69916991
codegenParameter.baseName = "request_body";
69926992
} else {
6993-
codegenParameter.baseName = mostInnerItem.complexType;
6993+
codegenParameter.baseName = mostInnerItem.refClass;
69946994
}
69956995
} else {
69966996
codegenParameter.baseName = bodyParameterName;
@@ -7235,7 +7235,7 @@ protected void addRequiredVarsMap(Schema schema, IJsonSchemaValidationProperties
72357235
/*
72367236
this should be called after vars and additionalProperties are set
72377237
Features added by storing codegenProperty values:
7238-
- complexType stores reference to additionalProperties definition
7238+
- refClass stores reference to additionalProperties definition
72397239
- baseName stores original name (can be invalid in a programming language)
72407240
- nameInSnakeCase can store valid name for a programming language
72417241
*/

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ default String getBaseType() {
292292
/**
293293
* @return complex type that can contain type parameters - like {@code List<Items>} for Java
294294
*/
295-
default String getComplexType() {
295+
default String getRefClass() {
296296
return getBaseType();
297297
};
298298

@@ -344,13 +344,13 @@ default Set<String> getImports(boolean importContainerType, boolean importBaseTy
344344
if (this.getIsArray() || this.getIsMap()) {
345345
if (importContainerType) {
346346
/*
347-
use-case for this complexType block:
347+
use-case for this refClass block:
348348
DefaultCodegenTest.objectQueryParamIdentifyAsObject
349349
DefaultCodegenTest.mapParamImportInnerObject
350350
*/
351-
String complexType = this.getComplexType();
352-
if (complexType != null) {
353-
imports.add(complexType);
351+
String refClass = this.getRefClass();
352+
if (refClass != null) {
353+
imports.add(refClass);
354354
}
355355
/*
356356
use-case:
@@ -363,9 +363,9 @@ default Set<String> getImports(boolean importContainerType, boolean importBaseTy
363363
}
364364
} else {
365365
// referenced or inline schemas
366-
String complexType = this.getComplexType();
367-
if (complexType != null) {
368-
imports.add(complexType);
366+
String refClass = this.getRefClass();
367+
if (refClass != null) {
368+
imports.add(refClass);
369369
}
370370
String baseType = this.getBaseType();
371371
if (importBaseType && baseType != null) {

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ public CodegenProperty fromProperty(String name, Schema p, boolean required, boo
10301030
if (cp.isAnyType && cp.isNullable) {
10311031
cp.isNullable = false;
10321032
}
1033-
if (cp.isNullable && cp.complexType == null) {
1033+
if (cp.isNullable && cp.refClass == null) {
10341034
cp.setIsNull(true);
10351035
cp.isNullable = false;
10361036
cp.setHasMultipleTypes(true);
@@ -1054,7 +1054,7 @@ public CodegenProperty fromProperty(String name, Schema p, boolean required, boo
10541054
}
10551055
Schema unaliasedSchema = unaliasSchema(p);
10561056
if (cp.isPrimitiveType && unaliasedSchema.get$ref() != null) {
1057-
cp.complexType = cp.dataType;
1057+
cp.refClass = cp.dataType;
10581058
}
10591059
return cp;
10601060
}
@@ -1133,10 +1133,10 @@ public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, S
11331133
Schema unaliasedSchema = unaliasSchema(schema);
11341134
CodegenProperty unaliasedProp = fromProperty("body", unaliasedSchema, false);
11351135
Boolean dataTypeMismatch = !cp.dataType.equals(unaliasedProp.dataType);
1136-
Boolean baseTypeMismatch = !cp.baseType.equals(unaliasedProp.complexType) && unaliasedProp.complexType != null;
1136+
Boolean baseTypeMismatch = !cp.baseType.equals(unaliasedProp.refClass) && unaliasedProp.refClass != null;
11371137
if (dataTypeMismatch || baseTypeMismatch) {
11381138
cp.dataType = unaliasedProp.dataType;
1139-
cp.baseType = unaliasedProp.complexType;
1139+
cp.baseType = unaliasedProp.refClass;
11401140
}
11411141
return cp;
11421142
}
@@ -2451,22 +2451,22 @@ protected void updateModelForComposedSchema(CodegenModel m, Schema schema, Map<S
24512451
if (cs != null) {
24522452
if (cs.getAllOf() != null && !cs.getAllOf().isEmpty()) {
24532453
for (CodegenProperty cp: cs.getAllOf()) {
2454-
if (cp.complexType != null) {
2455-
addImport(m, cp.complexType);
2454+
if (cp.refClass != null) {
2455+
addImport(m, cp.refClass);
24562456
}
24572457
}
24582458
}
24592459
if (cs.getOneOf() != null && !cs.getOneOf().isEmpty()) {
24602460
for (CodegenProperty cp: cs.getOneOf()) {
2461-
if (cp.complexType != null) {
2462-
addImport(m, cp.complexType);
2461+
if (cp.refClass != null) {
2462+
addImport(m, cp.refClass);
24632463
}
24642464
}
24652465
}
24662466
if (cs.getAnyOf() != null && !cs.getAnyOf().isEmpty()) {
24672467
for (CodegenProperty cp: cs.getAnyOf()) {
2468-
if (cp.complexType != null) {
2469-
addImport(m, cp.complexType);
2468+
if (cp.refClass != null) {
2469+
addImport(m, cp.refClass);
24702470
}
24712471
}
24722472
}

modules/openapi-json-schema-generator/src/main/resources/Java/libraries/jersey2/pojo.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
371371
{{name}} = ({{{datatypeWithEnum}}})in.readValue(null);
372372
{{/isPrimitiveType}}
373373
{{^isPrimitiveType}}
374-
{{name}} = ({{{datatypeWithEnum}}})in.readValue({{complexType}}.class.getClassLoader());
374+
{{name}} = ({{{datatypeWithEnum}}})in.readValue({{refClass}}.class.getClassLoader());
375375
{{/isPrimitiveType}}
376376
{{/vars}}
377377
{{/isArray}}

0 commit comments

Comments
 (0)