Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server with relative location are not converted to an absolute url #742

Closed
jmini opened this issue Jun 19, 2018 · 1 comment
Closed

Server with relative location are not converted to an absolute url #742

jmini opened this issue Jun 19, 2018 · 1 comment

Comments

@jmini
Copy link
Contributor

jmini commented Jun 19, 2018

The OAS3 spec specifies:

This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the OpenAPI document is being served.

With a server that serves on http://localhost:8090/openapi.json:

{
  "openapi": "3.0.1",
  "servers": [
    {
      "url": "/rel"
    }
  ],
  "info": {
    "description": "This is a sample server",
    "version": "1.0.0",
    "title": "OpenAPI Petstore",
    "license": {
      "name": "Apache-2.0",
      "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
    }
  },
  "paths": {
    "/ping": {
      "get": {
        "summary": "Some ping operation",
        "description": "Some ping operation",
        "operationId": "doPing",
        "responses": {
          "200": {
            "description": "OK",
            "content" : {
              "application/json" : {
                "schema" : {
                  "type" : "object",
                  "properties" : {
                    "status": {
                      "type" : "string",
                      "example" : "ok",
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

When you do:

String inputSpec = "http://localhost:8090/openapi.json";

OpenAPIParser openApiParser = new OpenAPIParser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setFlatten(true);

System.out.println(openAPI.getServers().get(0).getUrl()); //should be http://localhost:8090/rel

You get /rel where the expected value is http://localhost:8090/rel


Tested with:

<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser</artifactId>
<version>2.0.1</version>
A-Aravindhan added a commit to A-Aravindhan/swagger-parser that referenced this issue Jul 6, 2018
Server with relative location are not converted to an absolute url
jmini added a commit to jmini/swagger-parser that referenced this issue Jul 11, 2018
@jmini
Copy link
Contributor Author

jmini commented Jul 20, 2018

Solved with merge of #773

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant