swagger-api / swagger-api/swagger-parser
API Spec cannot be read from classpath or JAR on *Windows* file system
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
Getting Exception on Windows when reading a API spec packaged in the jar file to validate requests.
OpenAPIV3Parser.readContentFromLocation() uses the underlying sun.nio.file.Paths to find the API specs... on unix, this works file.
However, on Windows, the underlying java.nio.file.Path.of () uses the WindowsPathParser that in turn does not accept needed chars like ":" needed to read from a jar subsystem. Causing : j.n.f.InvalidPathException: Illegal char <:> at index 9: classpath:/static/my-api.yaml.
more complete stack:
j.n.f.InvalidPathException: Illegal char <:> at index 9: classpath:/static/my-api.yaml
at s.n.f.WindowsPathParser.normalize(WindowsPathParser.java:182)
at s.n.f.WindowsPathParser.parse(WindowsPathParser.java:153)
at s.n.f.WindowsPathParser.parse(WindowsPathParser.java:77)
at s.nio.fs.WindowsPath.parse(WindowsPath.java:92)
at s.n.f.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
at java.nio.file.Path.of(Path.java:147)
at java.nio.file.Paths.get(Paths.java:69)
at i.s.v.p.OpenAPIV3Parser.readContentFromLocation(OpenAPIV3Parser.java:225)
Versions use:
swagger-request-validator-core: 2.22.0
swagger-request-validator-springmvc: 2.22.0
io.swagger.parser.v3: 2.0.28
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
To sum it up:
As a system developer, I want the OpenAPIV2Parser to read the packaged spec from the jar file on Windows to get same behavior as Unix and to enable me to package my application and ressources as a single jar file.
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 at OpenAPIV3Parser.readContentFromLocation(), using the reported stack trace and the classpath:/static/my-api.yaml example to reproduce the failure on Windows with a packaged JAR. Compare resource loading with the Unix path behavior; done means the API spec can be read from the classpath or JAR on Windows as well as Unix.
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
- Mostly clear
- Newbie friendliness
- 45/100