Skip to content
Snippets Groups Projects
Commit 4bf35dda authored by Lars Trieloff's avatar Lars Trieloff
Browse files

Better handling of nested object types #32

parent f305c608
Branches
Tags
No related merge requests found
......@@ -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
```
......@@ -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
......
......@@ -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."
}
}
},
......
......@@ -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."
}
}
},
......
......@@ -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
......@@ -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",{
_:_,
......
......@@ -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) { %>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment