Add helper function

This commit is contained in:
akihito.nakano
2018-03-31 20:30:47 +09:00
parent d9ec433a5b
commit 353c51fc0a
2 changed files with 13 additions and 1 deletions

View File

@@ -4122,6 +4122,18 @@ public class DefaultCodegen implements CodegenConfig {
return false;
}
protected boolean isMapSchema(Schema schema) {
if (schema instanceof MapSchema) {
return true;
}
if (schema.getAdditionalProperties() != null) {
return true;
}
return false;
}
protected void addOption(String key, String description) {
addOption(key, description, null);
}

View File

@@ -371,7 +371,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
return getTypeDeclaration(inner) + "[]";
} else if (p.getAdditionalProperties() != null) {
} else if (isMapSchema(p)) {
Schema inner = (Schema) p.getAdditionalProperties();
return getSchemaType(p) + "[string," + getTypeDeclaration(inner) + "]";
} else if (StringUtils.isNotBlank(p.get$ref())) {