Skip to content

Commit 0836d84

Browse files
feat: allow skipping auto http code annotation #3150
1 parent 96259e6 commit 0836d84

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/plugin/merge-options.ts

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export interface PluginOptions {
1313
pathToSource?: string;
1414
debug?: boolean;
1515
parameterProperties?: boolean;
16+
/**
17+
* Skip auto-annotating controller methods with HTTP status codes (e.g., @HttpCode(201))
18+
*/
19+
skipAutoHttpCode?: boolean;
1620
}
1721

1822
const defaultOptions: PluginOptions = {

lib/plugin/visitors/controller-class.visitor.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,14 @@ export class ControllerClassVisitor extends AbstractFileVisitor {
397397
compilerOptionsPaths: ts.MapLike<string[]>
398398
): ts.ObjectLiteralExpression {
399399
let properties = [];
400-
if (!options.readonly) {
400+
401+
if (!options.readonly && options.skipAutoHttpCode) {
401402
properties = properties.concat(
402403
existingProperties,
403404
this.createStatusPropertyAssignment(factory, node, existingProperties)
404405
);
405406
}
407+
406408
properties = properties.concat([
407409
this.createTypePropertyAssignment(
408410
factory,

0 commit comments

Comments
 (0)