-
Notifications
You must be signed in to change notification settings - Fork 474
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
feat(plugin) add support for @Expose() and @Exclude() decorators #2777
Conversation
LGTM |
👀 |
@kurt-west |
@gustavopedroni - this PR follows the existing plugin pattern of decorating properties, not classes. The class visitor could be updated to pass @expose()/@exclude() metadata down to the property visitor to match the class-transformer pattern of class or property decoration. @kamilmysliwiec - if you'd support this I can submit a PR. |
Thanks for this contribution, that's a great feature. Any idea how to achieve that? Thanks |
How it works: Is it possible: If you post a manually generated dto I can dig deeper and see if we can come up with a feature proposal for the Nest team. |
@gustavopedroni |
Hi @kurt-west , did you ever wind up submitting the PR for class-level exclude? I didn't see it in a cursory search so I figured I'd ask. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The Swagger plugin will automatically annotate all DTO properties with @ApiProperty unless @ApiHideProperty is used.
Issue Number: #2603
What is the new behavior?
This PR adds support to include or hide DTO properties from the generated OpenAPI definitions via the existing class-transformer decorators.
The new
classTransformerShim
option can be set to one of the following:@Exclude()
will be hidden from the the generated definition; same behavior as@ApiHideProperty()
@Expose()
or@ApiProperty
will be included in the generated definitionNOTE: default is
classTransformerShim: false
Does this PR introduce a breaking change?
Other information
Small unrelated change to
test/plugin/readonly-visitor.spec.ts
to help with test failing due to end-of-line characters differences between host machine and PluginMetadataPrinter output.Edit: grammar