Describe the feature
Currently paramsStyles and queryStyles are objects in the openapi() meta plugin. The problem here is that those values are coupled to the input schema. I was thinking that it might be easier to write those if orpc would allow those to also be notated by functions, where the function receives the current field name and the standard schema of the field. This way it would be much easier and shorter to define those styles for larger input objects. It would also be possible to define re-usable helper functions for all input which follows the same logic / styles.
oc.meta(openapi({
paramsStyle: (field, schema) => {
// since I know that my standard schema is zod, I can check whether the input schema field is ZodArray / Object or anything else
return isZodArray(schema) ? 'comma-delimited-array' : 'primitive';
}
})).input(
z.object({
params: z.object({
someArray: z.array(),
someValue: z.string(),
}),
});
As for metadata merging, in the case of a function the latest call would overwrite the whole function.
Additional information
Describe the feature
Currently
paramsStylesandqueryStylesare objects in theopenapi()meta plugin. The problem here is that those values are coupled to the input schema. I was thinking that it might be easier to write those iforpcwould allow those to also be notated by functions, where the function receives the current field name and the standard schema of the field. This way it would be much easier and shorter to define those styles for larger input objects. It would also be possible to define re-usable helper functions for all input which follows the same logic / styles.As for metadata merging, in the case of a function the latest call would overwrite the whole function.
Additional information