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

Support @Expose() and @Exclude() or allow custom @ApiHideProperty() decorators #2603

Open
1 task done
kurt-west opened this issue Sep 5, 2023 · 3 comments
Open
1 task done
Labels

Comments

@kurt-west
Copy link
Contributor

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

With the CLI plugin not supporting the class-transformer @Expose and @Exclude and @ApiHideProperty() not being composable the developer experience is less than it could be.

Describe the solution you'd like

The optimal - IMO - solution would be to add a class-transformer shim that scans for Expose like the class-validator shim does and extends the array of decorators (currently only ApiHideProperty) used to skip a property to include Exclude. I see this idea has been shutdown multiple times.

The other option would be to add a plugin configuration option hidePropertiesDecoratedWith that is an array of strings that will be ignored when the plugin is processing. The exclusion logic already exists (hidePropertyDecorator) and supports an array of strings. The plugin options are locally available in the method (visitPropertyNodeDeclaration) used to decide if a property is annotated or not.

Teachability, documentation, adoption, migration strategy

No response

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

Using class-transformer for validation and serialization is at the core of NestJS it would be great to improve the DE so the swagger module is intergraded with these core concepts. Also, selfishly I'm sick of seeing @Exclude() and @ApiHideProperty side-by-side or missing @ApiHideProperty and the property being shown in the documentation.

I'm happy to do a PR to support either or both of these changes.

@kurt-west kurt-west changed the title Support @Expse and @Exclude or allow custom @ApiHideProperty() decorators Support @Expose and @Exclude or allow custom @ApiHideProperty() decorators Sep 5, 2023
@kurt-west kurt-west changed the title Support @Expose and @Exclude or allow custom @ApiHideProperty() decorators Support @Expose() and @Exclude() or allow custom @ApiHideProperty() decorators Sep 5, 2023
@kamilmysliwiec
Copy link
Member

The optimal - IMO - solution would be to add a class-transformer shim that scans for Expose like the class-validator shim does and extends the array of decorators (currently only ApiHideProperty) used to skip a property to include Exclude. I see this idea has been shutdown multiple times.

Would you like to create a PR for this issue?

@kurt-west
Copy link
Contributor Author

kurt-west commented Sep 11, 2023

The optimal - IMO - solution would be to add a class-transformer shim that scans for Expose like the class-validator shim does and extends the array of decorators (currently only ApiHideProperty) used to skip a property to include Exclude. I see this idea has been shutdown multiple times.

Would you like to create a PR for this issue?

I definitely can and will, thank you.

@mateussaggin
Copy link

This is indeed extremely necessary.
@kurt-west did you have the opportunity to take a look and crate the PR?

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

3 participants