diff --git a/examples/docs/abstract.schema.md b/examples/docs/abstract.schema.md index 72799baabf2228ab2a292ab3ba9cfc0fda2a5354..55b9dca8dcf779e529ee283be919dbeeee7d6a52 100644 --- a/examples/docs/abstract.schema.md +++ b/examples/docs/abstract.schema.md @@ -21,6 +21,7 @@ This is an abstract schema. It has `definitions`, but does not declare any prope |----------|------|-------| | [bar](#bar) | `string` | `https://example.com/schemas/abstract#/definitions/second` | | [foo](#foo) | `string` | `https://example.com/schemas/abstract#/definitions/first` | +| [nonfoo](#nonfoo) | `const` | `https://example.com/schemas/abstract#/definitions/first` | ## bar @@ -59,3 +60,22 @@ A unique identifier given to every addressable thing. + +## nonfoo + +This is not foo. + +`nonfoo` +* is optional +* type: `const` +* defined in this schema + +The value of this property **must** be equal to: + +```json +false +``` + + + + diff --git a/examples/docs/complex.schema.md b/examples/docs/complex.schema.md index d9d54ff89b144e12440da8b01d253293ea7b9f40..774ce4f42d654217efb769fa62e8ed3b999275e4 100644 --- a/examples/docs/complex.schema.md +++ b/examples/docs/complex.schema.md @@ -113,26 +113,60 @@ String or number… ### refabstract Type -Unknown type `object`. + +`object` with following properties: + + +| Property | Type | Required +|----------|------|----------| +| `foo`| string | Optional | +| `nonfoo`| boolean | Optional | + + + +#### foo + +A unique identifier given to every addressable thing. + +`foo` +* is optional +* type: `string` + +##### foo Type + + +`string` + + + + + + + + +#### nonfoo + +This is not foo. + +`nonfoo` +* is optional +* type: `boolean` + +The value of this property **must** be equal to: ```json -{ - "type": "object", - "properties": { - "foo": { - "type": "string", - "description": "A unique identifier given to every addressable thing." - } - }, - "required": true, - "simpletype": "`object`" -} +false ``` + + + + + ## reflist diff --git a/examples/generated-schemas/abstract.schema.json b/examples/generated-schemas/abstract.schema.json index f202ac4a9a344d780f2cd546d2606d0ab0a94ce6..780b192cca9579a95de15df9b5c3d899acc35352 100644 --- a/examples/generated-schemas/abstract.schema.json +++ b/examples/generated-schemas/abstract.schema.json @@ -17,6 +17,11 @@ "foo": { "type": "string", "description": "A unique identifier given to every addressable thing." + }, + "nonfoo": { + "type": "boolean", + "const": false, + "description": "This is not foo." } } }, diff --git a/examples/schemas/abstract.schema.json b/examples/schemas/abstract.schema.json index 2f170c0c1a7d71064f3fc1e5a19e933e589f285b..5d3a9ba9d80a6c29fa071eeb11a8581f1ffabc66 100644 --- a/examples/schemas/abstract.schema.json +++ b/examples/schemas/abstract.schema.json @@ -17,6 +17,11 @@ "foo": { "type": "string", "description": "A unique identifier given to every addressable thing." + }, + "nonfoo": { + "type": "boolean", + "const": false, + "description": "This is not foo." } } }, diff --git a/templates/md/nested-properties.ejs b/templates/md/nested-properties.ejs index 66143c027698e7efbd59d351602f9e9dcd90daf3..1cc93adb9dce623a91ae56c93e4b42ef21678d6e 100644 --- a/templates/md/nested-properties.ejs +++ b/templates/md/nested-properties.ejs @@ -10,7 +10,7 @@ |----------|------|----------| <% _.keys(props).sort().forEach(property => { const schema = props[property]; %> -| `<%= property %>`| <%= schema.type %> | <%= (outer.required&&outer.required.indexOf(property)>=0) ? "**Required**" : "Optional" %> | +| `<%= property %>`| <%= schema.type %> | <%= (Array.isArray(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 index cc1902a15602aa54dd2397d757a8548ad5972bfe..00cbd60469031777a6d2944d5d18a247b803dd2d 100644 --- a/templates/md/object-type.ejs +++ b/templates/md/object-type.ejs @@ -12,7 +12,7 @@ <% _.keys(schema.properties).sort().forEach(property => { const inner = schema.properties[property]; inner.simpletype = "`" + inner.type + "`"; - const required = (schema.required&&schema.required.indexOf(property)>=0); %> + const required = (Array.isArray(schema.required)&&schema.required.indexOf(property)>=0); %> <%- include("nested-property",{ _:_, diff --git a/templates/md/property.ejs b/templates/md/property.ejs index f1dafd05a514ba5bcec0b6226b175feb58499cbd..522c68f8bcbff6dc1da5728327c8179bf62733df 100644 --- a/templates/md/property.ejs +++ b/templates/md/property.ejs @@ -41,6 +41,8 @@ The value of this property **must** be equal to one of the [known values below]( <%- include("number-type",{schema:schema,_:_}) %> <% } else if (schema.type==="boolean") { %> <%- include("boolean-type",{schema:schema,_:_}) %> +<% } else if (schema.type==="object") { %> +<%- include("object-type",{schema:schema,_:_}) %> <% } else if (schema.type==="array") { %> <%- include("array-type",{schema:schema,_:_,nested:false,ejs:ejs}) %> <% } else if (schema.$ref!==undefined) { %>