Bundle output can't handle $ref with same name but different directory path
Describe the bug When using redocly bundle, if your openapi file uses a $ref for e.g. "custom: $ref: components/schemas/custom.yaml" and then a second one of the same filename but different path e.g. "includes: $ref: components/schemas/includes/custom.yaml", then the bundle output shows
Two schemas are referenced with the same name but different content. Renamed Guest to Custom-2.
and the actual JSON/YAML loses its property name ("includes" in this example) and is changed to "Custom-2".
Expected behavior the bundle command should be keeping track of references using the full path not just the filename.
Minimal reproducible OpenAPI snippet(if possible)
post:
operationId: xxx_get
tags:
- xxx
description: Retrieve an existing xxx
requestBody:
content:
application/json:
schema:
type: object
required:
- id
properties:
id:
type: number
format: integer
include:
$ref: ../components/schemas/includes/XXX.yaml
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
required:
- success
- data
properties:
success:
type: boolean
default: true
data:
$ref: ../components/schemas/XXX.yaml
Hey @mykelscappin. We can confirm the issue on our end. Thanks for the report!
Stay tuned for updates.
@mykelscappin this is a warning. redocly-cli bundle command extracts shared schemas into components->schemas section. We can't have duplicates there so we automatically renamed the second schema to Custom-2. The resulting definition is still valid.
Do you have any specific problem with the bundle command output?
We think that having two different schemas with the same name is in general not a very good practice so we made it a warning.
Is there a way to customize the schema names using a decorator or plugin or something? I have a similar case where I have multiple folders with the same (mutliple) files in it. Adding the folder name to the scheme name would be ideal