Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAPI: Use oneOf with $ref #2964

Open
1 task done
jeengbe opened this issue May 31, 2024 · 0 comments
Open
1 task done

OpenAPI: Use oneOf with $ref #2964

jeengbe opened this issue May 31, 2024 · 0 comments
Labels

Comments

@jeengbe
Copy link

jeengbe commented May 31, 2024

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

I would like to get a named oneOf in /components/schemas and referring to it with $ref instead of inlining all oneOf types.

Advantages of this are numerous. I currently experience working with oneOfs as rather painful. On one hand, you cannot simply use oneOf in the same way you use other models by referring to them with getSchemaPath. Instead, you need to know that the type referred to is a union type.
It also makes working with clients generated from the API documentation more cumbersome. When used to be a nicely named union type, now has to be named like ThingDto['unionField'], or UnionADto | UnionBDto | ....

Describe the solution you'd like

In the example in the docs, this would be creating a PetDto schema for the Pet union type, which is then used like $ref: /components/schemas/PetDto instead of an inline oneOf.

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

described above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant