swagger-api / swagger-parser

Swagger Spec to Java POJOs
http://swagger.io
Apache License 2.0
785 stars 531 forks source link

Swagger parsing fails when Servers URL is set to / (default) value #1897

Open vpawar-tibco opened 1 year ago

vpawar-tibco commented 1 year ago

As per swagger docs - https://swagger.io/docs/specification/api-host-and-base-path/

If the servers array is not provided or is empty, the server URL defaults to /

While parsing a swagger json with -

 "servers": [
    {
      "url": "/"
    }
  ],

and the java code to parse the swagger json -

OpenAPI swagger = new OpenAPIV3Parser().read(<path-to-swagger.json>);
if(swagger == null) {
    System.out.println("Swagger is null");
}

The swagger object returns null. When the server url is set to http://localhost/ the same code snippet works fine.

Swagger parser version - v3-2.1.12