digikare / nestjs-prom

A prometheus module for nestjs
160 stars 54 forks source link

PromMethodCounter decorator breaks swagger documentation #18

Open HansG89 opened 4 years ago

HansG89 commented 4 years ago

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, ApiResponseand 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 commented 4 years ago

Could you please tell me which packages version you have for

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

HansG89 commented 4 years ago

Hi,

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

dependencies:

dev dependencies:

HansG89 commented 4 years ago

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

spike008t commented 3 years ago

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

danshapir commented 3 years ago

still not working with latest versions of everything