swagger-api / swagger-api/swagger-parser
OpenAPIParser does not resolve references in Swagger 2.0
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
OpenAPIParser with resolveFully option does not seem to replace $ref references in Swagger 2.0 specification. For example:
ParseOptions opts = new ParseOptions();
opts.setResolveFully(true);
SwaggerParseResult result = new OpenAPIParser().readLocation("https://petstore.swagger.io/v2/swagger.json", null, opts);
Schema schema = (Schema) result.getOpenAPI().getComponents().getSchemas().get("Pet").getProperties().get("category");
will produce a generic Schema object with empty properties field and $ref = "#/components/schemas/Category".
The same code with https://petstore3.swagger.io/api/v3/openapi.json specification will result in an ObjectSchema instance with correctly populated properties.
Version used is 2.0.24. Version 1.x does not have setResolveFully option and it also produces plain RefProperty items so I am not sure if it supports reference resolution at all.
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 with OpenAPIParser.readLocation and ParseOptions.setResolveFully, then compare reference handling for the supplied Swagger 2.0 petstore specification with the OpenAPI 3 example. Done means resolving the Pet category reference produces a populated schema rather than a generic Schema retaining the $ref.
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
- 38/100