From 0068fde2b5fd730bb7fa1e2f185f8c46daadb789 Mon Sep 17 00:00:00 2001 From: Lars Trieloff <trieloff@adobe.com> Date: Fri, 5 Jan 2018 14:59:02 +0000 Subject: [PATCH] list properties of nested objects --- examples/docs/arrays.schema.md | 31 +++++-------------- examples/docs/deepextending.schema.md | 6 ++-- examples/docs/definitions.schema.md | 6 ++-- examples/docs/extending.schema.md | 6 ++-- examples/docs/simple.schema.md | 2 +- examples/docs/simpletypes.schema.md | 12 +++---- examples/docs/subdir/subdir.schema.md | 2 +- examples/generated-schemas/arrays.schema.json | 3 ++ examples/schemas/arrays.schema.json | 3 ++ templates/md/nested-properties.ejs | 16 ++++++++++ templates/md/object-type.ejs | 12 +++++++ 11 files changed, 59 insertions(+), 40 deletions(-) create mode 100644 templates/md/nested-properties.ejs create mode 100644 templates/md/object-type.ejs diff --git a/examples/docs/arrays.schema.md b/examples/docs/arrays.schema.md index a37f8cf..86e4eb3 100644 --- a/examples/docs/arrays.schema.md +++ b/examples/docs/arrays.schema.md @@ -204,30 +204,15 @@ An array of simple objects Array type: `object[]` All items must be of the type: -Unknown type `object`. - -```json -{ - "type": "array", - "description": "An array of simple objects", - "items": { - "type": "object", - "properties": { - "a": { - "type": "string", - "description": "The a property" - }, - "b": { - "type": "integer", - "description": "The b property" - } - }, - "simpletype": "`object`" - }, - "simpletype": "`object[]`" -} -``` +`object` with following properties: + + +| Property | Type | Required +|----------|------|----------| +| `a`| string | **Required** | +| `b`| integer | Optional | +full list. diff --git a/examples/docs/deepextending.schema.md b/examples/docs/deepextending.schema.md index f80bd5a..0221a91 100644 --- a/examples/docs/deepextending.schema.md +++ b/examples/docs/deepextending.schema.md @@ -46,7 +46,7 @@ An `id` with an `@` in front of it. The `@` stands for "dot com" `string` -* format: `uri-reference` URI Reference (according to [RFC3986](https://tools.ietf.org/html/rfc3986)) +* format: `uri-reference` – URI Reference (according to [RFC3986](https://tools.ietf.org/html/rfc3986)) @@ -141,7 +141,7 @@ A unique identifier given to every addressable thing. `string` -* format: `uri` Uniformous Resource Identifier (according to [RFC3986](http://tools.ietf.org/html/rfc3986)) +* format: `uri` – Uniformous Resource Identifier (according to [RFC3986](http://tools.ietf.org/html/rfc3986)) @@ -161,7 +161,7 @@ An about ids. It is meta. If you are confused, send an email to the address spec `string` -* format: `email` email address (according to [RFC 5322, section 3.4.1](https://tools.ietf.org/html/rfc5322)) +* format: `email` – email address (according to [RFC 5322, section 3.4.1](https://tools.ietf.org/html/rfc5322)) diff --git a/examples/docs/definitions.schema.md b/examples/docs/definitions.schema.md index 734c3a3..3b73086 100644 --- a/examples/docs/definitions.schema.md +++ b/examples/docs/definitions.schema.md @@ -50,7 +50,7 @@ An `id` with an `@` in front of it. The `@` stands for "dot com" `string` -* format: `uri-reference` URI Reference (according to [RFC3986](https://tools.ietf.org/html/rfc3986)) +* format: `uri-reference` – URI Reference (according to [RFC3986](https://tools.ietf.org/html/rfc3986)) @@ -70,7 +70,7 @@ A unique identifier given to every addressable thing. `string` -* format: `uri` Uniformous Resource Identifier (according to [RFC3986](http://tools.ietf.org/html/rfc3986)) +* format: `uri` – Uniformous Resource Identifier (according to [RFC3986](http://tools.ietf.org/html/rfc3986)) @@ -90,7 +90,7 @@ An about ids. It is meta. If you are confused, send an email to the address spec `string` -* format: `email` email address (according to [RFC 5322, section 3.4.1](https://tools.ietf.org/html/rfc5322)) +* format: `email` – email address (according to [RFC 5322, section 3.4.1](https://tools.ietf.org/html/rfc5322)) diff --git a/examples/docs/extending.schema.md b/examples/docs/extending.schema.md index f6d701c..141f234 100644 --- a/examples/docs/extending.schema.md +++ b/examples/docs/extending.schema.md @@ -44,7 +44,7 @@ An `id` with an `@` in front of it. The `@` stands for "dot com" `string` -* format: `uri-reference` URI Reference (according to [RFC3986](https://tools.ietf.org/html/rfc3986)) +* format: `uri-reference` – URI Reference (according to [RFC3986](https://tools.ietf.org/html/rfc3986)) @@ -120,7 +120,7 @@ A unique identifier given to every addressable thing. `string` -* format: `uri` Uniformous Resource Identifier (according to [RFC3986](http://tools.ietf.org/html/rfc3986)) +* format: `uri` – Uniformous Resource Identifier (according to [RFC3986](http://tools.ietf.org/html/rfc3986)) @@ -140,7 +140,7 @@ An about ids. It is meta. If you are confused, send an email to the address spec `string` -* format: `email` email address (according to [RFC 5322, section 3.4.1](https://tools.ietf.org/html/rfc5322)) +* format: `email` – email address (according to [RFC 5322, section 3.4.1](https://tools.ietf.org/html/rfc5322)) diff --git a/examples/docs/simple.schema.md b/examples/docs/simple.schema.md index 922088c..bdaa1ea 100644 --- a/examples/docs/simple.schema.md +++ b/examples/docs/simple.schema.md @@ -34,7 +34,7 @@ A unique identifier given to every addressable thing. `string` -* format: `uri` Uniformous Resource Identifier (according to [RFC3986](http://tools.ietf.org/html/rfc3986)) +* format: `uri` – Uniformous Resource Identifier (according to [RFC3986](http://tools.ietf.org/html/rfc3986)) diff --git a/examples/docs/simpletypes.schema.md b/examples/docs/simpletypes.schema.md index 1aefdca..00b71c2 100644 --- a/examples/docs/simpletypes.schema.md +++ b/examples/docs/simpletypes.schema.md @@ -148,7 +148,7 @@ A date-like string. `string` -* format: `date-time` date and time (according to [RFC 3339, section 5.6](http://tools.ietf.org/html/rfc3339)) +* format: `date-time` – date and time (according to [RFC 3339, section 5.6](http://tools.ietf.org/html/rfc3339)) @@ -168,7 +168,7 @@ An email-like string. `string` -* format: `email` email address (according to [RFC 5322, section 3.4.1](https://tools.ietf.org/html/rfc5322)) +* format: `email` – email address (according to [RFC 5322, section 3.4.1](https://tools.ietf.org/html/rfc5322)) @@ -188,7 +188,7 @@ A hostname-like string. `string` -* format: `hostname` Domain Name (according to [RFC 1034, section 3.1](https://tools.ietf.org/html/rfc1034)) +* format: `hostname` – Domain Name (according to [RFC 1034, section 3.1](https://tools.ietf.org/html/rfc1034)) @@ -208,7 +208,7 @@ An IPv4-like string. `string` -* format: `ipv4` IP (v4) address (according to [RFC 2673, section 3.2](https://tools.ietf.org/html/rfc2673)) +* format: `ipv4` – IP (v4) address (according to [RFC 2673, section 3.2](https://tools.ietf.org/html/rfc2673)) @@ -228,7 +228,7 @@ An IPv6-like string. `string` -* format: `ipv6` IP (v6) address (according to [RFC 4291, section 2.2](https://tools.ietf.org/html/rfc4291)) +* format: `ipv6` – IP (v6) address (according to [RFC 4291, section 2.2](https://tools.ietf.org/html/rfc4291)) @@ -418,7 +418,7 @@ A URI. `string` -* format: `uri` Uniformous Resource Identifier (according to [RFC3986](http://tools.ietf.org/html/rfc3986)) +* format: `uri` – Uniformous Resource Identifier (according to [RFC3986](http://tools.ietf.org/html/rfc3986)) diff --git a/examples/docs/subdir/subdir.schema.md b/examples/docs/subdir/subdir.schema.md index 5e236c3..b62f222 100644 --- a/examples/docs/subdir/subdir.schema.md +++ b/examples/docs/subdir/subdir.schema.md @@ -34,7 +34,7 @@ A unique identifier given to every addressable thing. `string` -* format: `uri` Uniformous Resource Identifier (according to [RFC3986](http://tools.ietf.org/html/rfc3986)) +* format: `uri` – Uniformous Resource Identifier (according to [RFC3986](http://tools.ietf.org/html/rfc3986)) diff --git a/examples/generated-schemas/arrays.schema.json b/examples/generated-schemas/arrays.schema.json index 42200b1..490e0e0 100644 --- a/examples/generated-schemas/arrays.schema.json +++ b/examples/generated-schemas/arrays.schema.json @@ -82,6 +82,9 @@ "description": "An array of simple objects", "items": { "type": "object", + "required": [ + "a" + ], "properties": { "a": { "type": "string", diff --git a/examples/schemas/arrays.schema.json b/examples/schemas/arrays.schema.json index 2d9bb70..9cc2660 100644 --- a/examples/schemas/arrays.schema.json +++ b/examples/schemas/arrays.schema.json @@ -82,6 +82,9 @@ "description": "An array of simple objects", "items": { "type": "object", + "required": [ + "a" + ], "properties": { "a": { "type": "string", diff --git a/templates/md/nested-properties.ejs b/templates/md/nested-properties.ejs new file mode 100644 index 0000000..66143c0 --- /dev/null +++ b/templates/md/nested-properties.ejs @@ -0,0 +1,16 @@ +<% /** + * Copyright 2017 Adobe Systems Incorporated. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + */ %> + + +| Property | Type | Required +|----------|------|----------| +<% _.keys(props).sort().forEach(property => { + const schema = props[property]; %> +| `<%= property %>`| <%= schema.type %> | <%= (outer.required&&outer.required.indexOf(property)>=0) ? "**Required**" : "Optional" %> | +<% +}); +%> \ No newline at end of file diff --git a/templates/md/object-type.ejs b/templates/md/object-type.ejs new file mode 100644 index 0000000..4addd6a --- /dev/null +++ b/templates/md/object-type.ejs @@ -0,0 +1,12 @@ +<% /** + * Copyright 2018 Adobe Systems Incorporated. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + */ %> + +`object` with following properties: + +<%- include("nested-properties",{outer:schema,props: schema.properties,_:_, nested:true}) %> + +full list. \ No newline at end of file -- GitLab