File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed
modules/swagger-parser-v2-converter/src
main/java/io/swagger/v3/parser/converter
java/io/swagger/parser/test Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -1194,6 +1194,7 @@ public Schema convert(io.swagger.models.Model v2Model) {
11941194 composed .setTitle (composedModel .getTitle ());
11951195 composed .setExtensions (convert (composedModel .getVendorExtensions ()));
11961196 composed .setAllOf (composedModel .getAllOf ().stream ().map (this ::convert ).collect (Collectors .toList ()));
1197+ composed .setRequired (composedModel .getRequired ());
11971198
11981199 addProperties (v2Model , composed );
11991200
Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ public class V2ConverterTest {
9696 private static final String ISSUE_1715_YAML = "issue-1715.yaml" ;
9797
9898 private static final String ISSUE_1767_YAML = "issue-1767.yaml" ;
99+ private static final String ISSUE_1796_YAML = "issue-1796.yaml" ;
99100
100101 private static final String API_BATCH_PATH = "/api/batch/" ;
101102 private static final String PETS_PATH = "/pets" ;
@@ -877,6 +878,16 @@ public void testIssue1767() throws Exception {
877878 assertNull (secondOperationSecurityRequirements );
878879 }
879880
881+ @ Test (description = "OpenAPI v2 converter - composed model should keep required properties" )
882+ public void testissue1796 () throws Exception {
883+ OpenAPI oas = getConvertedOpenAPIFromJsonFile (ISSUE_1796_YAML );
884+ assertNotNull (oas );
885+ ComposedSchema schema = (ComposedSchema ) oas .getComponents ().getSchemas ().get ("ComposedModel" );
886+ assertNotNull (schema .getRequired ());
887+ assertEquals (schema .getRequired ().size (), 1 );
888+ assertEquals (schema .getRequired ().get (0 ), "name" );
889+ }
890+
880891 @ Test ()
881892 public void testInlineDefinitionProperty () throws Exception {
882893 SwaggerConverter converter = new SwaggerConverter ();
Original file line number Diff line number Diff line change 1+ swagger : " 2.0"
2+ info :
3+ title : composed model conversion test
4+ version : 1.0.0
5+ paths :
6+ /composed :
7+ get :
8+ operationId : composed
9+ responses :
10+ " 200 " :
11+ description : OK
12+ schema :
13+ $ref : " #/definitions/ComposedModel"
14+ definitions :
15+ BaseModel :
16+ type : object
17+ required :
18+ - uuid
19+ properties :
20+ uuid :
21+ type : string
22+ ComposedModel :
23+ type : object
24+ required :
25+ - name
26+ allOf :
27+ - $ref : " #/definitions/BaseModel"
28+ properties :
29+ name :
30+ type : string
You can’t perform that action at this time.
0 commit comments