The above schema will invoke `faker.internet.email()`.
The above schema will invoke [`faker.internet.email()`](https://github.com/Marak/faker.js/blob/1f47f09e25ad43db41ea4187c3cd3f7e113d4cb4/lib/internet.js#L32).
Note that both generators has higher precedence than **format**.
Note that both generators has higher precedence than **format**.
...
@@ -273,9 +285,12 @@ Another example of faking values is passing arguments to the generator:
...
@@ -273,9 +285,12 @@ Another example of faking values is passing arguments to the generator:
which will invoke `chance.email({ "domain": "fake.com" })`. This example works for single-parameter generator function.
which will invoke [`chance.email({ "domain": "fake.com" })`](https://github.com/chancejs/chancejs/blob/b4c143bf53f516dfd77a8376d0f631462458c062/chance.js#L1118).
This example works for single-parameter generator function.
However, if you pass multiple arguments to the generator function, just pass them wrapped in an array. In the example below we use the [`faker.finance.amount(min, max, dec, symbol)`](https://github.com/Marak/faker.js/blob/1f47f09e25ad43db41ea4187c3cd3f7e113d4cb4/lib/finance.js#L85) generator which has 4 parameters. We just wrap them with an array and it's equivalent to `faker.finance.amount(100, 10000, 2, "$")`:
However, if you pass multiple arguments to the generator function, just pass them wrapped in an array.
In the example below we use the [`faker.finance.amount(min, max, dec, symbol)`](https://github.com/Marak/faker.js/blob/1f47f09e25ad43db41ea4187c3cd3f7e113d4cb4/lib/finance.js#L85)
generator which has 4 parameters. We just wrap them with an array and it's equivalent to `faker.finance.amount(100, 10000, 2, "$")`:
```json
```json
{
{
...
@@ -295,7 +310,10 @@ However, if you pass multiple arguments to the generator function, just pass the
...
@@ -295,7 +310,10 @@ However, if you pass multiple arguments to the generator function, just pass the
However, if you want to pass a single parameter that is an array itself, e.g. [`chance.pickone(["banana", "apple", "orange"])`](https://github.com/chancejs/chancejs/blob/b4c143bf53f516dfd77a8376d0f631462458c062/chance.js#L382), just like [described here](https://github.com/json-schema-faker/json-schema-faker/issues/171), then you need to wrap it with an array once more (twice in total). The outer brackets determine that the content is gonna be a list of params injected into the generator. The inner brackets are just the value itself - the array we pass:
However, if you want to pass a single parameter that is an array itself, e.g.
just like [described here](https://github.com/json-schema-faker/json-schema-faker/issues/171),
then you need to wrap it with an array once more (twice in total). The outer brackets determine that the content is gonna be a list of params injected into the generator. The inner brackets are just the value itself - the array we pass:
```json
```json
{
{
...
@@ -367,7 +385,7 @@ Note that custom generators has lower precedence than core ones.
...
@@ -367,7 +385,7 @@ Note that custom generators has lower precedence than core ones.
You may define following options for `jsf` that alter its behavior:
You may define following options for `jsf` that alter its behavior:
-`failOnInvalidTypes`: boolean - don't throw exception when invalid type passed
-`failOnInvalidTypes`: boolean - don't throw exception when invalid type passed
-`defaultInvalidTypeProduct`: *- default value generated for a schema with invalid type (works only if `failOnInvalidTypes` is set to `false`)
-`defaultInvalidTypeProduct`: - default value generated for a schema with invalid type (works only if `failOnInvalidTypes` is set to `false`)
Set options just as below:
Set options just as below:
...
@@ -490,8 +508,8 @@ Below is the list of JSON Schema validation properties and the inferred type bas
...
@@ -490,8 +508,8 @@ Below is the list of JSON Schema validation properties and the inferred type bas
`jsf` supports [OpenAPI Specification *vendor extensions*](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#vendorExtensions), i.e.
`jsf` supports [OpenAPI Specification *vendor extensions*](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#vendorExtensions), i.e.
*`x-faker` property that stands for `faker` property
*`x-faker` property that stands for `faker` property ([demo »](http://json-schema-faker.js.org/#gist/7cdf200c27eceb6163a79fbc50813fcb))
*`x-chance` property that stands for `chance` property
*`x-chance` property that stands for `chance` property ([demo »](http://json-schema-faker.js.org/#gist/c0084695b4ca1c4cd015ded1f5c6dc33))
Thanks to it, you can use valid swagger definitions for `jsf` data generation.
Thanks to it, you can use valid swagger definitions for `jsf` data generation.