swagger-api / swagger-api/swagger-parser
Swagger parsing fails when Servers URL is set to / (default) value
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with OpenAPIV3Parser.read using a Swagger JSON whose servers array contains {"url":"/"}, then compare it with the working http://localhost/ case. Trace the parser path for the server URL and consider the issue done when the root URL produces a non-null OpenAPI object without breaking the existing localhost case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100