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

Correctly defined 204 will return Response does not have a Content-Type header #480

Open
dtrunk90 opened this issue Nov 25, 2022 · 0 comments

Comments

@dtrunk90
Copy link

Describe the bug
Based on https://swagger.io/docs/specification/describing-responses/ (Empty Response Body) the definition for 204 should look like this:

{
  ...,
  "paths": {
    "/tests": {
      "get": {
        "tags": [
          "test-controller"
        ],
        "operationId": "getTests",
        "parameters": [...],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Test"
                  }
                }
              }
            }
          },
          "204": {
            "description": "Empty list"
          },
          "502": {
            "description": "Invalid Response",
            "content": {
              "application/json": {}
            }
          },
          "504": {
            "description": "No Response",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    }
  },
  ...
}

But in that case I get the following error:

{
  "data": null,
  "errors": [
    {
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR"
      },
      "locations": [
        {
          "column": 17,
          "line": 1
        }
      ],
      "message": "Response does not have a Content-Type header",
      "path": [
        "tests"
      ]
    }
  ]
}

There's indeed no Content-Type header since there's no Content.

To Reproduce
Steps to reproduce the behavior:
See above

Expected behavior
No error should occur

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

No branches or pull requests

1 participant