Skip to content

Commit

Permalink
Merge pull request #1301 from r-sreesaran/issue-1236
Browse files Browse the repository at this point in the history
Fix for issue 1236
  • Loading branch information
gracekarina authored Jan 15, 2020
2 parents 646850f + b76ae7b commit 2e06ef6
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,12 @@ public Server getServer(ObjectNode obj, String location, ParseResult result, Str
if("http".equals(absURI.getScheme()) || "https".equals(absURI.getScheme())){
value = absURI.resolve(new URI(value)).toString();
}
else {
result.warning(location," invalid url : "+value);
}

} catch (URISyntaxException e) {
result.warning(location,"invalid url : "+value);
e.printStackTrace();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2261,6 +2261,15 @@ private static int getDynamicPort() {
}

@Test
public void testIssue1236() {
final ParseOptions options = new ParseOptions();
options.setResolve(true);

SwaggerParseResult result = new OpenAPIV3Parser()
.readLocation("src/test/resources/issue-1236/petstore.json",null,options);
assertEquals(result.getMessages().get(0),"attribute .servers. invalid url : /te st/sample.yaml");
}

public void testSampleParser() {
final String location = "src/test/resources/issue-1211.json";

Expand Down
131 changes: 131 additions & 0 deletions modules/swagger-parser-v3/src/test/resources/issue-1236/petstore.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"openapi": "3.0.2",
"info": {
"title": "Swagger Petstore - OpenAPI 3.0",
"description": "This is a sample Pet Store Server based on the OpenAPI 3.0 specification. You can find out more about\nSwagger at [http://swagger.io](http://swagger.io). In the third iteration of the pet store, we've switched to the design first approach!\nYou can now help us improve the API whether it's by making changes to the definition itself or to the code.\nThat way, with time, we can improve the API in general, and expose some of the new features in OAS3.\n\nSome useful links:\n- [The Pet Store repository](https://github.com/swagger-api/swagger-petstore)\n- [The source API definition for the Pet Store](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"email": "apiteam@swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "1.0.4"
},
"externalDocs": {
"description": "Find out more about Swagger",
"url": "http://swagger.io"
},
"servers": [
{
"url": "/te st/sample.yaml"
}
],
"tags": [
{
"name": "pet",
"description": "Everything about your Pets",
"externalDocs": {
"description": "Find out more",
"url": "http://swagger.io"
}
},
{
"name": "store",
"description": "Operations about user"
},
{
"name": "user",
"description": "Access to Petstore orders",
"externalDocs": {
"description": "Find out more about our store",
"url": "http://swagger.io"
}
}
],
"paths": {
"/user/login": {
"get": {
"tags": [
"user"
],
"summary": "Logs user into the system",
"description": "",
"operationId": "loginUser",
"parameters": [
{
"name": "username",
"in": "query",
"description": "The user name for login",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "password",
"in": "query",
"description": "The password for login in clear text",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"headers": {
"X-Rate-Limit": {
"description": "calls per hour allowed by the user",
"schema": {
"type": "integer",
"format": "int32"
}
},
"X-Expires-After": {
"description": "date in UTC when toekn expires",
"schema": {
"type": "string",
"format": "date-time"
}
}
},
"content": {
"application/xml": {
"schema": {
"type": "string"
}
},
"application/json": {
"schema": {
"type": "string"
}
}
}
},
"400": {
"description": "Invalid username/password supplied"
}
}
}
},
"/user/logout": {
"get": {
"tags": [
"user"
],
"summary": "Logs out current logged in user session",
"description": "",
"operationId": "logoutUser",
"parameters": [],
"responses": {
"default": {
"description": "successful operation"
}
}
}
}
}
}

0 comments on commit 2e06ef6

Please sign in to comment.