-
-
Notifications
You must be signed in to change notification settings - Fork 175
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON Schema Arbitrary #3730
Comments
Hey @Ceres6, That could be a good idea. We thought of it multiple times since the beginning of fast-check and being able to magically generate data based on a schema (or typings details) seems to be great. I do have some snippets doing so but I never pushed them up to a release as there are many challenges to deal with in order to implement it correctly. For instance most of the time when a schema asks for a numeric value, this is not any number but is might be restricted to positive integers, integer corresponding to an existing index... Same applies to all other types. In other words: if we implement that we either need to confirm that the source constraints are expressive enough to be used as a basis to create the whole arbitrary or to offer a way to refine sub-part by sub-part the produced arbitrary. I know about similar initiative backed by zod or io-ts. Anyway, I'd rather but that one as a side-package for now if we start building it natively. |
馃殌 Feature Request
I would like to have a method to generate arbitraries from a json schema object.
Motivation
When testing APIs that validate the input complies with a JSON schema it is a lot of work to generate arbitraries for every schema you have. Being it an standard I think it should be possible to create a function that generates the arbitrary from the schema directly.
Example
In my case I would use it to validate that any data that follow the schema is valid for other function's input.
It has been some time since I last used the library, sorry if the code is not 100% valid.
I would take any other ideas on how to accomplish the same and I would be glad to help with the implementation if the feature gets approved.
Thanks in advance for taking the time to review.
The text was updated successfully, but these errors were encountered: