diff --git a/lib/plugin/merge-options.ts b/lib/plugin/merge-options.ts index 97aff50a6..d3b6c5b67 100644 --- a/lib/plugin/merge-options.ts +++ b/lib/plugin/merge-options.ts @@ -13,6 +13,10 @@ export interface PluginOptions { pathToSource?: string; debug?: boolean; parameterProperties?: boolean; + /** + * Skip auto-annotating controller methods with HTTP status codes (e.g., @HttpCode(201)) + */ + skipAutoHttpCode?: boolean; } const defaultOptions: PluginOptions = { diff --git a/lib/plugin/visitors/controller-class.visitor.ts b/lib/plugin/visitors/controller-class.visitor.ts index 70349c312..87bb1f9f5 100644 --- a/lib/plugin/visitors/controller-class.visitor.ts +++ b/lib/plugin/visitors/controller-class.visitor.ts @@ -397,12 +397,14 @@ export class ControllerClassVisitor extends AbstractFileVisitor { compilerOptionsPaths: ts.MapLike ): ts.ObjectLiteralExpression { let properties = []; - if (!options.readonly) { + + if (!options.readonly && !options.skipAutoHttpCode) { properties = properties.concat( existingProperties, this.createStatusPropertyAssignment(factory, node, existingProperties) ); } + properties = properties.concat([ this.createTypePropertyAssignment( factory,