Skip to content

Commit

Permalink
Merge pull request #3151 from nestjs/feat/skip-http-code-annotation
Browse files Browse the repository at this point in the history
feat: allow skipping auto http code annotation
  • Loading branch information
kamilmysliwiec authored Nov 7, 2024
2 parents 647c0a6 + 7dd6759 commit 55f2a39
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/plugin/merge-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 3 additions & 1 deletion lib/plugin/visitors/controller-class.visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,14 @@ export class ControllerClassVisitor extends AbstractFileVisitor {
compilerOptionsPaths: ts.MapLike<string[]>
): 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,
Expand Down

0 comments on commit 55f2a39

Please sign in to comment.