Skip to content

[BUG] OpenAPI 3.1 component not matched correctly when using $ref #21535

Open
@rockinrimmer

Description

@rockinrimmer

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When generating an OpenAPI 3.1 spec using generator openapi-yaml or the spring generator (and maybe others). If a response schema uses a $ref to a component and that is also a $ref to another file, an inner schema reference will create a new component schema instead of re-using an existing one. If the response $ref links to a component that is defined within the root openapi.yaml (that still uses a $ref for inner schema) then the expected output of re-using the component is what happens.

I've also prepared an example using OpenAPI 3.0 with the same schema layout as the OpenAPI 3.1 bug version and it produces the expected output as well.

openapi-generator version

7.14.0

OpenAPI declaration file content or url

Repo: https://github.com/rockinrimmer/OpenAPI-Generator-Inline-Ref-Bug with more details of each version provided in the readme.

Generation Details
Steps to reproduce

See https://github.com/rockinrimmer/OpenAPI-Generator-Inline-Ref-Bug?tab=readme-ov-file#running

Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions