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

Adding application/health+json as accepted Content-Type #386

Open
cobyforrester opened this issue Sep 26, 2022 · 0 comments
Open

Adding application/health+json as accepted Content-Type #386

cobyforrester opened this issue Sep 26, 2022 · 0 comments

Comments

@cobyforrester
Copy link

cobyforrester commented Sep 26, 2022

Hello, love the project idea, but while looking to bring this into an existing codebase, I hit a snag where it was giving a 500 internal server error when using Content-Type application/health+json. I would like to follow the rfc health check endpoint spec https://inadarei.github.io/rfc-healthcheck/.

The yaml spec for the endpoint is:

  /api/health:
    get:
      summary: Healthcheck to determine health of API. 
      responses:
        200:
          description: The request's query parameters.
          content:
            application/health+json:
              schema: 
                type: object
                properties:
                  status:
                    type: string
                    example: "ok"
                  description:
                    type: string
                    example: Description of endpoint.
                  version:
                    type: string
                    example: "0.0.1"
                  releaseId:
                    type: string
                    example: "release-id"
                  notes:
                    type: array
                    items:
                      type: string
                    example: [""]
                  output:
                    type: string
                    example: "Output of error"

The curl logs are:

< HTTP/1.1 500 Internal Server Error
< X-Powered-By: Express
< openapi-cop-source-request: {"method":"GET","path":"/api/health","headers":{"host":"localhost:8888","user-agent":"curl/7.79.1","accept":"*/*"},"query":{}}
< openapi-cop-validation-result: {"request":{"valid":true,"errors":null}}
< Date: Mon, 26 Sep 2022 21:49:33 GMT
< Connection: keep-alive
< Content-Length: 0

The server logs with verbose set to 1 are:

2022-09-26T21:49:33.007Z openapi-cop:proxy Received server response with status code 200
2022-09-26T21:49:33.008Z openapi-cop:proxy Validation results [GET /api/health] 
{
  "request": {
    "valid": true,
    "errors": null
   }
 }

If I change the Content-Type to application/json in the response, I get a 200 response, with a openapi-cop-validation-result containing response and responseHeaders objects.

I would be open to contributing if needed.

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