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

Feature/zod Alpha support for generating zod schemas #161

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

Conversation

Zambonilli
Copy link

@Zambonilli Zambonilli commented Aug 6, 2024

#160

A new ILanguage implementation for generating typescript Zod schemas. The ILanguage implementation outputs a single file that exports a zod schema for each FHIR complex. In addition, a FhirResourceSchema that is a Zod union type is created for polymorphic scenarios like Bundle.

I list this code as alpha code because while I've been able to successfully validate all FHIR r4 examples successfully, the code is missing some functionality and has not been used in production.

Known Missing Features

  • support for validating code systems
  • exclusive or support for mutually exclusive fields like value* and date*.
  • validations beyond structure like number or date constraints

Known Things I'd do before Production

  • performance test the egregious use of zod lazy
  • performance test bundle (is zod validating all items against all schemas in O(n*m) time or is it smart enough to realize resourceType is the discriminator)

@Zambonilli
Copy link
Author

@microsoft-github-policy-service agree

@GinoCanessa
Copy link
Contributor

Hi Mike, thank you for doing a pass of this! We are getting close to merging in a major refactoring of the internals that is in the experimental branch right now (I am hoping for either later this week or next).

Do you want me to make a pass at converting this over to the new structure or would you?

Thanks again!

@Zambonilli
Copy link
Author

Oh cool, no worries on timing here and I'll watch for the experimental branch refactoring to merge to main and update this PR afterwards.

@GinoCanessa
Copy link
Contributor

That sounds great, thanks!

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

Successfully merging this pull request may close these issues.

2 participants