Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,7 @@ public String getterAndSetterCapitalize(String name) {
*/
public CodegenProperty fromProperty(String name, Schema p) {
if (p == null) {
LOGGER.error("Unexpected missing property for name " + name);
LOGGER.error("Undefined property/schema for `{}`. Default to type:string.", name);
return null;
}
LOGGER.debug("debugging fromProperty for " + name + " : " + p);
Expand Down Expand Up @@ -2022,6 +2022,21 @@ public CodegenProperty fromProperty(String name, Schema p) {

} else if (ModelUtils.isFreeFormObject(p)) {
property.isFreeFormObject = true;
} else if (ModelUtils.isArraySchema(p)) {
// default to string if inner item is undefined
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ((ArraySchema) p).getItems());
if (innerSchema == null) {
LOGGER.error("Undefined array inner type for `{}`. Default to String.", p.getName());
innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
((ArraySchema)p).setItems(innerSchema);
}
} else if (ModelUtils.isMapSchema(p)) {
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getAdditionalProperties(p));
if (innerSchema == null) {
LOGGER.error("Undefined map inner type for `{}`. Default to String.", p.getName());
innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
p.setAdditionalProperties(innerSchema);
}
}

//Inline enum case:
Expand Down Expand Up @@ -2092,6 +2107,11 @@ public CodegenProperty fromProperty(String name, Schema p) {
itemName = property.name;
}
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ((ArraySchema) p).getItems());
if (innerSchema == null) {
LOGGER.error("Undefined array inner type for `{}`. Default to String.", p.getName());
innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
((ArraySchema)p).setItems(innerSchema);
}
CodegenProperty cp = fromProperty(itemName, innerSchema);
updatePropertyForArray(property, cp);
} else if (ModelUtils.isMapSchema(p)) {
Expand All @@ -2104,6 +2124,11 @@ public CodegenProperty fromProperty(String name, Schema p) {

// handle inner property
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getAdditionalProperties(p));
if (innerSchema == null) {
LOGGER.error("Undefined map inner type for `{}`. Default to String.", p.getName());
innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
p.setAdditionalProperties(innerSchema);
}
CodegenProperty cp = fromProperty("inner", innerSchema);
updatePropertyForMap(property, cp);
} else if (ModelUtils.isFreeFormObject(p)) {
Expand Down Expand Up @@ -4359,8 +4384,8 @@ public List<CodegenParameter> fromRequestBodyToFormParameters(RequestBody body,
final ArraySchema arraySchema = (ArraySchema) s;
Schema inner = arraySchema.getItems();
if (inner == null) {
LOGGER.warn("warning! No inner type supplied for array parameter \"" + s.getName() + "\", using String");
inner = new StringSchema().description("//TODO automatically added by openapi-generator due to missing iner type definition in the spec");
LOGGER.error("No inner type supplied for array parameter `{}`. Default to type:string", s.getName());
inner = new StringSchema().description("//TODO automatically added by openapi-generator due to missing inner type definition in the spec");
arraySchema.setItems(inner);
}

Expand All @@ -4373,7 +4398,7 @@ public List<CodegenParameter> fromRequestBodyToFormParameters(RequestBody body,
codegenParameter.isContainer = true;
codegenParameter.isListContainer = true;
codegenParameter.description = escapeText(s.getDescription());
codegenParameter.dataType = getTypeDeclaration(s);
codegenParameter.dataType = getTypeDeclaration(arraySchema);
if (codegenParameter.baseType != null && codegenParameter.enumName != null) {
codegenParameter.datatypeWithEnum = codegenParameter.dataType.replace(codegenParameter.baseType, codegenParameter.enumName);
} else {
Expand Down Expand Up @@ -4522,6 +4547,7 @@ public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, S
if (ModelUtils.isMapSchema(schema)) {
Schema inner = ModelUtils.getAdditionalProperties(schema);
if (inner == null) {
LOGGER.error("No inner type supplied for map parameter `{}`. Default to type:string", schema.getName());
inner = new StringSchema().description("//TODO automatically added by openapi-generator");
schema.setAdditionalProperties(inner);
}
Expand Down Expand Up @@ -4550,10 +4576,11 @@ public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, S
final ArraySchema arraySchema = (ArraySchema) schema;
Schema inner = arraySchema.getItems();
if (inner == null) {
inner = new StringSchema().description("//TODO automatically added by openapi-generator");
LOGGER.error("No inner type supplied for array parameter `{}`. Default to type:string", schema.getName());
inner = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
arraySchema.setItems(inner);
}
CodegenProperty codegenProperty = fromProperty("property", schema);
CodegenProperty codegenProperty = fromProperty("property", arraySchema);
imports.add(codegenProperty.baseType);
CodegenProperty innerCp = codegenProperty;
CodegenProperty mostInnerItem = innerCp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -708,15 +708,17 @@ public String getTypeDeclaration(Schema p) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
if (inner == null) {
LOGGER.warn(ap.getName() + "(array property) does not have a proper inner type defined.Default to string");
LOGGER.error("`{}` (array property) does not have a proper inner type defined. Default to type:string", ap.getName());
inner = new StringSchema().description("TODO default missing array inner type to string");
ap.setItems(inner);
}
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
if (inner == null) {
LOGGER.warn(p.getName() + "(map property) does not have a proper inner type defined. Default to string");
inner = new StringSchema().description("TODO default missing array inner type to string");
LOGGER.error("`{}` (map property) does not have a proper inner type defined. Default to type:string", p.getName());
inner = new StringSchema().description("TODO default missing map inner type to string");
p.setAdditionalProperties(inner);
}
return getSchemaType(p) + "<String, " + getTypeDeclaration(inner) + ">";
}
Expand All @@ -742,8 +744,11 @@ public String toDefaultValue(Schema p) {
} else {
pattern = "new ArrayList<%s>()";
}

if (ap.getItems() == null) {
return null;
LOGGER.error("`{}` (array property) does not have a proper inner type defined. Default to type:string", ap.getName());
Schema inner = new StringSchema().description("TODO default missing array inner type to string");
ap.setItems(inner);
}

String typeDeclaration = getTypeDeclaration(ap.getItems());
Expand Down