nestjsx / crud

NestJs CRUD for RESTful APIs

Home Page:https://github.com/nestjsx/crud/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

operationIdFactory from SwaggerDocumentOptions is ignored

yann510 opened this issue · comments

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.