diff --git a/README.md b/README.md index 7b64ec68254164b360a446165b6d41f5d94e725f..0cfa38fc3ec590409973f06dd8ef688fbf540786 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Supported keywords - **$ref** — Resolve internal references only, and/or external if provided. - **required** — All required properties are guaranteed, if not can be omitted. -- **pattern** +- **pattern** — Generate samples based on RegExp values. - **format** — Core formats only: date-time, email, hostname, ipv4, ipv6 and uri. - **enum** — Returns any of these enumerated values. - **minLength/maxLength** — Applies length constraints to string values. @@ -67,10 +67,41 @@ Supported keywords - **additionalProperties** — Partially supported (?) - **dependencies** — Not supported yet (?) +Using references +---------------- + +Inline references are fully supported (json-pointers) but external can't be resolved by `json-schema-faker`. + +In order to achieve that you can use [refaker](https://github.com/gextech/refaker) and then use the resolved schemas: + +```javascript +var schema = { + type: 'object', + properties: { + someValue: { + $ref: 'otherSchema' + } + } +}; + +var refs = [ + { + id: 'otherSchema', + type: 'string' + } +]; + +var sample = jsf(schema, refs); + +console.log(sample.someValue); +// output: voluptatem +``` + + Faking values ------------- -In order to get human-friendly samples you can use the **faker** property on each subschema: +Generated human-friendly samples by using **faker** property on each subschema: ```json { @@ -100,3 +131,8 @@ Actually, I've found some projects or services: - https://github.com/murgatroid99/json-schema-random-instance But are incomplete or has limited support for some keywords, so I decided to code this library. + +Issues +------ + +Any contribution is well received.