Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add schema properties to vars also for composed schema #536

Merged
merged 1 commit into from
Nov 11, 2019
Merged
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
Add schema properties to vars also for composed schema
  • Loading branch information
frantuma committed Nov 11, 2019
commit 25bd8e26c462a2059c25213151132b75d7a715d6
Original file line number Diff line number Diff line change
Expand Up @@ -1456,21 +1456,21 @@ protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Sc
}

protected void addProperties(Map<String, Schema> properties, List<String> required, Schema schema, Map<String, Schema> allSchemas) {
if(schema instanceof ComposedSchema) {
ComposedSchema composedSchema = (ComposedSchema) schema;
if(composedSchema.getAllOf() == null || composedSchema.getAllOf().isEmpty() || composedSchema.getAllOf().size() == 1) {
return;
}
for (int i = 1; i < composedSchema.getAllOf().size(); i++) {
addProperties(properties, required, composedSchema.getAllOf().get(i), allSchemas);
}
return;
}
if(StringUtils.isNotBlank(schema.get$ref())) {
Schema interfaceSchema = allSchemas.get(OpenAPIUtil.getSimpleRef(schema.get$ref()));
addProperties(properties, required, interfaceSchema, allSchemas);
return;
}

if(schema instanceof ComposedSchema) {
ComposedSchema composedSchema = (ComposedSchema) schema;
if(!(composedSchema.getAllOf() == null || composedSchema.getAllOf().isEmpty() || composedSchema.getAllOf().size() == 1)) {
for (int i = 1; i < composedSchema.getAllOf().size(); i++) {
addProperties(properties, required, composedSchema.getAllOf().get(i), allSchemas);
}
}
}

if(schema.getProperties() != null) {
properties.putAll(schema.getProperties());
}
Expand Down