Skip to content

Commit

Permalink
Better support for composed schema (allOf) (OpenAPITools#1842)
Browse files Browse the repository at this point in the history
* better support for composed schema

* remove commented code
  • Loading branch information
wing328 authored Jan 9, 2019
1 parent 4ba1d52 commit 637d60d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
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

0 comments on commit 637d60d

Please sign in to comment.