From 699eac1b593b0f6fee508e2e295b57cbf6396cd5 Mon Sep 17 00:00:00 2001 From: Alvaro Cabrera <pateketrueke@gmail.com> Date: Fri, 28 Nov 2014 17:33:26 -0600 Subject: [PATCH] Missing info; fixed --- README.md | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7b64ec68..0cfa38fc 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. -- GitLab