-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Unable to call delete since body is typed as never #469
Comments
this is a get path. You can call delete by passing undefined for body and it should work. |
Sorry, pasted the wrong schema, here's the correct one: {
method: 'delete',
path: '/api/customers/:customerId/subscriptions/:subscriptionId/resources/intunefourme/:resourceId',
requestFormat: 'json',
parameters: [
{
name: 'customerId',
type: 'Path',
schema: z.string().uuid()
},
{
name: 'subscriptionId',
type: 'Path',
schema: z.string().uuid()
},
{
name: 'resourceId',
type: 'Path',
schema: z.string().uuid()
}
],
response: z.void()
}, |
Update, I created a new project with just zodios and an empty schema and added the faulting endpoint, which worked. Then added the other endpoints one by one, when I added another delete endpoint which had a body defined, I got the error again: import { makeApi, Zodios, ZodiosPathsByMethod, type ZodiosOptions } from "@zodios/core";
import { z } from "zod";
const DeleteRoleAssignmentCommand = z.object({ tenantId: z.string().uuid(), objectId: z.string().uuid() });
const endpoints = makeApi([
{
method: "delete",
path: "/api/customers/:customerId/",
requestFormat: "json",
parameters: [
{
name: "customerId",
type: "Path",
schema: z.string().uuid(),
}
],
response: z.void(),
},
{
method: "delete",
path: "/api/customers/:customerId/roleassignments/:roleId",
requestFormat: "json",
parameters: [
{
name: "body",
type: "Body",
schema: DeleteRoleAssignmentCommand,
},
{
name: "roleId",
type: "Path",
schema: z.string().uuid(),
},
{
name: "customerId",
type: "Path",
schema: z.string(),
},
],
response: z.void(),
},
]);
export const api = new Zodios(endpoints);
export function createApiClient(baseUrl: string, options?: ZodiosOptions) {
return new Zodios(baseUrl, endpoints, options);
}
const client = createApiClient("http://localhost:3000/");
client.delete("/api/customers/:customerId/", undefined, { params: { customerId: "123", subscriptionId: "456", resourceId: "789" } }); @ecyrbe Do you want me to open a new issue for this since you closed it? |
If you have a body, put the body instead of undefined. |
Ok, so to be clear I have endpoint A that accepts a body and endpoint B that doesn't accept a body. I want to call endpoint B, |
ok, i reproduced the issue. it's triggered in some specific use cases. fix incoming. |
can you check new version |
Yes, it works fine now. Thanks for the quick response and fix! 🚀 |
Given the schema below, I am unable to call delete on it since the data param is typed as never.
Schema
The text was updated successfully, but these errors were encountered: