-
-
Notifications
You must be signed in to change notification settings - Fork 597
Closed
Labels
bugSomething isn't workingSomething isn't workingopenapi-fetchRelevant to the openapi-fetch libraryRelevant to the openapi-fetch library
Description
Description
I'm seeing an issue where generated typescript types result in some impossible types:
Type error: Argument of type '{ params: { path: { id: string; }; }; }' is not assignable to parameter of type 'FetchOptions<{ parameters: { path: { id: string; }; }; responses: ...snipped
Property 'body' is missing in type '{ params: { path: { id: string; }; }; }' but required in type '{ body: never; }'.
10 |
11 | async function exampleGet() {
> 12 | const { data, error } = await get(`/v1/endpoint`, {
| ^
13 | params: { path: { id: "todo" } },
14 | });
15 | }
I am able to work around it by adding a field body: "" as never, which seems to be forcing TS into the right path. body: undefined or body: null does not work either.
Reproduction
I used the latest versions of openapi-fetch, openapi-typescript, and an internal OpenAPI spec with only GETs in it.
Something relevant in the generated code seems to be:
export interface components {
...
responses: never;
parameters: never;
requestBodies: never; // <--
headers: never;
pathItems: never;
}
Expected result
I can work out the types in this scenario more easily.
Checklist
- I’m willing to open a PR (see CONTRIBUTING.md)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingopenapi-fetchRelevant to the openapi-fetch libraryRelevant to the openapi-fetch library