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
The openapi spec however does not wrap the responses properly with { result: <response-type> }.
Describe the solution you'd like
I understand that response transformers are a runtime construct, and that there is likely not a good way to magically infer these types and then have the plugin generate the proper decorations. However, I wonder if there might be a way to statically define a wrapper type for the plugin or the swagger module itself to use.
For instance, maybe we can provide a file name that specifies a generic class that can be used to wrap all response types in the plugin's generated decorations.
responseWrapper: "src/responseDecorator.ts"
responseDecorator.ts
export class SuccessResponse<ResponseType> {
result: ResponseType;
}
or maybe another possibility would be using the DocumentBuilder or options sent to SwaggerModule.createDocument?
The seems like it would be a fairly common use case that would make the CLI Plugin much more viable.
The documentation for the plugin options could be updated to include information about the responseWrapper field and there could be an example similar to the stuff in my problem statement and proposed solution.
What is the motivation / use case for changing the behavior?
I really love the plugin and really dislike boilerplate. Having this feature would mean that I can continue using the plugin without having to manually add @ApiResponse all over my code. This would boost my team's productivity while still giving us a way to effortlessly generate an open API spec for documentation and code generation purposes.
Without this, I will have to customize any code generation tools we use such that they are aware of the wrapped type and return data appropriately.
The text was updated successfully, but these errors were encountered:
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
My team absolutely loves using the CLI plugin for this module because it reduces so much boilerplate code! Thank you for the awesome feature.
The issue we're facing is that we use this interceptor:
The openapi spec however does not wrap the responses properly with
{ result: <response-type> }
.Describe the solution you'd like
I understand that response transformers are a runtime construct, and that there is likely not a good way to magically infer these types and then have the plugin generate the proper decorations. However, I wonder if there might be a way to statically define a wrapper type for the plugin or the swagger module itself to use.
For instance, maybe we can provide a file name that specifies a generic class that can be used to wrap all response types in the plugin's generated decorations.
responseDecorator.ts
or maybe another possibility would be using the
DocumentBuilder
or options sent toSwaggerModule.createDocument
?The seems like it would be a fairly common use case that would make the CLI Plugin much more viable.
Teachability, documentation, adoption, migration strategy
The documentation for the plugin options could be updated to include information about the
responseWrapper
field and there could be an example similar to the stuff in my problem statement and proposed solution.What is the motivation / use case for changing the behavior?
I really love the plugin and really dislike boilerplate. Having this feature would mean that I can continue using the plugin without having to manually add
@ApiResponse
all over my code. This would boost my team's productivity while still giving us a way to effortlessly generate an open API spec for documentation and code generation purposes.Without this, I will have to customize any code generation tools we use such that they are aware of the wrapped type and return data appropriately.
The text was updated successfully, but these errors were encountered: