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

Closed
1 task done
jeengbe opened this issue May 31, 2024 · 1 comment
Closed
1 task done

OpenAPI: Use oneOf with $ref #2964

jeengbe opened this issue May 31, 2024 · 1 comment
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

@kamilmysliwiec
Copy link
Member

Thanks for your suggestion!

There are no plans to implement it in the foreseeable future.

If you think your request could live outside Nest's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

@nestjs nestjs locked and limited conversation to collaborators Oct 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants