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

Argument of type '"/example/post-endpoint"' is not assignable to parameter of type 'PathsWithMethod<paths, "post">' #2021

Open
1 task
ViktorPontinen opened this issue Nov 27, 2024 · 0 comments
Assignees
Labels
bug Something isn't working openapi-fetch Relevant to the openapi-fetch library

Comments

@ViktorPontinen
Copy link

ViktorPontinen commented Nov 27, 2024

Description

A brief description of the bug. Provide either a screenshot or the full error message
When we use the --path-params-as-types flag with openapi-typescript to generate types, some post requests(seems to only affect post requests) stop being autocompleted/discovered and shows error:
Argument of type '"/example/post-endpoint"' is not assignable to parameter of type 'PathsWithMethod<paths, "post">'.

Example(ignore the untyped body):

export const createSomeEntity = async (body) => {
  return client.POST('/example/post-endpoint', {
    body,
  })
}

Without the --path-params-as-types flag, everything works as expected. Only difference I see in generated types is the adjustments to dynamic paths keys: [path: `/example/dynamic/${string}`]:.

Anyone else got same issue or just us?

Reproduction

How can this be reproduced / when did the error occur? Does the issue occur in a specific browser, or all browsers?
Not sure if reproducible in other repos, I guess try to regenerate your types with the --path-params-as-types flag. Will try to test outside our repo to test.

Expected result
I think description covers it's all.
(in case it’s not obvious)

Checklist

@ViktorPontinen ViktorPontinen added bug Something isn't working openapi-fetch Relevant to the openapi-fetch library labels Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi-fetch Relevant to the openapi-fetch library
Projects
None yet
Development

No branches or pull requests

2 participants