Open sspat opened 6 years ago
Have you considered using the 'pattern'-property to achieve your goal?
Example:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"city": {
"type": "string",
"pattern": "Moscow|Brussels|Oslo|Stockholm|Copenhagen|London"
}
},
"required": [
"city"
]
}
Check that it works here -> https://json-schema-faker.js.org
@sspat Maybe the chance
or faker
-property already supports this?
{
"type": "object",
"properties": {
"food": {
"type": "string",
"chance": {
"pickone": [
[
"banana",
"apple",
"orange"
]
]
}
}
},
"required": [
"food"
]
}
I haven't tried it but it is described here: https://github.com/json-schema-faker/json-schema-faker/blob/master/docs/USAGE.md#user-content-advanced-usage-of-fakerjs-and-chancejs
Hi! Awesome plugin, appreciate your work!
It would be great to have the next feature: If there are any examples specified, the plugin could randomly take a value from the examples, instead of generating fake data. That would give more control of the generated data and create more relevant examples.
Right now, using the following schema:
The plugin generates a success example like this:
It would be great, if it could generate instead this:
So i can provide examples where they are relevant and leave other fields for random fake data generation.