You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
As a practical development, to use a RegExp it is common that it is itself except in some global constant of the solution and then it is used in all applications.
The problem is that to export this RegExp, @ApiProperty({ pattern }) does not need to be converted to a string and then remove the initial and final bars as well.
It is a common behavior to specify converting the RegExp to string and removing the initial and final bars, and, as it is also possible to identify the type of the value attributed in a pattern using the options.pattern instanceof RegExp, I believe that it is simple to implement the behavior of using RegExp in this field. A possible solution is a simple addition here:
// lib/decorators/api-property.decorator.tsexportfunctioncreateApiPropertyDecorator(options: ApiPropertyOptions={},overrideExisting=true): PropertyDecorator{if(options.patterninstanceofRegExp){options.pattern=options.pattern.toString().slice(1,-1);}const[type,isArray]=getTypeIsArrayTuple(options.type,options.isArray);// ... rest of code here
Uh oh!
There was an error while loading. Please reload this page.
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
As a practical development, to use a RegExp it is common that it is itself except in some global constant of the solution and then it is used in all applications.
The problem is that to export this RegExp, @ApiProperty({ pattern }) does not need to be converted to a string and then remove the initial and final bars as well.
Describe the solution you'd like
It is a common behavior to specify converting the RegExp to string and removing the initial and final bars, and, as it is also possible to identify the type of the value attributed in a pattern using the
options.pattern instanceof RegExp
, I believe that it is simple to implement the behavior of using RegExp in this field. A possible solution is a simple addition here:Teachability, documentation, adoption, migration strategy
The developers will be define properties passing the pattern in ApiProperty decorator as RegExp directly without adjust like:
What is the motivation / use case for changing the behavior?
Simplify use an coding experience of
@nestjs/swagger
package to developersThe text was updated successfully, but these errors were encountered: