Skip to content
This repository was archived by the owner on Nov 24, 2022. It is now read-only.

Commit bff6717

Browse files
committed
fix for issue swagger-api#1018
1 parent 317330c commit bff6717

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/InlineModelResolver.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ public Schema modelFromProperty(ArraySchema object, @SuppressWarnings("unused")
422422
public Schema modelFromProperty(ObjectSchema object, String path) {
423423
String description = object.getDescription();
424424
String example = null;
425+
List<String> requiredList = object.getRequired();
426+
425427

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

441444
if (properties != null) {
442445
flattenProperties(properties, path);

modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/InlineModelResolverTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44

5+
import io.swagger.v3.core.util.Yaml;
56
import io.swagger.v3.oas.models.Components;
67
import io.swagger.v3.oas.models.OpenAPI;
78
import io.swagger.v3.oas.models.Operation;
@@ -32,6 +33,17 @@
3233
@SuppressWarnings("static-method")
3334
public class InlineModelResolverTest {
3435

36+
@Test
37+
public void testIssue1018() throws Exception {
38+
ParseOptions options = new ParseOptions();
39+
options.setFlatten(true);
40+
OpenAPI openAPI = new OpenAPIV3Parser().read("flatten.json",null, options);
41+
42+
assertNotNull(openAPI);
43+
assertNotNull(openAPI.getComponents().getSchemas().get("ReturnInformation_manufacturer_signin_credentials").getRequired());
44+
}
45+
46+
3547
@Test
3648
public void testIssue705() throws Exception {
3749
ParseOptions options = new ParseOptions();

modules/swagger-parser-v3/src/test/resources/flatten.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22
"openapi" : "3.0.1",
33
"components" : {
44
"schemas" : {
5+
"ReturnInformation": {
6+
"type": "object",
7+
"properties": {
8+
"manufacturer_signin_credentials": {
9+
"type": "object",
10+
"properties": {
11+
"login": {
12+
"type": "string"
13+
},
14+
"password": {
15+
"type": "string"
16+
}
17+
},
18+
"required": [
19+
"login",
20+
"password"
21+
]
22+
}
23+
}
24+
},
525
"User" : {
626
"required" : [ "address" ],
727
"properties" : {

0 commit comments

Comments
 (0)