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

Better support for composed schema (allOf) #1842

Merged
merged 2 commits into from
Jan 9, 2019
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 @@ -1841,7 +1841,7 @@ private CodegenDiscriminator createDiscriminator(String schemaName, Schema
.map(s -> ModelUtils.getSimpleRef(s.get$ref()))
.collect(Collectors.toSet());
if (parentSchemas.contains(schemaName)) {
discriminator.getMappedModels().add(new MappedModel(childName, childName));
discriminator.getMappedModels().add(new MappedModel(childName, toModelName(childName)));
}
}
});
Expand All @@ -1864,18 +1864,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) {
throw new RuntimeException("Please report the issue: Cannot process Composed Schema in addProperties: " + schema);
/*
ComposedSchema composedSchema = (ComposedSchema) schema;
if (composedSchema.getAllOf() == null) {
return;
}

for (Schema component : composedSchema.getAllOf()) {
addProperties(properties, required, component, allSchemas);
}

if (composedSchema.getOneOf() != null) {
throw new RuntimeException("Please report the issue: Cannot process oneOf (Composed Scheme) in addProperties: " + schema);
}

if (composedSchema.getAnyOf() != null) {
throw new RuntimeException("Please report the issue: Cannot process anyOf (Composed Schema) in addProperties: " + schema);
}

return;
*/
}

Schema unaliasSchema = ModelUtils.unaliasSchema(globalSchemas, schema);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ public AbstractJavaCodegen() {

setReservedWordsLowerCase(
Arrays.asList(
// special words
"object",
// used as internal variables, can collide with parameter names
"localVarPath", "localVarQueryParams", "localVarCollectionQueryParams",
"localVarHeaderParams", "localVarFormParams", "localVarPostBody",
Expand Down