swagger-api / swagger-api/swagger-parser
swagger-parser-v3 fails to parse Open API with relative paths
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
Version 2.0.0-rc3
io.swagger.parser.v3:swagger-parser-v3 fails to parse/load Open API v3 file that has relative paths. Here is an example:
paths:
/JTasker/startRun:
post:
tags:
- JTasker
summary: Start JTasker Run
operationId: JTasker_startRun
requestBody:
content:
application/json:
schema:
$ref: './resources/urn_jsonschema_com_issinc_odin_display_CreatePlan.json'
required: true
responses:
'200':
description: Success
content:
application/json:
schema:
type: array
items:
type: string
'500':
description: Server Error
The problem is that ClasspathHelper cannot load the child resource './resources/urn_jsonschema_com_issinc_odin_display_CreatePlan.json'. The problem is very clear when you look at the code.
ClasspathHelper#loadFileFromClasspath(String location) where location is './resources/urn_jsonschema_com_issinc_odin_display_CreatePlan.json'. That obviously can't find the file because that is not the correct path for loading from the class path. In our case the correct path would be '/webroot/resources/urn_jsonschema_com_issinc_odin_display_CreatePlan.json'.
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 swagger-parser-v3 and inspect ClasspathHelper#loadFileFromClasspath(String), using the relative ./resources/... reference in the issue as the reproduction case. Trace how child resources are resolved and verify the parser can load the referenced file from the appropriate classpath location, such as /webroot/resources/....
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100