Is there an existing issue for this?
Current behavior
I'm trying to implement a custom versioning pattern (some modules use path and some header) with multiple documents served per version. My plan is to include all of the metadata that I need in the operationId and then do the filtering per document in patchDocumentOnRequest function.
I found a bug in the "operationIdFactory", where it only receives version parameter from path versioning.
Take a look at this example:
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
getHello(): string {
return this.appService.getHello();
}
@Get()
@Version('2')
getHelloV2(): string {
return this.appService.getHello();
}
}
app.enableVersioning({
type: VersioningType.CUSTOM,
defaultVersion: '1',
extractor(request) {
return '1.0'; // irrelevant for the example
}
});
const documentOptions = new DocumentBuilder()
.setTitle(`repro | OpenAPI`)
.setVersion('1.0')
.build();
SwaggerModule.createDocument(app, documentOptions, {
operationIdFactory: (controllerKey, methodKey, version) => {
const opId = `${controllerKey}_${methodKey}_${version}`;
console.log(opId); // AppController_getHelloV2_undefined
return opId;
}
});
It seems that it is hardcoded that the only version that is being passed to the 'getOperationId' function is the pathVersion, ignoring method and controller versions:
|
operationId: this.getOperationId(instance, methodKey, pathVersion), |
Minimum reproduction code
https://github.com/triforcely/nest-js-operationifactorybug
Steps to reproduce
No response
Expected behavior
When any api versioning is present, the parameter shouldn't be undefined.
Package version
11.0.3
NestJS version
11.0.5
Node.js version
22.13.0
In which operating systems have you tested?
Other
No response
Is there an existing issue for this?
Current behavior
I'm trying to implement a custom versioning pattern (some modules use path and some header) with multiple documents served per version. My plan is to include all of the metadata that I need in the operationId and then do the filtering per document in
patchDocumentOnRequestfunction.I found a bug in the "operationIdFactory", where it only receives version parameter from path versioning.
Take a look at this example:
It seems that it is hardcoded that the only version that is being passed to the 'getOperationId' function is the pathVersion, ignoring method and controller versions:
swagger/lib/swagger-explorer.ts
Line 387 in e949cef
Minimum reproduction code
https://github.com/triforcely/nest-js-operationifactorybug
Steps to reproduce
No response
Expected behavior
When any api versioning is present, the parameter shouldn't be undefined.
Package version
11.0.3
NestJS version
11.0.5
Node.js version
22.13.0
In which operating systems have you tested?
Other
No response