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

Error types no longer strongly typed #618

Closed
bruceharrison1984 opened this issue May 24, 2024 · 4 comments · Fixed by #635
Closed

Error types no longer strongly typed #618

bruceharrison1984 opened this issue May 24, 2024 · 4 comments · Fixed by #635
Labels
bug 🔥 Something isn't working

Comments

@bruceharrison1984
Copy link

bruceharrison1984 commented May 24, 2024

Description

After upgrading to the newer @hey-api/client-fetch, the data object is correctly typed, but the error type is now untyped (previously it was correctly typed)

image

Spec

...
"schema":{
      "ErrorPayload": {
        "type": "object",
        "properties": {
          "message": { "type": "string" },
          "detail": { "type": "string" },
          "status": { "type": "number" },
          "stack": { "type": "string" }
        },
        "required": ["message", "status"]
      },
...

"paths": {
    "/resources/users": {
      "get": {
        "tags": ["Users"],
        "security": [{ "Bearer": [] }],
        "parameters": [
          {
            "schema": { "type": "number" },
            "required": true,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": { "type": "number" },
            "required": true,
            "name": "offset",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "array of Users",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/UsersResult" }
                }
              }
            }
          },
          "4XX": {
            "description": "common error response",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorPayload" }
              }
            }
          }
        }
      },
...

This is easy enough to work-around by forcibly casting the objects, but I presume this is an oversight.

@mrlubos
Copy link
Contributor

mrlubos commented May 27, 2024

I am actually surprised this worked before the standalone client. Either way, I think it's because of the 4XX status code. I am adding support for such codes in the next release, please let me know if that fixes it for you!

@kostia1st
Copy link

I am adding support for such codes in the next release

Just a note, schemas comprised of numbers only also have issues - they don't generate into compilable code

Code_Qz8prvGWAM
Code_u2Nu9ZFZE5

@mrlubos
Copy link
Contributor

mrlubos commented May 30, 2024

@kostia1st that sounds like a separate issue no?

@kostia1st
Copy link

@mrlubos yep, just created one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants