Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PromMethodCounter decorator breaks swagger documentation #18

Open
HansG89 opened this issue Nov 14, 2019 · 5 comments
Open

PromMethodCounter decorator breaks swagger documentation #18

HansG89 opened this issue Nov 14, 2019 · 5 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@HansG89
Copy link

HansG89 commented Nov 14, 2019

When using the PromMethodCounter decorator on a controller function it will break the API documentation beginning from the line where the decorator was added.

Example

The following code generates API documentation for ApiOperation, ApiResponse and Data.
But it will not generate documentation for the query parameters.

    @Get()
    @ApiOperation({ title: 'Get something by query string' })
    @ApiResponse({ status: 200, type: Data, description: 'List of Data objects' })
    @PromMethodCounter()
    public async getAllData(@Query() query: GetByQuery): Promise<Data[]> {
        this.logger.info(`GET / by query`);
        return await this.dataService.loadAllData().toPromise();
    }

When I switch the order of decorators, only the basic documentation for the GET function is generated. Everything else is missing (also the model for Data)

    @Get()
    @PromMethodCounter()
    @ApiOperation({ title: 'Get something by query string' })
    @ApiResponse({ status: 200, type: Data, description: 'List of Data objects' })
    public async getAllData(@Query() query: GetByQuery): Promise<Data[]> {
        this.logger.info(`GET / by query`);
        return await this.dataService.loadAllData().toPromise();
    }

When I remove PromMethodCounter the API documentation is working as expected.

@spike008t spike008t self-assigned this Dec 18, 2019
@spike008t spike008t added the bug Something isn't working label Dec 18, 2019
@spike008t
Copy link
Contributor

Could you please tell me which packages version you have for

  • @nestjs/*
  • @nestjs/swagger

I just give a try with latest versions of nestjs and swagger with the latest v0.2.2, all seems works correctly.

@HansG89
Copy link
Author

HansG89 commented Jan 7, 2020

Hi,

I updated all packages recently. But the problem is still there.

dependencies:

  • "@nestjs/common": "^6.10.14",
  • "@nestjs/core": "^6.10.14",
  • "@nestjs/platform-express": "^6.10.14",
  • "@nestjs/swagger": "^4.1.1",
  • "@nestjs/typeorm": "^6.2.0",

dev dependencies:

  • "@nestjs/cli": "^6.13.1",
  • "@nestjs/schematics": "^6.7.6",
  • "@nestjs/testing": "6.10.14",

@HansG89
Copy link
Author

HansG89 commented Aug 10, 2020

The problem is still there with the latest 7.x version of nestjs and "@nestjs/swagger": "^4.5.12"

@spike008t
Copy link
Contributor

Could you provide me a git sample project to reproduce it?
Otherwise, could you try with the latest v1.0.0 available ?

@spike008t spike008t added the question Further information is requested label Oct 23, 2020
@danshapir
Copy link

still not working with latest versions of everything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants