prism
prism copied to clipboard
Allow providing a seed when using dynamic content generation
Would be really helpful for tests to be able to get a stable response value
Context
- i want to use prism for writing tests
- setting the seed would be really useful for this to get stable values
Current Behavior
- currently, faker/prism uses randomly generated responses with each request when using dynamic mode
Expected Behavior
- i want to be able to get stable responses from the server using dynamic mode
Possible Solution(s)
- accept a header,
x-dynamic-seed, that i can set to a constant during testing
We are also interested in providing a seed to control the RNG, our use case is using Prism to mock APIs and run tests for SDKs we generate from an OpenAPI spec.
For our use case, running Prism in CLI mode, we really want a --seed argument to get stable values when --dynamic or --ignoreExamples are being used.
PR #2594 is up! One thing to note, when you use --ignoreExamples, the results are already deterministic. This is because --ignoreExamples uses json-schema-sampler to statically generate examples, not json-schema-faker, and json-schema-sampler is deterministic (https://github.com/stoplightio/json-schema-sampler).
Awesome @ilanashapiro, thanks for this 🙇. I will do a full review shortly.
@jack-bliss Does that address your use case? Ilana PR adds support for both --seed and the header Prefer="seed=test_seed".
Just to transparent, Stainless did support this effort, but our aim is to ensure the solution benefits the broader community, not just our specific needs.
yes looks great, much appreciated <3
Ilana's PR has been merged 🎉. It will be part of the next release: https://github.com/stoplightio/prism/pull/2606.