Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ public Schema modelFromProperty(ArraySchema object, @SuppressWarnings("unused")
public Schema modelFromProperty(ObjectSchema object, String path) {
String description = object.getDescription();
String example = null;
List<String> requiredList = object.getRequired();


Object obj = object.getExample();
if (obj != null) {
Expand All @@ -437,6 +439,7 @@ public Schema modelFromProperty(ObjectSchema object, String path) {
model.setName(name);
model.setXml(xml);
model.setType(object.getType());
model.setRequired(requiredList);

if (properties != null) {
flattenProperties(properties, path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@



import io.swagger.v3.core.util.Yaml;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
Expand Down Expand Up @@ -32,6 +33,17 @@
@SuppressWarnings("static-method")
public class InlineModelResolverTest {

@Test
public void testIssue1018() throws Exception {
ParseOptions options = new ParseOptions();
options.setFlatten(true);
OpenAPI openAPI = new OpenAPIV3Parser().read("flatten.json",null, options);

assertNotNull(openAPI);
assertNotNull(openAPI.getComponents().getSchemas().get("ReturnInformation_manufacturer_signin_credentials").getRequired());
}


@Test
public void testIssue705() throws Exception {
ParseOptions options = new ParseOptions();
Expand Down
20 changes: 20 additions & 0 deletions modules/swagger-parser-v3/src/test/resources/flatten.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@
"openapi" : "3.0.1",
"components" : {
"schemas" : {
"ReturnInformation": {
"type": "object",
"properties": {
"manufacturer_signin_credentials": {
"type": "object",
"properties": {
"login": {
"type": "string"
},
"password": {
"type": "string"
}
},
"required": [
"login",
"password"
]
}
}
},
"User" : {
"required" : [ "address" ],
"properties" : {
Expand Down