diff --git a/examples/docs/README.md b/examples/docs/README.md index 0502d30d53aa01bd12e680be8b6d8b1c1c658843..7a6a42401d32b3af4d41e1a4811666581c223772 100644 --- a/examples/docs/README.md +++ b/examples/docs/README.md @@ -20,6 +20,7 @@ * [Extensible](./extensible.schema.md) – `https://example.com/schemas/extensible` (Unknown) * [Identifiable](./identifiable.schema.md) – `https://example.com/schemas/identifiable` (Unknown) * [Join Types](./join.schema.md) – `https://example.com/schemas/join` (Unknown) +* [Nested Object](./nestedobj.schema.md) – `https://example.com/schemas/nestedobject` (Unknown) * [Pattern Properties](./pattern.schema.md) – `https://example.com/schemas/pattern` (Unknown) * [Simple](./simple.schema.md) – `https://example.com/schemas/simple` (Unknown) * [Simple Types](./simpletypes.schema.md) – `https://example.com/schemas/simpletypes` (Unknown) diff --git a/examples/docs/nestedobj.schema.md b/examples/docs/nestedobj.schema.md new file mode 100644 index 0000000000000000000000000000000000000000..f3459efc3a1778c45d2d4f6350f9a2fd50fa91f6 --- /dev/null +++ b/examples/docs/nestedobj.schema.md @@ -0,0 +1,93 @@ +--- +template: reference +foo: bar +--- + +# Nested Object Schema + +``` +https://example.com/schemas/nestedobject +``` + + +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------| +| Can be instantiated | No | Experimental | No | Forbidden | Forbidden | [nestedobj.schema.json](nestedobj.schema.json) | + +# Nested Object Properties + +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [settings](#settings) | `object` | Optional | No | Nested Object (this schema) | + +## settings + +settings + +`settings` + +* is optional +* type: `object` +* defined in this schema + +### settings Type + + +`object` with following properties: + + +| Property | Type | Required | +|----------|------|----------| +| `collaborators`| object | Optional | + + + +#### collaborators + +collaborators + +`collaborators` + +* is optional +* type: `object` + +##### collaborators Type + + +`object` with following properties: + + +| Property | Type | Required | +|----------|------|----------| +| `id`| string | Optional | + + + +#### id + + +`id` + +* is optional +* type: `string` + +##### id Type + + +`string` + + + + + + + + + + + + + + + + diff --git a/examples/generated-schemas/nestedobj.schema.json b/examples/generated-schemas/nestedobj.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..62f814d6a7af195d0f5455a881860e680e41be3b --- /dev/null +++ b/examples/generated-schemas/nestedobj.schema.json @@ -0,0 +1,29 @@ +{ + "$id": "https://example.com/schemas/nestedobject", + "$schema": "http://json-schema.org/draft-07/schema", + "title": "Nested Object", + "type": "object", + "properties": { + "settings": { + "description": "settings", + "type": "object", + "properties": { + "collaborators": { + "description": "collaborators", + "type": "object", + "patternProperties": { + ".*": { + "type": "string" + } + }, + "properties": { + "id": { + "type": "string" + } + } + } + } + } + }, + "additionalProperties": false +} \ No newline at end of file diff --git a/examples/schemas/nestedobj.schema.json b/examples/schemas/nestedobj.schema.json index fffda3bac08985273def77bb4a20e0aff8c25fde..f068d4e59a731610b9a3b0850af44f3b8a4e842f 100644 --- a/examples/schemas/nestedobj.schema.json +++ b/examples/schemas/nestedobj.schema.json @@ -1,7 +1,7 @@ { - "$id": "test.json", + "$id": "https://example.com/schemas/nestedobject", "$schema": "http://json-schema.org/draft-07/schema", - "title": "test", + "title": "Nested Object", "type": "object", "properties": { "settings": { diff --git a/spec/examples/README.md b/spec/examples/README.md index 0502d30d53aa01bd12e680be8b6d8b1c1c658843..7a6a42401d32b3af4d41e1a4811666581c223772 100644 --- a/spec/examples/README.md +++ b/spec/examples/README.md @@ -20,6 +20,7 @@ * [Extensible](./extensible.schema.md) – `https://example.com/schemas/extensible` (Unknown) * [Identifiable](./identifiable.schema.md) – `https://example.com/schemas/identifiable` (Unknown) * [Join Types](./join.schema.md) – `https://example.com/schemas/join` (Unknown) +* [Nested Object](./nestedobj.schema.md) – `https://example.com/schemas/nestedobject` (Unknown) * [Pattern Properties](./pattern.schema.md) – `https://example.com/schemas/pattern` (Unknown) * [Simple](./simple.schema.md) – `https://example.com/schemas/simple` (Unknown) * [Simple Types](./simpletypes.schema.md) – `https://example.com/schemas/simpletypes` (Unknown) diff --git a/spec/examples/nestedobj.schema.md b/spec/examples/nestedobj.schema.md new file mode 100644 index 0000000000000000000000000000000000000000..f3459efc3a1778c45d2d4f6350f9a2fd50fa91f6 --- /dev/null +++ b/spec/examples/nestedobj.schema.md @@ -0,0 +1,93 @@ +--- +template: reference +foo: bar +--- + +# Nested Object Schema + +``` +https://example.com/schemas/nestedobject +``` + + +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------| +| Can be instantiated | No | Experimental | No | Forbidden | Forbidden | [nestedobj.schema.json](nestedobj.schema.json) | + +# Nested Object Properties + +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [settings](#settings) | `object` | Optional | No | Nested Object (this schema) | + +## settings + +settings + +`settings` + +* is optional +* type: `object` +* defined in this schema + +### settings Type + + +`object` with following properties: + + +| Property | Type | Required | +|----------|------|----------| +| `collaborators`| object | Optional | + + + +#### collaborators + +collaborators + +`collaborators` + +* is optional +* type: `object` + +##### collaborators Type + + +`object` with following properties: + + +| Property | Type | Required | +|----------|------|----------| +| `id`| string | Optional | + + + +#### id + + +`id` + +* is optional +* type: `string` + +##### id Type + + +`string` + + + + + + + + + + + + + + + + diff --git a/spec/lib/integrationTest.spec.js b/spec/lib/integrationTest.spec.js index 061d7de439c157fd7c7a95ed1395551805498edc..8ed479714682eb8335f98f894266f35bb487b453 100644 --- a/spec/lib/integrationTest.spec.js +++ b/spec/lib/integrationTest.spec.js @@ -55,7 +55,7 @@ describe('Compare results', () => { ls.on('close', code => { expect(code).toEqual(0); const files = readdirSync('./spec/examples').filter(item => !(/(^|\/)\.[^\/\.]/g).test(item)); - expect(files.length).toEqual(21); + expect(files.length).toEqual(22); files.forEach(file => { if (statSync('./spec/examples/' + file).isFile()) { diff --git a/templates/md/nested-property.ejs b/templates/md/nested-property.ejs index 2bd24d2230f5657e90e5d8b68f75940f32346b0c..5f1b6cb9f429dcccafadb6e215cf40e64e618892 100644 --- a/templates/md/nested-property.ejs +++ b/templates/md/nested-property.ejs @@ -8,8 +8,9 @@ #### <%=name %> <% if (schema.title) { %>##### <%= schema.title %><% } %> - +<% if (schema.description) { %> <%- (""+schema.description).replace(/\n/g, '\n\n') %> +<% } %> `<%=name %>`