[Feature Request] Generate schemas dynamically from request
brettdh opened this issue · comments
I have an API that adheres to the jsonapi.org spec, and I'm attempting to describe it with Zodios. One semantic detail that's proven hard to capture is sparse fieldsets, where the set of fields returned is controlled by a query parameter. Since response schemas are static in Zodios when defining an API, I end up having to mark all fields as .optional()
if I want to exclude them from the fieldset in any request context.
I haven't thought this all the way through, but I wonder if there's a way to enable schema refinement based on the input parameters to a query. I'm very new to Typescript and Zod, so I thought I'd create this issue fairly open-ended and see if it sparks any ideas (or reveals any workarounds).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Still interested in feedback here.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Stiiiiill interested in feedback.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
🏓
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Last try. 🏓
Maybe using a zodios plugin
: here
In the response object, get requested fields, and return a object with filtered keys
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.