swagger-api / swagger-api/swagger-parser
[Bug]: Presence of path parameter in parent reference leads to unresolved examples
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
Description
When parsing an OpenAPI v3.0.3 specification that contains nested references for an operation with a path parameter the new ParseOptions().setResolve(true) method doesn't resolve the examples.
Affected Version
Current main branch, so 2.1.35
Steps to Reproduce
Given the example OpenAPI specification at https://gist.github.com/clone1612/e9ca124ca323843d0175c67a4890d5ee the following test will fail:
OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult parseResult = openApiParser.readLocation("reproducer.yaml", null, options);
OpenAPI openAPI = parseResult.getOpenAPI();
assertNotNull(openAPI.getComponents().getExamples());
Expected Behavior
The examples should have been resolved
Actual Behavior
The examples aren't resolved
Environment
λ java -version
openjdk version "1.8.0_452"
OpenJDK Runtime Environment (build 1.8.0_452-b09)
OpenJDK 64-Bit Server VM (build 25.452-b09, mixed mode)
λ mvn --version
Apache Maven 3.9.8 (36645f6c9b5079805ea5009217e36f2cffd34256)
...
OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"
Additional Context
Discovered while attempting to fix https://github.com/OpenAPITools/openapi-generator/issues/21409 but issue is located in this underlying library
Checklist
- I have searched the existing issues and this is not a duplicate.
- I have provided sufficient information for maintainers to reproduce the issue.
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 OpenAPIV3Parser.readLocation and ParseOptions.setResolve(true), using the reproducer.yaml specification from the linked gist and the test shown in the issue. Trace nested references for an operation with a path parameter; done means parseResult.getOpenAPI().getComponents().getExamples() is populated with the resolved examples.
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
- 55/100