Allow overriding each of endpointDefinition with a callback function
imballinst opened this issue · comments
Hello, thanks for creating this library!
I want to request to add 2 new fields here: operationId
and security
, because these 2 fields can exist in the Operation object.
openapi-zod-client/lib/src/getZodiosEndpointDefinitionList.ts
Lines 154 to 163 in 8fdb58f
It's either that, or make us able to pass a callback function, something like:
endpointDefinitionRefiner: (defaultDefinition: EndpointDefinitionWithRefs, operation: OperationObject) => ({
...defaultDefinition,
security: operation.security,
operationId: operation.operationId
})
So the thing above becomes:
const defaultDefinition: EndpointDefinitionWithRefs = {
method: method as EndpointDefinitionWithRefs["method"],
path: replaceHyphenatedPath(path),
...(options?.withAlias && { alias: operationName }),
description: operation.description,
requestFormat: "json",
parameters: [],
errors: [],
response: "",
}
const endpointDefinition = endpointDefinitionRefiner ? endpointDefinitionRefiner(defaultDefinition) : defaultDefinition
I can submit a PR as well, if possible.
I suppose you're not using zodios; and are only using openapi-zod-client
to convert to zod schemas ?
I like the callback version as it looks more future-proof
I can submit a PR as well, if possible.
go for it ! Don't forget to add a dedicated test + a changeset
I suppose you're not using zodios; and are only using openapi-zod-client to convert to zod schemas ?
That is correct, yeah. I want to generate the boilerplates with koa and hence I can't use the zodios one.
I like the callback version as it looks more future-proof
go for it ! Don't forget to add a dedicated test + a changeset
Alright, I'll see what I can do, thanks @astahmer for the quick response!