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

👜 Collect Remaining Object Fields #88

Open
han-tyumi opened this issue Aug 23, 2024 · 1 comment
Open

👜 Collect Remaining Object Fields #88

han-tyumi opened this issue Aug 23, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@han-tyumi
Copy link

I'd like to able to collect the remaining object fields into a Dict that can be put in the output rather than being stripped out.

It'd also be nice to be able to validate these as to say all remaining fields must validate their their names and/or values against some discriminator.

And it'd be really really nice if rescript-json-schema could generate these from the patternProperties and additionalProperties keywords.

I ran into this when manually creating a schema for package.json before realizing I could've used rescript-json-schema 😄.

Awesome libraries btw!

@DZakh
Copy link
Owner

DZakh commented Aug 24, 2024

Awesome libraries btw!

Thank you 🙏

It's a good feature. Not easy to implement, but at least it should be possible. I'm currently occupied with contributing to rescript@12 and rescript-rest library, so I won't have time for it in the near future.

If you are interested only in the JSON schema creation and not parsing, you can use JSONSchema.extend and manually add the additionalProperties field to the object schema.

https://github.com/DZakh/rescript-json-schema/blob/b9ce2e67ffe8e72df0e733efa3217f1fa39f6b80/src/JSONSchema.resi#L7

@DZakh DZakh added the enhancement New feature or request label Oct 11, 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