I'm using fast-check to create zod, typebox, valibod, arktype and JSON schemas #6177
Replies: 5 comments 6 replies
-
|
Here's the entrypoint for one of them, in case it helps: https://github.com/traversable/schema/blob/main/packages/zod-test/src/generator.ts#L259-L297 |
Beta Was this translation helpful? Give feedback.
-
|
To make things more concrete: here's how I'm using it to test that a function that accepts a Valibot schema and turns it into a string results in generating the same schema: |
Beta Was this translation helpful? Give feedback.
-
|
Hey, sorry I'm familiar with schemas and rewrite systems but I still don't quite understand what this library is doing and how it relates to fast check. Is this like a more composable way to construct schemas? Does this allow you to derive fast-check arbitraries from schemas or something? |
Beta Was this translation helpful? Give feedback.
-
|
@gruhn hey, thanks for checking it out. Did you look at the StackBlitz? Here's my post about it. tl;dr, basically these are seed arbitraries that can be interpreted to generate schemas. For example, if you're writing a library that accepts a JSON Schema input, you can use The same seed can also be interpreted as a valid data generator, and also an invalid data generator. |
Beta Was this translation helpful? Give feedback.
-
I didn't answer this part – fast-check generates the seeds. My goal in sharing this was to see if the fast-check maintainers have any feedback about how I implemented things. But now that some time has passed since I asked the question, I'm realizing that it's probably not very realistic to expect anyone to sit down and read through my code. I'll close this here, but if anyone does have any thoughts or questions I'm more than happy to discuss! Thanks for taking a look. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello fast-check maintainers,
I've been using fast-check as a core piece of infrastructure while building various libraries that are part of @traversable/schema.
These libraries generate "seeds", which are deeply nested arrays of integers (for performance reasons), and ship a handful of "seed interpreters" that can be used to generate arbitrary schemas, valid data, and even slightly invalid data, for testing purposes.
There are still a few features I'd like to add, and one regrettable configuration option that I need to deprecate (turns out
minDepthis a bad idea 😅), but they're almost ready.I also built a huge OpenAPI v3.0 arbitrary a while back, which needs a lot of work before it's ready to be published. Notably, one of the features that took a long time to build was a "self-referencing" OpenAPI document (which involved mutating the document to move some schemas to
components/schemas, to make the generated documents more realistic.I'd like to revisit building an OpenAPI arbitrary in the near future, but first, I was hoping to get some feedback on the direction of these libraries, to make sure I'm heading in the right direction with the implementation.
Anyway, thanks for taking a look, happy to answer any questions and would love to hear what you think.
Beta Was this translation helpful? Give feedback.
All reactions