Repository navigation
Closed
Labels
Description
Description
When parsing an openapi spec (using resolve: true) that has models A referencing C from file1 and B referencing C from file2, it will use C from file1 for both A and B.
I have created a reproduction in openapi-generator here: OpenAPITools/openapi-generator@43f0c76, only noticing afterwards, that the bug lies with swagger-parser.
The downstream project uses the following code for parsing:
final List<AuthorizationValue> authorizationValues = AuthParser.parse(this.auth);
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setResolveResponses(true);
SwaggerParseResult result = new OpenAPIParser().readLocation(inputSpec, authorizationValues, options);Affected Version
2.1.41
Steps to Reproduce
Try to parse the following spec using resolve: true.
Main spec file
openapi: 3.0.3
info:
title: Pet Store API
version: 1.0.0
paths: {}
components:
schemas:
SomeItem:
$ref: "inventory.yaml#/components/schemas/Pet"
Pet:
$ref: "pets.yaml#/components/schemas/Pet"inventory.yaml
openapi: 3.0.3
info:
title: Inventory API
version: 1.0.0
paths: {}
components:
schemas:
Pet:
type: object
properties:
name:
type: stringpets.yaml
openapi: 3.0.3
info:
title: Pets API
version: 1.0.0
paths: {}
components:
schemas:
Pet:
type: object
properties:
id:
type: integerExpected Behavior
SomeItem should include a name property and Pet should include an id property.
Actual Behavior
Both SomeItem and Pet use the same model Pet from inventory.yaml and contain the name attribute.
Environment
- Java version: OpenJDK 11
- Build tool: mvn 3.9.15
- OS: Arch Linux
Checklist
- I have searched the existing issues and this is not a duplicate.
- I have provided sufficient information for maintainers to reproduce the issue.
Activity
Resolve same-named schemas from different files as distinct components
Resolve same-named schemas from different files as distinct components (