Skip to content

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

@ViktorPontinen

Description

@ViktorPontinen

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingopenapi-fetchRelevant to the openapi-fetch library

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions