swagger-parser icon indicating copy to clipboard operation
swagger-parser copied to clipboard

[Bug]: Presence of path parameter in parent reference leads to unresolved examples

Open jhemelhof opened this issue 2 months ago • 0 comments

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

  • [x] I have searched the existing issues and this is not a duplicate.
  • [x] I have provided sufficient information for maintainers to reproduce the issue.

jhemelhof avatar Nov 05 '25 12:11 jhemelhof