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

Commit 7ef1f98

Browse files
committed
CHanges complexType to refClass (#62)
1 parent 85d830c commit 7ef1f98

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);
@@ -3886,7 +3886,7 @@ protected void updatePropertyForArray(CodegenProperty property, CodegenProperty
38863886
}
38873887
property.dataFormat = innerProperty.dataFormat;
38883888
if (!languageSpecificPrimitives.contains(innerProperty.baseType)) {
3889-
property.complexType = innerProperty.baseType;
3889+
property.refClass = innerProperty.baseType;
38903890
} else {
38913891
property.isPrimitiveType = true;
38923892
}
@@ -3921,7 +3921,7 @@ protected void updatePropertyForMap(CodegenProperty property, CodegenProperty in
39213921
return;
39223922
}
39233923
if (!languageSpecificPrimitives.contains(innerProperty.baseType)) {
3924-
property.complexType = innerProperty.baseType;
3924+
property.refClass = innerProperty.baseType;
39253925
} else {
39263926
property.isPrimitiveType = true;
39273927
}
@@ -4033,7 +4033,7 @@ protected void setNonArrayMapProperty(CodegenProperty property, String type) {
40334033
if (languageSpecificPrimitives().contains(type)) {
40344034
property.isPrimitiveType = true;
40354035
} else {
4036-
property.complexType = property.baseType;
4036+
property.refClass = property.baseType;
40374037
property.isModel = true;
40384038
}
40394039
}
@@ -4101,8 +4101,8 @@ protected void handleMethodResponse(Operation operation,
41014101
CodegenProperty innerProperty = fromProperty("response", getAdditionalProperties(responseSchema), false);
41024102
op.returnBaseType = innerProperty.baseType;
41034103
} else {
4104-
if (cm.complexType != null) {
4105-
op.returnBaseType = cm.complexType;
4104+
if (cm.refClass != null) {
4105+
op.returnBaseType = cm.refClass;
41064106
} else {
41074107
op.returnBaseType = cm.baseType;
41084108
}
@@ -4538,11 +4538,11 @@ public CodegenResponse fromResponse(String responseCode, ApiResponse response) {
45384538
r.dataType = getTypeDeclaration(responseSchema);
45394539

45404540
if (!ModelUtils.isArraySchema(responseSchema)) {
4541-
if (cp.complexType != null) {
4541+
if (cp.refClass != null) {
45424542
if (cp.items != null) {
4543-
r.baseType = cp.items.complexType;
4543+
r.baseType = cp.items.refClass;
45444544
} else {
4545-
r.baseType = cp.complexType;
4545+
r.baseType = cp.refClass;
45464546
}
45474547
r.isModel = true;
45484548
} else {
@@ -4955,7 +4955,7 @@ public CodegenParameter fromParameter(Parameter parameter, Set<String> imports,
49554955
if (parameterModelName != null) {
49564956
codegenParameter.dataType = parameterModelName;
49574957
if (ModelUtils.isObjectSchema(parameterSchema)) {
4958-
codegenProperty.complexType = codegenParameter.dataType;
4958+
codegenProperty.refClass = codegenParameter.dataType;
49594959
}
49604960
} else {
49614961
codegenParameter.dataType = codegenProperty.dataType;
@@ -4998,8 +4998,8 @@ public CodegenParameter fromParameter(Parameter parameter, Set<String> imports,
49984998
codegenParameter.paramName = toParamName(priorJsonPathFragment);
49994999
if (!addSchemaImportsFromV3SpecLocations) {
50005000
// import
5001-
if (codegenProperty.complexType != null) {
5002-
imports.add(codegenProperty.complexType);
5001+
if (codegenProperty.refClass != null) {
5002+
imports.add(codegenProperty.refClass);
50035003
}
50045004
}
50055005
codegenParameter.pattern = toRegularExpression(parameterSchema.getPattern());
@@ -5369,7 +5369,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
53695369
*/
53705370
protected void addParentContainer(CodegenModel model, String name, Schema schema) {
53715371
final CodegenProperty property = fromProperty(name, schema, false);
5372-
addImport(model, property.complexType);
5372+
addImport(model, property.refClass);
53735373
model.parent = toInstantiationType(schema);
53745374
if (!addSchemaImportsFromV3SpecLocations) {
53755375
final String containerType = property.containerType;
@@ -6759,8 +6759,8 @@ public CodegenParameter fromFormProperty(String name, Schema propertySchema, Set
67596759

67606760
if (!addSchemaImportsFromV3SpecLocations) {
67616761
// import
6762-
if (codegenProperty.complexType != null) {
6763-
imports.add(codegenProperty.complexType);
6762+
if (codegenProperty.refClass != null) {
6763+
imports.add(codegenProperty.refClass);
67646764
}
67656765
}
67666766
setParameterExampleValue(codegenParameter);
@@ -6797,13 +6797,13 @@ protected void addBodyModelSchema(CodegenParameter codegenParameter, String name
67976797
} else {
67986798
CodegenProperty codegenProperty = fromProperty("property", schema, false);
67996799

6800-
if (codegenProperty != null && codegenProperty.getComplexType() != null && codegenProperty.getComplexType().contains(" | ")) {
6800+
if (codegenProperty != null && codegenProperty.getRefClass() != null && codegenProperty.getRefClass().contains(" | ")) {
68016801
if (!addSchemaImportsFromV3SpecLocations) {
68026802
// TODO move this splitting logic to the generator that needs it only
6803-
List<String> parts = Arrays.asList(codegenProperty.getComplexType().split(" \\| "));
6803+
List<String> parts = Arrays.asList(codegenProperty.getRefClass().split(" \\| "));
68046804
imports.addAll(parts);
68056805
}
6806-
String codegenModelName = codegenProperty.getComplexType();
6806+
String codegenModelName = codegenProperty.getRefClass();
68076807
codegenParameter.baseName = codegenModelName;
68086808
codegenParameter.paramName = toParamName(codegenParameter.baseName);
68096809
codegenParameter.baseType = codegenParameter.baseName;
@@ -6843,8 +6843,8 @@ protected void addBodyModelSchema(CodegenParameter codegenParameter, String name
68436843
if (!addSchemaImportsFromV3SpecLocations) {
68446844
imports.add(codegenParameter.baseType);
68456845

6846-
if (codegenProperty.complexType != null) {
6847-
imports.add(codegenProperty.complexType);
6846+
if (codegenProperty.refClass != null) {
6847+
imports.add(codegenProperty.refClass);
68486848
}
68496849
}
68506850
}
@@ -6871,8 +6871,8 @@ protected void updateRequestBodyForMap(CodegenParameter codegenParameter, Schema
68716871
imports.add(codegenProperty.baseType);
68726872
CodegenProperty innerCp = codegenProperty;
68736873
while (innerCp != null) {
6874-
if (innerCp.complexType != null) {
6875-
imports.add(innerCp.complexType);
6874+
if (innerCp.refClass != null) {
6875+
imports.add(innerCp.refClass);
68766876
}
68776877
innerCp = innerCp.items;
68786878
}
@@ -6914,8 +6914,8 @@ protected void updateRequestBodyForPrimitiveType(CodegenParameter codegenParamet
69146914
codegenParameter.isNullable = codegenProperty.isNullable;
69156915

69166916
if (!addSchemaImportsFromV3SpecLocations) {
6917-
if (codegenProperty.complexType != null) {
6918-
imports.add(codegenProperty.complexType);
6917+
if (codegenProperty.refClass != null) {
6918+
imports.add(codegenProperty.refClass);
69196919
}
69206920
}
69216921
}
@@ -6976,8 +6976,8 @@ protected void updateRequestBodyForArray(CodegenParameter codegenParameter, Sche
69766976
// also find the most inner item
69776977
while (innerCp != null) {
69786978
if (!addSchemaImportsFromV3SpecLocations) {
6979-
if (innerCp.complexType != null) {
6980-
imports.add(innerCp.complexType);
6979+
if (innerCp.refClass != null) {
6980+
imports.add(innerCp.refClass);
69816981
}
69826982
}
69836983
mostInnerItem = innerCp;
@@ -6989,10 +6989,10 @@ protected void updateRequestBodyForArray(CodegenParameter codegenParameter, Sche
69896989
}
69906990

69916991
if (StringUtils.isEmpty(bodyParameterName)) {
6992-
if (StringUtils.isEmpty(mostInnerItem.complexType)) {
6992+
if (StringUtils.isEmpty(mostInnerItem.refClass)) {
69936993
codegenParameter.baseName = "request_body";
69946994
} else {
6995-
codegenParameter.baseName = mostInnerItem.complexType;
6995+
codegenParameter.baseName = mostInnerItem.refClass;
69966996
}
69976997
} else {
69986998
codegenParameter.baseName = bodyParameterName;
@@ -7237,7 +7237,7 @@ protected void addRequiredVarsMap(Schema schema, IJsonSchemaValidationProperties
72377237
/*
72387238
this should be called after vars and additionalProperties are set
72397239
Features added by storing codegenProperty values:
7240-
- complexType stores reference to additionalProperties definition
7240+
- refClass stores reference to additionalProperties definition
72417241
- baseName stores original name (can be invalid in a programming language)
72427242
- nameInSnakeCase can store valid name for a programming language
72437243
*/

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
@@ -1032,7 +1032,7 @@ public CodegenProperty fromProperty(String name, Schema p, boolean required, boo
10321032
if (cp.isAnyType && cp.isNullable) {
10331033
cp.isNullable = false;
10341034
}
1035-
if (cp.isNullable && cp.complexType == null) {
1035+
if (cp.isNullable && cp.refClass == null) {
10361036
cp.setIsNull(true);
10371037
cp.isNullable = false;
10381038
cp.setHasMultipleTypes(true);
@@ -1056,7 +1056,7 @@ public CodegenProperty fromProperty(String name, Schema p, boolean required, boo
10561056
}
10571057
Schema unaliasedSchema = unaliasSchema(p);
10581058
if (cp.isPrimitiveType && unaliasedSchema.get$ref() != null) {
1059-
cp.complexType = cp.dataType;
1059+
cp.refClass = cp.dataType;
10601060
}
10611061
return cp;
10621062
}
@@ -1139,10 +1139,10 @@ public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, S
11391139
Schema unaliasedSchema = unaliasSchema(schema);
11401140
CodegenProperty unaliasedProp = fromProperty("body", unaliasedSchema, false);
11411141
Boolean dataTypeMismatch = !cp.dataType.equals(unaliasedProp.dataType);
1142-
Boolean baseTypeMismatch = !cp.baseType.equals(unaliasedProp.complexType) && unaliasedProp.complexType != null;
1142+
Boolean baseTypeMismatch = !cp.baseType.equals(unaliasedProp.refClass) && unaliasedProp.refClass != null;
11431143
if (dataTypeMismatch || baseTypeMismatch) {
11441144
cp.dataType = unaliasedProp.dataType;
1145-
cp.baseType = unaliasedProp.complexType;
1145+
cp.baseType = unaliasedProp.refClass;
11461146
}
11471147
return cp;
11481148
}
@@ -2457,22 +2457,22 @@ protected void updateModelForComposedSchema(CodegenModel m, Schema schema, Map<S
24572457
if (cs != null) {
24582458
if (cs.getAllOf() != null && !cs.getAllOf().isEmpty()) {
24592459
for (CodegenProperty cp: cs.getAllOf()) {
2460-
if (cp.complexType != null) {
2461-
addImport(m, cp.complexType);
2460+
if (cp.refClass != null) {
2461+
addImport(m, cp.refClass);
24622462
}
24632463
}
24642464
}
24652465
if (cs.getOneOf() != null && !cs.getOneOf().isEmpty()) {
24662466
for (CodegenProperty cp: cs.getOneOf()) {
2467-
if (cp.complexType != null) {
2468-
addImport(m, cp.complexType);
2467+
if (cp.refClass != null) {
2468+
addImport(m, cp.refClass);
24692469
}
24702470
}
24712471
}
24722472
if (cs.getAnyOf() != null && !cs.getAnyOf().isEmpty()) {
24732473
for (CodegenProperty cp: cs.getAnyOf()) {
2474-
if (cp.complexType != null) {
2475-
addImport(m, cp.complexType);
2474+
if (cp.refClass != null) {
2475+
addImport(m, cp.refClass);
24762476
}
24772477
}
24782478
}

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)