Better support for composed schema (allOf) (#1842)

* better support for composed schema

* remove commented code
This commit is contained in:
William Cheng 2019-01-09 10:50:02 +08:00 committed by GitHub
parent 4c14c85542
commit 60dd3d51be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View File

@ -1841,7 +1841,7 @@ public class DefaultCodegen implements CodegenConfig {
.map(s -> ModelUtils.getSimpleRef(s.get$ref())) .map(s -> ModelUtils.getSimpleRef(s.get$ref()))
.collect(Collectors.toSet()); .collect(Collectors.toSet());
if (parentSchemas.contains(schemaName)) { if (parentSchemas.contains(schemaName)) {
discriminator.getMappedModels().add(new MappedModel(childName, childName)); discriminator.getMappedModels().add(new MappedModel(childName, toModelName(childName)));
} }
} }
}); });
@ -1864,18 +1864,21 @@ public class DefaultCodegen implements CodegenConfig {
protected void addProperties(Map<String, Schema> properties, List<String> required, Schema protected void addProperties(Map<String, Schema> properties, List<String> required, Schema
schema, Map<String, Schema> allSchemas) { schema, Map<String, Schema> allSchemas) {
if (schema instanceof ComposedSchema) { if (schema instanceof ComposedSchema) {
throw new RuntimeException("Please report the issue: Cannot process Composed Schema in addProperties: " + schema);
/*
ComposedSchema composedSchema = (ComposedSchema) schema; ComposedSchema composedSchema = (ComposedSchema) schema;
if (composedSchema.getAllOf() == null) {
return;
}
for (Schema component : composedSchema.getAllOf()) { for (Schema component : composedSchema.getAllOf()) {
addProperties(properties, required, component, allSchemas); 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; return;
*/
} }
Schema unaliasSchema = ModelUtils.unaliasSchema(globalSchemas, schema); Schema unaliasSchema = ModelUtils.unaliasSchema(globalSchemas, schema);

View File

@ -117,6 +117,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
setReservedWordsLowerCase( setReservedWordsLowerCase(
Arrays.asList( Arrays.asList(
// special words
"object",
// used as internal variables, can collide with parameter names // used as internal variables, can collide with parameter names
"localVarPath", "localVarQueryParams", "localVarCollectionQueryParams", "localVarPath", "localVarQueryParams", "localVarCollectionQueryParams",
"localVarHeaderParams", "localVarFormParams", "localVarPostBody", "localVarHeaderParams", "localVarFormParams", "localVarPostBody",