-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
I've copied the output of the standard PetStore example into a TypeScript playground.
At the end, I've created an api and tried to invoke findByStatus
:
const api = createApiClient((method, url, params) =>
fetch(url, { method, body: JSON.stringify(params) }).then((res) => res.json()),
);
api.get("/pet/findByStatus");
The error you'll see is:
Expected 2 arguments, but got 1.(2554)
input.tsx(316, 5): Arguments for the rest parameter 'params' were not provided.
When looking at the type of that function, config
is indeed required:
(method) ApiClient.get<"/pet/findByStatus", Endpoints.get_FindPetsByStatus>(path: "/pet/findByStatus", config: {
query: Partial<{
status: "available" | "pending" | "sold";
}>;
}): Promise<Schemas.Pet[]>
However, running the same code in the typed-openapi
playground shows the whole config as optional:
const api = createApiClient((method, url, params) =>
fetch(url, { method, body: JSON.stringify(params) }).then((res) => res.json()),
);
api.get("/pet/findByStatus");
I'm not sure where that difference is coming from, but it seems that I have to pass { query: {} }
to satisfy typescript right now and I don't think that is correct :)
Metadata
Metadata
Assignees
Labels
No labels