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

Commit ad031a2

Browse files
committed
Java methods updated
1 parent 8857665 commit ad031a2

2 files changed

Lines changed: 11 additions & 18 deletions

File tree

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,7 +2934,7 @@ public CodegenModel fromModel(String name, Schema schema) {
29342934
m.setFormat(schema.getFormat());
29352935
m.setComposedSchemas(getComposedSchemas(schema));
29362936
if (ModelUtils.isArraySchema(schema)) {
2937-
String itemName = getItemsNameForModel(name);
2937+
String itemName = getItemsName(null, name);
29382938
CodegenProperty arrayProperty = fromProperty(itemName, schema, false);
29392939
m.setItems(arrayProperty.items);
29402940
m.arrayModelType = arrayProperty.complexType;
@@ -3851,7 +3851,7 @@ public CodegenProperty fromProperty(String name, Schema p, boolean required, boo
38513851
}
38523852

38533853
// handle inner property
3854-
String itemName = getItemsNameForProp(p, name);
3854+
String itemName = getItemsName(p, name);
38553855
ArraySchema arraySchema = (ArraySchema) p;
38563856
Schema innerSchema = unaliasSchema(getSchemaItems(arraySchema));
38573857
CodegenProperty cp = fromProperty(itemName, innerSchema, false);
@@ -7909,22 +7909,19 @@ public List<VendorExtension> getSupportedVendorExtensions() {
79097909
*/
79107910
protected String handleSpecialCharacters(String name) { return name; }
79117911

7912-
public String getItemsNameForProp(Schema containingSchema, String containingSchemaName) {
7912+
public String getItemsName(Schema containingSchema, String containingSchemaName) {
79137913
String itemName = null;
7914-
if (containingSchema.getExtensions() != null && containingSchema.getExtensions().get("x-item-name") != null) {
7915-
itemName = containingSchema.getExtensions().get("x-item-name").toString();
7916-
}
7917-
if (itemName == null) {
7918-
itemName = toVarName(containingSchemaName);
7914+
if (containingSchema != null) {
7915+
// fromProperty use case
7916+
if (containingSchema.getExtensions() != null && containingSchema.getExtensions().get("x-item-name") != null) {
7917+
return containingSchema.getExtensions().get("x-item-name").toString();
7918+
}
7919+
return toVarName(containingSchemaName);
79197920
}
7920-
return itemName;
7921-
}
7922-
7923-
public String getItemsNameForModel(String containingSchemaName) {
7921+
// fromModel use case
79247922
return containingSchemaName;
79257923
}
79267924

7927-
79287925
public String getAdditionalPropertiesName() {
79297926
return "additional_properties";
79307927
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,11 +1079,7 @@ public boolean isDataTypeString(String dataType) {
10791079
return "str".equals(dataType);
10801080
}
10811081

1082-
public String getItemsNameForProp(Schema containingSchema, String containingSchemaName) {
1083-
return "items";
1084-
}
1085-
1086-
public String getItemsNameForModel(String containingSchemaName) {
1082+
public String getItemsName(Schema containingSchema, String containingSchemaName) {
10871083
return "items";
10881084
}
10891085

0 commit comments

Comments
 (0)