Skip to content

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

@cobyforrester

Description

@cobyforrester

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions