nestjsx / crud

NestJs CRUD for RESTful APIs
https://github.com/nestjsx/crud/wiki
MIT License
4.04k stars 533 forks source link

operationIdFactory from SwaggerDocumentOptions is ignored #759

Open yann510 opened 2 years ago

yann510 commented 2 years ago

I'm trying to override the default generated operationIds using the SwaggerDocumentOptions:

const swaggerConfig = new DocumentBuilder().setTitle("Stator").setDescription("The stator API description").setVersion("1.0").build()
const swaggerOptions: SwaggerDocumentOptions = {
  operationIdFactory: (controllerKey, methodKey) => {
    const entityName = `${methodKey.includes("Many") ? "" : "s"}Controller`

    return methodKey.includes("Base")
      ? `${methodKey.replace("Base", controllerKey.replace(entityName, ""))}`
      : `${methodKey}${entityName}`
  },
}
const document = SwaggerModule.createDocument(app, swaggerConfig, swaggerOptions)

It works for all my controllers which are not using the @nestjsx/crud to generate the endpoints.