Skip to content

Commit c9429c8

Browse files
committed
update tests
1 parent 9b985a2 commit c9429c8

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,20 @@ private void gatherInlineModels(Schema schema, String modelPrefix) {
353353
}
354354
}
355355
}
356-
} else if (schema.getProperties() != null) {
357-
// If non-object type is specified but also properties
358-
LOGGER.warn("Illegal schema found with non-object type ({}) combined with properties. Properties automatically removed.", schema.getType());
359-
schema.setProperties(null);
360-
return;
361-
} else if (schema.getAdditionalProperties() != null) {
362-
// If non-object type is specified but also additionalProperties
363-
LOGGER.error("Illegal schema found with non-object type ({}) combined with additionalProperties. AdditionalProperties automatically removed.", schema.getType());
364-
schema.setAdditionalProperties(null);
365-
return;
356+
} else {
357+
if (schema.getProperties() != null) {
358+
// If non-object type is specified but also properties
359+
LOGGER.warn("Illegal schema found with non-object type ({}) combined with properties. Properties automatically removed.", schema.getType());
360+
schema.setProperties(null);
361+
return;
362+
}
363+
364+
if (schema.getAdditionalProperties() != null) {
365+
// If non-object type is specified but also additionalProperties
366+
LOGGER.error("Illegal schema found with non-object type ({}) combined with additionalProperties. AdditionalProperties automatically removed.", schema.getType());
367+
schema.setAdditionalProperties(null);
368+
return;
369+
}
366370
}
367371

368372
// Check array items

modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,8 +2272,12 @@ public void testResponseWithArray_issue12524() throws Exception {
22722272
additionalProperties.put(RETURN_SUCCESS_CODE, "true");
22732273
Map<String, File> files = generateFromContract("src/test/resources/bugs/issue_12524.json", SPRING_BOOT, additionalProperties);
22742274

2275-
JavaFileAssert.assertThat(files.get("API01ListOfStuff.java"))
2276-
.hasImports("com.fasterxml.jackson.annotation.JsonTypeName");
2275+
// class extending array is no longer generated as it's automatically fixed by inline resolver
2276+
// by removing the properties for array type
2277+
//JavaFileAssert.assertThat(files.get("API01ListOfStuff.java"))
2278+
// .hasImports("com.fasterxml.jackson.annotation.JsonTypeName");
2279+
File notExisting = files.get("API01ListOfStuff.java");
2280+
assertThat(notExisting).isNull();
22772281
} finally {
22782282
GlobalSettings.reset();
22792283
}

0 commit comments

Comments
 (0)