#Swagger ignores the global prefix

3 messages · Page 1 of 1 (latest)

errant heron
#

I've just added @nestjs/swagger to my project, but it ignores the global prefix I've set, even with that option explicitly disabled.

I wonder if there's an order needed for things to work ?

Here's my main.ts file

import { VersioningType } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  const config = new DocumentBuilder()
    .setTitle('API')
    .setDescription('API description')
    .setVersion('1.0')
    .build();

  const document = SwaggerModule.createDocument(app, config, {
    ignoreGlobalPrefix: false,
  });
  SwaggerModule.setup('/api/docs', app, document);

  app.enableCors();
  app.setGlobalPrefix('/api');
  app.enableVersioning({
    type: VersioningType.URI,
    defaultVersion: '1',
  });
  await app.listen(3000);
}

bootstrap();
#

Ok nevermind, discord decided to show me related threads on the second search only, sorry about that