#@Nestjs/swagger does not resolve paths correctly

6 messages · Page 1 of 1 (latest)

livid valve
#

I'm trying to use a class as a type coming from an external package. However while typescript resolves well the path, the package nestjs swagger is not able to do it :

const openapi = require("@nestjs/swagger");

const swagger_1 = require("@nestjs/swagger");


tslib_1.__decorate([
    (0, common_1.Post)(),

    openapi.ApiResponse({ status: 201, type: require("../../../../../../schema/api-partner/src/x-body.schema").XXX }),
    tslib_1.__param(0, (0, common_1.Query)()),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [schema_api_partner_1.XXX]),

I don't know where to start to look at. I'm expecting the import to be

   openapi.ApiResponse({ status: 201, type: [schema_api_partner_1.XXX] })

Is it an issue related to the package ?

red aspen
#

Can you show first of all what the typescript code looks like?

livid valve
#

Sure, this is the compilation of :

@Controller()
@ApiExcludeController()
export class FlightsMonitoringsController {


  @Post()
  @ApiProperty({ type: CreateFlightMonitoringResBody })

  public async create(): Promise<CreateFlightMonitoringResBody> {


The type CreateFlightMonitoringResBody is a class that comes from another package of my monorepo. In the ApiProperty part seem well imported :

    (0, swagger_1.ApiProperty)({ type: schema_api_1.CreateFlightMonitoringResBody }),
    openapi.ApiResponse({ status: 201, type: require("../../../../../../schema/api/src/resources/create-flight-monitoring/create-flight-monitoring-res-body.schema").CreateFlightMonitoringResBody }),

The issue remains in the openapi import

livid valve
red aspen
#

Interesting that the require() gets set there instead of at the top of the transpiled file

#

I wonder if that comes from the Swagger Plugin CLI from @nestjs/swagger