I have the following as a metrics.controller.ts
file:
import { Controller, Get } from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiUseTags, ApiModelProperty } from '@nestjs/swagger';
import { PrometheusService } from './prometheus.service';
@Controller('metrics')
@ApiUseTags('Misc')
export class MetricsController {
constructor(private readonly prometheusService: PrometheusService) {}
@Get('/')
@ApiOperation({
title: 'Prometheus metrics',
description: 'Exposes default prometheus node metrics'
})
@ApiResponse({ status: 200, description: 'Prometheus metrics' })
public getMetrics(): string {
return this.prometheusService.getMetrics();
}
}
However Swagger incorrectly indicates a Response content type of application/json, when the actual output is text/plain:
I have tried looking at the Swagger docs regarding describing responses, and the item I am looking for is the 'content' portion. However, that doc does not cover the TypeScript annotations. The Swagger Core 2.X documentation talks about an @Operation
annotation, but I don't have a reference to that and I don't know where to get one--only @ApiOperation
works.
The relevant version information from npm ls
in the project directory is as follows:
+-- @nestjs/[email protected]
| +-- @nestjs/[email protected] deduped
| +-- @nestjs/[email protected] deduped
| +-- [email protected]
| +-- [email protected] deduped
| `-- [email protected]
What is the proper annotation to indicate a Response content type of text/plain?