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

[Deep] Parse JSON Schema to Builder/s to facilitate a hybrid approach to composition in Typescript #52

Closed
lburgess opened this issue Mar 11, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@lburgess
Copy link

Is your feature request related to a problem? Please describe.
Being able to use an existing JSON schema is certainly useful, however it does not appear that it is possible further modify the schema using the builder pattern. Both approaches are really useful independently, but would be so much more beneficial to a host of use cases which I have if it were possible to combine them.

Describe the solution you'd like
I would like to be able to write something along the lines of:

const composedSchema = s.jsonSchema(PERSON_JSON_SCHEMA) .omit({ middleNames: true }) .extend({ nameOfFavouriteShop: s.string(), addressOfFavouriteShop: s.jsonSchema(ADDRESS_JSON_SCHEMA), }) .requiredFor('nameOfFavouriteShop');

Describe alternatives you've considered
Composing derived JSON schemas on using pure JSON and then setting the ObjectBuilder schema to this new JSON schema. It arguably has greater utility since it is library/framework agnostic, but it somewhat undermines the point of using a library such as ajv-ts to create a better, more guided developer experience through [strongly-typed] Typescript.

Additional context
I am using fragments of JSON schema derived from Open API specifications and re-hashing them for use in HTML forms which are validated using AJV.

@lburgess lburgess added the enhancement New feature or request label Mar 11, 2024
@vitalics
Copy link
Owner

Hi @lburgess. Thanks for the issue. Have you tried the solution described in readme file?

@vitalics
Copy link
Owner

vitalics commented Apr 2, 2024

close the issue due to unactivity

@vitalics vitalics closed this as completed Apr 2, 2024
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

No branches or pull requests

2 participants