Repository: swagger-api/swagger-parser
Pull request #1578 (2021-06-18 23:24:17)

fix xml attribute in resolveFully option in ComposedSchema
fix xml attribute in resolveFully option in ComposedSchema


Patch:
diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/ResolverFully.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/ResolverFully.java
index 3248076a..de2240a5 100644
--- a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/ResolverFully.java
+++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/ResolverFully.java
@@ -377,6 +377,10 @@ public class ResolverFully {
                     combinedModel.setExample(examples);
                 }
 
+                if(schema.getXml()!= null){
+                    combinedModel.setXml(schema.getXml());
+                }
+
                 result = combinedModel;
 
             } else {


Test patch:
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java
index 6d4b5d9d..4868ce9e 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java
@@ -83,6 +83,15 @@ public class OpenAPIV3ParserTest {
     protected int serverPort = getDynamicPort();
     protected WireMockServer wireMockServer;
 
+    @Test
+    public void testAnonymousModelAllOf() {
+        ParseOptions options = new ParseOptions();
+        options.setResolveFully(true);
+        SwaggerParseResult result = new OpenAPIV3Parser().readLocation("issue203/issue203AllOf.yaml", null, options);
+        OpenAPI openAPI = result.getOpenAPI();
+        assertEquals(openAPI.getComponents().getSchemas().get("Supplier").getXml().getName(),"supplierObject");
+    }
+
     @Test
     public void testIssue1518() {
         ParseOptions options = new ParseOptions();
@@ -103,8 +112,6 @@ public class OpenAPIV3ParserTest {
         }catch (StackOverflowError stackOverflowError){
             assertTrue(false);
         }
-
-
     }
 
     @Test
diff --git a/modules/swagger-parser-v3/src/test/resources/issue203/issue203AllOf.yaml b/modules/swagger-parser-v3/src/test/resources/issue203/issue203AllOf.yaml
new file mode 100644
index 00000000..42eb5680
--- /dev/null
+++ b/modules/swagger-parser-v3/src/test/resources/issue203/issue203AllOf.yaml
@@ -0,0 +1,43 @@
+openapi: 3.0.0
+info:
+  title: test
+  version: 1.0.0
+paths:
+  /inventory:
+    get:
+      responses:
+        '200':
+          description: OK
+          content:
+            application/xml:
+              schema:
+                $ref: '#/components/schemas/InventoryItem'
+components:
+  schemas:
+    InventoryItem:
+      type: object
+      properties:
+        suppliersArray:
+          type: array
+          items:
+            $ref: '#/components/schemas/Supplier'
+      xml:
+        name: inventoryItem
+    Manufacturer:
+      type: object
+      properties:
+        name:
+          type: string
+          example: ACME Corporation
+      xml:
+        name: manufacturer
+    Supplier:
+      allOf:
+        - $ref: '#/components/schemas/Manufacturer'
+        - type: object
+          properties:
+            supplierRef:
+              type: string
+              example: REF123
+      xml:
+        name: supplierObject
\ No newline at end of file