Skip to content
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

to-json-schema: Add option to provide input schema for effects #1002

Open
bdashore3 opened this issue Dec 28, 2024 · 2 comments
Open

to-json-schema: Add option to provide input schema for effects #1002

bdashore3 opened this issue Dec 28, 2024 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@bdashore3
Copy link

Hi there, I'm trying to move away from Zod to Valibot, but I've hit a snag when generating OpenAPI defintions.

My schemas heavily rely on transform operations for validation, but I'm getting an error that states Error: The "transform" action cannot be converted to JSON Schema.. This is highlighted in the docs and I understand why that's the case. However, there are ways around this that can be explored.

For example, the zod-openapi package gets around this by allowing the user to set effectType to "input" which takes the non-transformed defintion and builds the schema from there. It does this by default when new effects are provided (see: rhinobase/hono-openapi#3)

I'd suggest that valibot should do the same, or even does this by default if a transform operation is detected. That way, the JSON schema package becomes usable for almost any situation.

@bdashore3 bdashore3 changed the title to-json-schema: Add option to to-json-schema: Add option to provide input schema for effects Dec 28, 2024
@bdashore3
Copy link
Author

Also, using 'warn' when running toJsonSchema seems to ignore the failed actions and still produces a valid JSON schema. However, it may be good to look into warning by default on a transform.

@fabian-hiller fabian-hiller self-assigned this Dec 29, 2024
@fabian-hiller fabian-hiller added the question Further information is requested label Dec 29, 2024
@fabian-hiller
Copy link
Owner

What exactly does Zod's toJsonSchema function do when this option is enabled? I would guess it does exactly the same thing as our errorMode option when set to 'warn' or 'ignore'. Are you basically asking to introduce a new option to override/define errorMode specifically for transformations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants