nestjs / swagger

OpenAPI (Swagger) module for Nest framework (node.js) :earth_americas:

Home Page:https://nestjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ReadonlyVisitor is missing controller typeImports

antischematic opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

In nest/swagger@7.0.6 the ReadonlyVisitor typeImports property only returns modelClassVisitor typeImports. As a result the generated metadata.ts file is missing type declarations when using PluginMetadataGenerator:

/* eslint-disable */
export default async () => {
  const t = {};
  return {
    '@nestjs/swagger': {
      models: [
        [
          import('./app/data.dto'),
          {
            DataDto: {
              message: { required: true, type: () => String },
              hello: { required: true, type: () => Number, maximum: 10 },
            },
          },
        ],
      ],
      controllers: [
        [
          import('./app/app.controller'),
          { AppController: { getData: { type: t['./app/data.dto'].DataDto } } },
        ],
      ],
    },
  };
};

The t['./app/data.dto'].DataDto reference is missing.

Minimum reproduction code

https://gist.github.com/antischematic/92cc02b9a071731d62d2ab10cfe457e7

Steps to reproduce

No response

Expected behavior

The ReadonlyVisitor should also return controllerClassVisitor typeImports

Current:

class ReadonlyVisitor {
    get typeImports() {
        return this.modelClassVisitor.typeImports
    }

Proposed

class ReadonlyVisitor {
    get typeImports() {
        return {
          ...this.modelClassVisitor.typeImports,
          ...this.controllerClassVisitor.typeImports
        };

Package version

7.0.6

NestJS version

No response

Node.js version

No response

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Fixed in 7.0.7, thanks for reporting!