Skip to content

Commit

Permalink
Merge pull request #686 from swagger-api/classpath-test
Browse files Browse the repository at this point in the history
Adding test for issue #682 - ClassPath
  • Loading branch information
gracekarina committed Apr 13, 2018
2 parents 5d300f8 + e03531e commit 8b27bf3
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static String urlToString(String url, List<AuthorizationValue> auths) thr
final URL inUrl = new URL(cleanUrl(url));
final List<AuthorizationValue> query = new ArrayList<>();
final List<AuthorizationValue> header = new ArrayList<>();
if (auths != null) {
if (auths != null && auths.size() > 0) {
for (AuthorizationValue auth : auths) {
if ("query".equals(auth.getType())) {
appendValue(inUrl, auth, query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ public class OpenAPIV3ParserTest {
protected int serverPort = getDynamicPort();
protected WireMockServer wireMockServer;

@Test
public void issue682() throws Exception {
OpenAPIV3Parser parser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setResolveCombinators(false);
options.setResolveFully(true);

String location = getClass().getResource("/odin.yaml").toString();
Assert.assertNotNull(location);
final SwaggerParseResult result = parser.readLocation(location, null, options);
Assert.assertNotNull(result.getOpenAPI());
Assert.assertTrue(result.getMessages().isEmpty());
Assert.assertTrue(result.getOpenAPI().getPaths().get("/JTasker/startRun").getPost().getRequestBody().getContent().get("application/json").getSchema().getProperties().size() == 2);
}


@BeforeClass
private void setUpWireMockServer() throws IOException {
Expand Down
32 changes: 32 additions & 0 deletions modules/swagger-parser-v3/src/test/resources/odin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#https://mermade.org.uk/openapi-converter
openapi: 3.0.0
servers:
- url: 'http://localhost:8080'
info:
version: '3.0'
title: Odin API
description: ODIN UI Services API
paths:
/JTasker/startRun:
post:
tags:
- JTasker
summary: Start JTasker Run
operationId: JTasker_startRun
requestBody:
content:
application/json:
schema:
$ref: './resources/urn_jsonschema_com_issinc_odin_display_CreatePlan.json'
required: true
responses:
'200':
description: Success
content:
application/json:
schema:
type: array
items:
type: string
'500':
description: Server Error
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"type" : "object",
"id" : "urn:jsonschema:com:issinc:odin:display:CreatePlan",
"properties" : {
"createPlanEvents" : {
"type" : "object",
"id" : "urn:jsonschema:com:issinc:odin:display:CreatePlanEvents",
"properties" : {
"name" : {
"type" : "string"
},
"description" : {
"type" : "string"
},
"events" : {
"type" : "array",
"items" : {
"type" : "string"
}
}
}
},
"createPlanSensors" : {
"type" : "object",
"id" : "urn:jsonschema:com:issinc:odin:display:CreatePlanSensors",
"properties" : {
"sensors" : {
"type" : "array",
"items" : {
"type" : "string"
}
}
}
}
}
}

0 comments on commit 8b27bf3

Please sign in to comment.