swagger-api / swagger-api/swagger-parser
Swagger 2 Relative path references are not getting resolved
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
While using java Swagger2 parser, the relative references are not getting resolved, if the references are in some other folder.
Is there a way to define what should be the root path from where the references should be resolved.
Eg. If a file located in https://example.com/content/test/api/swagger/test.yaml has a reference, $ref: '../some-other-folder/message.yaml#/definitions/MessageArray'
and the file is located in https://example.com/content/test/api/some-other-folder/message.yaml
the parser is not able to resolve the relative path and throws the error.
Is there a way to resolve a relative path with a given base path, eg user could provide an option to always resolve the relative paths using https://example.com/content/test/api/ and the content of relative path is appended to the give url, thus forming the location https://example.com/content/test/api/some-other-folder/message.yaml ?
This works in OpenAPIV3Parser.
Thanks
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
The issue names no files or tests. Start by locating the Java Swagger 2 parser's relative-reference resolution entry point and compare it with OpenAPIV3Parser; verify completion with a regression case covering a sibling-folder $ref and a supplied base URL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100