Change default inline object name (#2569)

* Change default inline object name

For #2516

* PR Review

* throughout
This commit is contained in:
Thibault Duperron 2019-04-04 06:17:03 +02:00 committed by William Cheng
parent d42b6d987a
commit b7b68ce0bc
2 changed files with 3 additions and 3 deletions

View File

@ -408,8 +408,8 @@ public class InlineModelResolver {
private String uniqueName(String key) {
if (key == null) {
key = "NULL_UNIQUE_NAME";
LOGGER.warn("null key found. Default to NULL_UNIQUE_NAME");
key = "InlineObject";
LOGGER.warn("Found an inline schema without the `title` attribute. Default the model name to InlineObject instead. To have better control of the model naming, define the model separately so that it can be reused throughout the spec.");
}
int count = 0;
boolean done = false;

View File

@ -378,7 +378,7 @@ public class InlineModelResolverTest {
ArraySchema requestBody = (ArraySchema) mediaType.getSchema();
assertNotNull(requestBody.getItems().get$ref());
assertEquals("#/components/schemas/NULL_UNIQUE_NAME", requestBody.getItems().get$ref());
assertEquals("#/components/schemas/InlineObject", requestBody.getItems().get$ref());
Schema items = ModelUtils.getReferencedSchema(openAPI, ((ArraySchema) mediaType.getSchema()).getItems());
assertTrue(items.getProperties().get("street") instanceof StringSchema);