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

Headers are not typed correctly when using openapi schema #98

Open
magnus-bb opened this issue Jan 25, 2025 · 1 comment
Open

Headers are not typed correctly when using openapi schema #98

magnus-bb opened this issue Jan 25, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@magnus-bb
Copy link

magnus-bb commented Jan 25, 2025

Environment

Reproduction

https://stackblitz.com/edit/github-xdmxkcqn?file=routes%2Ftest.get.ts

Type error can be seen when hovering the options object passed to $api(...) in the server/routes/test.get.ts file.

Describe the bug

openapi-typescript generates types based on the openapi schema which uses the singular form of headers (i.e. header instead). This seems to be used directly when typing the options you can pass to the $api function exposed by nuxt-api-party. This means, that a type error arises when I do something like the following:

  const res = await $api('/v1/auth/user/', {
    headers: {
      authorization: 'Bearer xyz',
    },
  });

The code works as intended, but the schema requires that the headers prop is called header instead, which will result in a runtime error since that is not how headers are passed to $api().

Additional context

No response

Logs

@johannschopplich
Copy link
Owner

Thanks for the report. PR welcome! ✨

@johannschopplich johannschopplich added bug Something isn't working and removed pending triage labels Jan 25, 2025
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

No branches or pull requests

2 participants