Skip to content

Commit

Permalink
add tests for issue swagger-api#1541
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielCastro committed Mar 26, 2021
1 parent b053930 commit 0484fc9
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,43 @@ public void testIssuei432() {
assertEquals("attribute paths.'/tickets'(get).responses.200.title is unexpected",result.getMessages().get(0));
}

@Test
public void testIssue1541() {
SwaggerParser parser = new SwaggerParser();
final Swagger swagger = parser.read("src/test/resources/issue-1541/main.yaml");
assertNotNull(swagger);

Model inlineSchema = swagger.getPaths()
.get("/inline_response")
.getGet()
.getResponses()
.get("200")
.getResponseSchema();

assertNotNull(inlineSchema);
assertNotNull(inlineSchema.getProperties());
assertNotNull(inlineSchema.getProperties().get("a"));
assertEquals("number", inlineSchema.getProperties().get("a").getType());

Model responseRef = swagger.getPaths()
.get("/ref_response")
.getGet()
.getResponses()
.get("200")
.getResponseSchema();

assertNotNull(responseRef);
assertEquals("#/definitions/ref_response_object", responseRef.getReference());

Model refSchema = swagger.getDefinitions()
.get("ref_response_object");

assertNotNull(refSchema);
assertNotNull(refSchema.getProperties());
assertNotNull(refSchema.getProperties().get("a"));
assertEquals("number", refSchema.getProperties().get("a").getType());
}

@Test
public void testRequiredItemsInComposedModel() {
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo("src/test/resources/allOf-example/allOf.yaml", null, true);
Expand Down
38 changes: 38 additions & 0 deletions modules/swagger-parser/src/test/resources/issue-1541/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
swagger: '2.0'
info:
title: 'Issue 1541'
version: '1.0'
consumes:
- application/json
paths:
/inline_response:
get:
responses:
'200':
description: ok
schema:
type: object
additionalProperties: false
properties:
a:
type: number
/ref_response:
get:
responses:
'200':
description: ok
schema:
$ref: '#/definitions/ref_response_object'
definitions:
ref_response_object:
type: object
additionalProperties: false
properties:
a:
type: number
b:
type: object
additionalProperties: false
properties:
c: { type: number }
d: { type: string }

0 comments on commit 0484fc9

Please sign in to comment.