Parenthesis in path is included in parameter
gtflip opened this issue · comments
This is for a third-party API, so I don't have control over the API. One of the paths is "/api/v1/odata/Jobs(:Id)". In the "params" object, it has a key of "Id)". I generated the code with openapi-zod-client. I simplified the swagger file to just one of the paths with that format.
import { makeApi, Zodios, type ZodiosOptions } from "@zodios/core";
import { z } from "zod";
const endpoints = makeApi([
{
method: "get",
path: "/api/v1/odata/Jobs(:Id)",
alias: "Job_GetById",
requestFormat: "json",
parameters: [
{
name: "Id",
type: "Path",
schema: z.number(),
},
],
response: z.void(),
},
]);
export const api = new Zodios(endpoints);
export function createApiClient(baseUrl: string, options?: ZodiosOptions) {
return new Zodios(baseUrl, endpoints, options);
}
When I use it, "Id)" is the completion vscode gives me instead of "Id". Removing the parenthesis gives me an error.
const client = createApiClient("");
await client.Job_GetById({ params: { "Id)": "1234" } });
can you try adding a // @ts-expect-error
and see if it's just a compile time issue and if at runtime it works when removing the )
?
I was having problems getting an API token, but now that I have, I tried it with { Id: 1000 }
and it worked properly. So, it's just a type problem.
If it had the correct key, would it also be restricted to number?
Thanks!
This is now fixed in @zodios/core
v10.9.3