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
feat: support metadata #411
base: main
Are you sure you want to change the base?
Conversation
…ish, nonNullishAsync, nonOptional, and nonOptionalAsync schemas
…redAsync, pickAsync, and merge methods
Thank you for creating this PR. I will review it in the next weeks. |
I will review this PR this week or next week. But I am still not sure if I want to merge it. |
@fabian-hiller Thank you! I think metadata is an essential feature, and both yup and zod support it. Do you think metadata needs to be discussed in more depth in terms of implementation? Do we need to consider the placement of metadata settings or the built-in metadata field? |
I am currently focused on other stuff. I will get back to you on the weekend or next week. |
b997a0f
to
6d0cde4
Compare
Metadata would be super nice for exporting schemas to other formats like OpenAPI. |
Can you make an example with dummy code? |
Implements #373
All schema functions accept the metadata argument:
message
.any()
,unknown()
,recursive()
The metadata argument has been added to the following method:
merge()
omit()
partial()
pick()
required()
Use
isSchema
inrestAndDefaultArgs
to distinguish whether an object is a valid schema or metadata.Currently only the
description
field has been added to the metadata.We can either follow the json-schema completely, or not pre-populate any fields like yup, or just a built-in
description
field like zod.