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

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

Open
2 tasks done
karlismelderis-mckinsey opened this issue Nov 6, 2024 · 3 comments
Open
2 tasks done

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

karlismelderis-mckinsey opened this issue Nov 6, 2024 · 3 comments

Comments

@karlismelderis-mckinsey
Copy link

Did you read the migration guide?

  • I have read the whole migration guide

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

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
Copy link

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

@micalevisk
Copy link
Member

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

why reproductions are required

@pelssersconsultancy
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants