Skip to content

[OAS3] conversion of external references to internal references is incorrect #834

@tomblench

Description

@tomblench
  • swagger-parser version: OpenAPITools/swagger-parser commit 090c789d (Thu Sep 6 07:01:26 2018 +0200) from 2.0-OpenAPITools branch.

  • Code snippet used to load OpenAPI definition:
    OpenAPI oai = new OpenAPIV3Parser().read("/path/to/index.yaml");

The attached tarball is a minimal sample which exhibits the issue:

oapi-reference-test2.zip

In some circumstances, after an external reference is resolved for the first time, subsequent internal references are incorrect as they are relative to the referring document and not the root.

Output from above program attached
parser-output.txt.

This is due to ExternalRefProcessor#processRefToExternalResponse concatenating the current file and the internal reference to yield ./components/response1.yaml#components/schemas/schema whereas the reference should be on the root (unsure whether this should be /index.yaml#components/schemas/schema or /#components/schemas/schema or something else).

Note that the attached test case is not exhaustive and I suspect that all of the processRefToExternal* methods suffer from this logic error.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions