swagger
swagger copied to clipboard
Add decorator to allow specification of the schema type name
You can use @ApiSchema to set a custom schema name. Custom schema names are not inherited.
PR Checklist
Please check if your PR fulfills the following requirements:
- [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
- [x] Tests for the changes have been added (for bug fixes / features)
- [x] Docs have been added / updated (for bug fixes / features)
PR Type
What kind of change does this PR introduce?
[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:
What is the current behavior?
Currently when creating schema for a class the class name is taken as the schema name.
Issue Number: N/A
What is the new behavior?
A new decorator has been introduced: @ApiSchema. Using this decorator you can define custom schema name different from the class name.
e.g. @ApiSchema({name: 'User'}) class UserDto {}
will produce a schema with name User, not UserDto.
Does this PR introduce a breaking change?
[ ] Yes
[x] No
Other information
Thanks! Could you create a PR to the docs as well? https://github.com/nestjs/docs.nestjs.com
Ok, will do!
@kamilmysliwiec here is the PR for documentation update https://github.com/nestjs/docs.nestjs.com/pull/1533
@nartc I haven't noticed any question there. Can you link it here, please?
When do you plan to merge and release it ?
I can't wait for merge and release it!
This PR is very helpful. When you guys are plan to merge and release it?
Can we release this soon please? It's been ready for quite a while now. There are other useful features that can be built on top of the ApiSchema decorator once this is merged (documentation at the type level).
It looks like this branch has merge conflicts - is this all that remains to be fixed? I'm willing to assist to help get this merged.
@adworacz I doubt the maintainer of this project wants to merge this PR/functionality. If he wanted he would have merged it when it was all green.
Ignore merge conflicts, I'll resolve them when I get to this PR.
https://github.com/nestjs/swagger/pull/2427