Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix case additionalProperties: {}
  • Loading branch information
wing328 committed Apr 28, 2020
commit df2974a0ad776a56976ce47b5a5d62bba7bb999c
Original file line number Diff line number Diff line change
Expand Up @@ -2637,7 +2637,6 @@ protected List<MappedModel> getOneOfAnyOfDescendants(String composedSchemaName,

protected List<MappedModel> getAllOfDescendants(String thisSchemaName, OpenAPI openAPI) {
ArrayList<String> queue = new ArrayList();
;
List<MappedModel> descendentSchemas = new ArrayList();
Map<String, Schema> schemas = ModelUtils.getSchemas(openAPI);
String currentSchemaName = thisSchemaName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,12 @@ public static boolean isAnyTypeSchema(Schema schema) {
once(LOGGER).error("Schema cannot be null in isAnyTypeSchema check");
return false;
}

if (isFreeFormObject(schema)) {
// to cover `additionalProperties: {}`
return false;
}

if (schema.getClass().equals(Schema.class) && schema.get$ref() == null && schema.getType() == null &&
(schema.getProperties() == null || schema.getProperties().isEmpty()) &&
schema.getAdditionalProperties() == null && schema.getNot() == null &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,23 +646,22 @@ public void testAnyType() {
Assert.assertEquals(property1.baseName, "any_value");
Assert.assertEquals(property1.dataType, "oas_any_type_not_mapped");
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertFalse(property1.isPrimitiveType);
Assert.assertFalse(property1.isContainer);

final CodegenProperty property2 = cm1.vars.get(1);
Assert.assertEquals(property2.baseName, "any_value_with_desc");
Assert.assertEquals(property2.dataType, "oas_any_type_not_mapped");
Assert.assertTrue(property2.hasMore);
Assert.assertTrue(property2.required);
Assert.assertFalse(property2.required);
Assert.assertFalse(property2.isPrimitiveType);
Assert.assertFalse(property2.isContainer);

final CodegenProperty property3 = cm1.vars.get(2);
Assert.assertEquals(property3.baseName, "any_value_nullable");
Assert.assertEquals(property3.dataType, "oas_any_type_not_mapped");
Assert.assertTrue(property3.hasMore);
Assert.assertTrue(property3.required);
Assert.assertFalse(property3.required);
Assert.assertFalse(property3.isPrimitiveType);
Assert.assertFalse(property3.isContainer);

Expand Down