Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,19 @@ public Response response(ObjectNode node, String location, ParseResult result) {
result.invalidType(location, "$ref", "string", node);
}
} else {
output.responseSchema(Json.mapper().convertValue(schema, Model.class));
String l = null;
JsonNode ln = schema.get("name");
if (ln != null) {
l = ln.asText();
} else {
l = "['unknown']";
}
location += ".[" + l + "]";

Model model = definition(schema, location, result);
if (model != null) {
output.responseSchema(model);
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1715,4 +1715,17 @@ public void testInlineModelResolverByLocation() {
assertTrue(userAddress.getProperties().containsKey("city"));
assertTrue(userAddress.getProperties().containsKey("street"));
}

@Test
public void testIssue1552() throws Exception {
Swagger swagger = new SwaggerParser().read("src/test/resources/issue1552.yaml");

Assert.assertNotNull(swagger);
Assert.assertNotNull(swagger.getResponses().get("Response"));
Assert.assertNotNull(swagger.getResponses().get("Response").getResponseSchema().getProperties());
Assert.assertNotNull(swagger.getResponses().get("Response").getResponseSchema().getProperties().get("Report"));


}

}
34 changes: 34 additions & 0 deletions modules/swagger-parser/src/test/resources/issue1552.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
swagger: '2.0'
info:
title: Some API
description: >-
This is the Som Api
version: 2.0.0
basePath: /somepath
schemes:
- https
consumes:
- application/json
produces:
- application/json
paths:
/somepath:
get:
description: >
my description
operationId: MyGet
responses:
'200':
$ref: '#/responses/Response'
responses:
Response:
description: Response
schema:
type: object
required:
- Report
properties:
Report:
type: string
additionalProperties: false