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

Bug: Server accepts invalid response type + doesn't validate output #105

Open
mgm1313 opened this issue Sep 23, 2024 · 0 comments
Open

Bug: Server accepts invalid response type + doesn't validate output #105

mgm1313 opened this issue Sep 23, 2024 · 0 comments

Comments

@mgm1313
Copy link

mgm1313 commented Sep 23, 2024

Given this operation:

  /healthz:
    get:
      operationId: healthCheck
      tags:
        - system
      summary: Health check endpoint
      description: Check if the API is up and running
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "OK"

And this implementation

import * as api from "generated";

export const healthCheck: api.server.HealthCheckOperationHandler<{}> =
  async () => {
    return [200, "OK"];
  };

The client receives this response:

HTTP/1.1 200 OK
Connection: close
Content-Type: application/json
Date: Mon, 23 Sep 2024 08:41:06 GMT
Transfer-Encoding: chunked

[200,"OK"]

I would expect:

  1. A typescript error because type string does not adhere to Record<'status', string>.
  2. An error response from the server

Am I missing something maybe?

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