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

feat: support metadata #411

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

xcfox
Copy link
Contributor

@xcfox xcfox commented Feb 4, 2024

Implements #373

  • All schema functions accept the metadata argument:

    • Most schemas accept this argument using the location of the message.
    • Additional metadata argument added for some special schemas. any(), unknown(), recursive()
  • The metadata argument has been added to the following method:

    • merge()
    • omit()
    • partial()
    • pick()
    • required()
  • Use isSchema in restAndDefaultArgs 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.

…ish, nonNullishAsync, nonOptional, and nonOptionalAsync schemas
@fabian-hiller
Copy link
Owner

Thank you for creating this PR. I will review it in the next weeks.

@fabian-hiller fabian-hiller self-assigned this Feb 4, 2024
@fabian-hiller fabian-hiller added the enhancement New feature or request label Feb 4, 2024
@fabian-hiller
Copy link
Owner

I will review this PR this week or next week. But I am still not sure if I want to merge it.

@xcfox
Copy link
Contributor Author

xcfox commented Feb 21, 2024

@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?

@fabian-hiller
Copy link
Owner

I am currently focused on other stuff. I will get back to you on the weekend or next week.

@jeremyjacob
Copy link

Metadata would be super nice for exporting schemas to other formats like OpenAPI.

@fabian-hiller
Copy link
Owner

Can you make an example with dummy code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants