nestjs / terminus

Terminus module for Nest framework (node.js) :robot:
https://nestjs.com/
MIT License
677 stars 99 forks source link

update "@nestjs/swagger" to `8.x` #2563

Open karlismelderis-mckinsey opened 6 days ago

karlismelderis-mckinsey commented 6 days ago

Did you read the migration guide?

Is there an existing issue that is already proposing this?

Potential Commit/PR that introduced the regression

No response

Versions

No response

Describe the regression

Now when @nestjs/swagger got new major version @nestjs/terminus fails to generate correct API spec

Minimum reproduction code

// this get's attached to controller function
function ApiHealthCheckEndpoint({
  path,
  summary,
  description,
}: PawApiHealthEndpointContext) {
  const decorators: MethodDecorator[] = [
    HttpCode(HttpStatus.OK),
    RequestMapping({ path, method: RequestMethod.GET }),
    ApiOperation({ description, summary }),
    HealthCheck(),
  ];

  return applyDecorators(...decorators);
}

ApiOperation is from @nestjs/swagger:8.0.2 and HealthCheck is from @nestjs/terminus:10.2.3

generated API spec has "schema" key that's failing OpenAPI spec validation

    "/search/health/ready": {
      "get": {
        "operationId": "HealthController_ready",
        "summary": "Readiness check",
        "description": "This endpoint returns readiness information of the service",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The Health Check is successful",
            "schema": { // Exact duplicate as under content."application/json"
              "type": "object",
              "properties": {}
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "503": {
            "description": "The Health Check is not successful",
            "schema": { // Exact duplicate as under content."application/json"
              "type": "object",
              "properties": {}
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          }
        },
        "tags": [
          "Service health"
        ]
      }
    },

Expected behavior

I expect to get correct API spec generated 🙏

Other

No response

pelssersconsultancy commented 6 days ago

We run into the same issue Screenshot 2024-11-06 at 14 24 55

micalevisk commented 6 days ago

Please provide a minimum reproduction repository. You can start one by running npm init nest in your terminal

why reproductions are required

pelssersconsultancy commented 6 days ago

nestjs-app.zip

I uploaded a newly created project with minimal dependencies: nestjs swagger and terminus. If you start the app I write the swagger to the dist folder. Try importing the generated swagger in https://editor.swagger.io/ and you can see the issue