swagger-mock-api
swagger-mock-api copied to clipboard
ability to use latest chance's helpers
not sure how (if it is exist) to use chance helpers like pickone
I tried
name:
type: string
x-chance-type: pickone
x-type-value:
- first
- second
I think we it might need to upgrade chance version in this repo.
update
I used pick with x-type-options and it worked.
I think for simplification, we can be consistent with how to pass options and value to chance method. even for fixed custom type we can ignore x-type-options and use the x-type-value
something like this here:
if (node['x-chance-type'] && !node['x-type-value'] ) {
return chance[node['x-chance-type']](node['x-type-options']);
}
if (node['x-chance-type'] && node['x-type-value'] ) {
return chance[node['x-chance-type']](node['x-type-value'], node['x-type-options']);
}
so I can do:
name:
type: string
x-chance-type: pick
x-type-options: 2
x-type-value:
- first
- second
- third
then it should return two randomly picked items on the value array