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

Query params shouldn't accept Record<string, unknown> #1247

Open
jpenna opened this issue Nov 7, 2024 · 5 comments
Open

Query params shouldn't accept Record<string, unknown> #1247

jpenna opened this issue Nov 7, 2024 · 5 comments
Labels
bug 🔥 Something isn't working prioritized 🚚 This issue has been prioritized and will be worked on soon
Milestone

Comments

@jpenna
Copy link

jpenna commented Nov 7, 2024

Description

The lib is generating a union with Record<string, unknown> for query parameters, which doesn't throw type errors when the query schema changes.

  • If one doesn't set any query parameters in the schema, it should have type never.
  • If one sets query parameters, it should only accept the configured schema.

I realized it also happens for body if it isn't defined (check the sample code). I think it should be never when it isn't defined.

Maybe add a configuration like --use-never to default any unset value to never.

Reproducible example or configuration

Check App.tsx:73

https://stackblitz.com/edit/hey-api-client-fetch-example-ssbzuv?file=src%2FApp.tsx&view=editor

OpenAPI specification (optional)

Use the example above.

System information (optional)

@hey-api/openapi-ts: v0.53.6

@jpenna jpenna added the bug 🔥 Something isn't working label Nov 7, 2024
Copy link

stackblitz bot commented Nov 7, 2024

@mrlubos
Copy link
Member

mrlubos commented Nov 7, 2024

Hi @jpenna, can you try with the experimental parser? I think it might be fixed there https://heyapi.dev/openapi-ts/configuration.html#parser

@mrlubos mrlubos added the info needed ❓ Further information is required label Nov 8, 2024
@jpenna
Copy link
Author

jpenna commented Nov 9, 2024

@mrlubos Will try it Monday!

@jpenna
Copy link
Author

jpenna commented Nov 18, 2024

Hello @mrlubos , I just upgraded to the latest version 0.53.12 and added the option for the parser (it is actually experimental_parser with underscore, according to the types).

But it is still including the Record<string, unknown>

 path: Record<string, unknown> & {
    threadId: string;

@mrlubos mrlubos added this to the Parser milestone Nov 18, 2024
@mrlubos mrlubos added prioritized 🚚 This issue has been prioritized and will be worked on soon and removed info needed ❓ Further information is required labels Nov 18, 2024
@mrlubos
Copy link
Member

mrlubos commented Nov 18, 2024

Thanks for confirming, will fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working prioritized 🚚 This issue has been prioritized and will be worked on soon
Projects
None yet
Development

No branches or pull requests

2 participants