Repository: swagger-api/swagger-parser
Pull request #730 (2018-06-04 12:06:26)

Fix inlineResolver adding schema type.
Fix issue #705


Patch:
diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/InlineModelResolver.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/InlineModelResolver.java
index be93c1d4..4eb0579a 100644
--- a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/InlineModelResolver.java
+++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/InlineModelResolver.java
@@ -436,6 +436,7 @@ public class InlineModelResolver {
         model.setExample(example);
         model.setName(name);
         model.setXml(xml);
+        model.setType(object.getType());
 
         if (properties != null) {
             flattenProperties(properties, path);


Test patch:
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/InlineModelResolverTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/InlineModelResolverTest.java
index 99ff7e90..768b1aa8 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/InlineModelResolverTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/InlineModelResolverTest.java
@@ -16,6 +16,8 @@ import io.swagger.v3.oas.models.parameters.Parameter;
 import io.swagger.v3.oas.models.parameters.RequestBody;
 import io.swagger.v3.oas.models.responses.ApiResponse;
 import io.swagger.v3.oas.models.responses.ApiResponses;
+import io.swagger.v3.parser.OpenAPIV3Parser;
+import io.swagger.v3.parser.core.models.ParseOptions;
 import org.testng.annotations.Test;
 
 
@@ -29,6 +31,17 @@ import static org.testng.AssertJUnit.*;
 
 @SuppressWarnings("static-method")
 public class InlineModelResolverTest {
+
+    @Test
+    public void testIssue705() throws Exception {
+        ParseOptions options = new ParseOptions();
+        options.setFlatten(true);
+        OpenAPI openAPI = new OpenAPIV3Parser().read("issue-705.yaml",null, options);
+        assertNotNull(openAPI);
+        assertNotNull(openAPI.getComponents().getSchemas().get("inline_response_200").getType());
+    }
+
+
     @Test
     public void resolveInlineModelTestWithoutTitle() throws Exception {
         OpenAPI openAPI = new OpenAPI();
diff --git a/modules/swagger-parser-v3/src/test/resources/issue-705.yaml b/modules/swagger-parser-v3/src/test/resources/issue-705.yaml
new file mode 100644
index 00000000..c2b4c4b7
--- /dev/null
+++ b/modules/swagger-parser-v3/src/test/resources/issue-705.yaml
@@ -0,0 +1,41 @@
+openapi: 3.0.0
+info:
+  version: 1.0.0
+  title: Swagger Petstore
+  license:
+    name: MIT
+paths:
+  /pets:
+    get:
+      summary: List all pets
+      operationId: listPets
+      tags:
+        - pets
+      parameters:
+        - name: limit
+          in: query
+          description: How many items to return at one time (max 100)
+          required: false
+          schema:
+            type: integer
+            format: int32
+      responses:
+        '200':
+          description: An paged array of pets
+          headers:
+            x-next:
+              description: A link to the next page of responses
+              schema:
+                type: string
+          content:
+            application/json:
+              schema:
+                 type: object
+                 properties:
+                    id:
+                      type: integer
+                      format: int64
+                    name:
+                      type: string
+                    tag:
+                      type: string
\ No newline at end of file