$refs to local filesystem paths are URL encoded, resulting in no such file or directory error
See original GitHub issueChecklist
- Conversion: I have checked my source definition is valid OpenAPI 2.0
- Conversion: On valid OpenAPI 2.0 input, the conversion looks wrong
- Validation: I believe my source definition is valid OpenAPI 3.0.x but the validator complains
- Validation: I believe my source definition is invalid OpenAPI 3.0.x but the validator does not complain
- Linting issue
- Resolver issue
Detailed Description
When resolving $refs, if the local filesystem path contains spaces (e.g. /some/path/with spaces/swagger.json) the paths are incorrectly URL encoded, resulting in the following error:
ENOENT: no such file or directory, open '/some/path/with%20spaces/ref.json'
It would appear the problem is being caused by URL encoding that is being performed by URL, which translates the spaces to %20 and ultimately results in the files not being found on the local filesystem. With the white-space removed from the path, the parser works fine and our project is validated correctly.
This issue was discovered when we started using speccy to validate our swagger documentation as part of our CI pipeline where the Jenkins job name contained a space. We have worked around it for the time being by renaming the job, but thought we should bring this to your attention.
Other stuff
We are using speccy to validate our OpenAPI 3.0 documentation.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (6 by maintainers)

Top Related StackOverflow Question
No problem, should be covered by tests such as
test/resolver/speccy 141.We are also facing this issue. when trying to use oas-resolver for folder containing spaces it tends to fail with
ENOENT: no such file or directory, open '/Users/umesh/<more-folders>/petstore%20separate%20yaml/spec/Pet.yamlpetstore separate yaml.zip Please try to resolve the above folder and let me know if it is failing for you as well.@MikeRalphson
Edit: After increasing the level of verbosity I found out the exact place where this is happening:
Rewriting external ref Pet.yaml as /Users/umesh/<more-folders>/petstore%20separate%20yaml/spec/Pet.yamlhttps://github.com/Mermade/oas-kit/blob/master/packages/oas-resolver/index.js#L89