Skip to content
Snippets Groups Projects
Unverified Commit 45bd5646 authored by Lars Trieloff's avatar Lars Trieloff Committed by GitHub
Browse files

Merge pull request #71 from AndyOGo/feature/add-default-support

added support for default
parents df95ab64 82fbef55
No related branches found
No related tags found
No related merge requests found
...@@ -208,10 +208,10 @@ All items must be of the type: ...@@ -208,10 +208,10 @@ All items must be of the type:
`object` with following properties: `object` with following properties:
| Property | Type | Required | Property | Type | Required |
|----------|------|----------| |----------|------|----------|
| `a`| string | **Required** | | `a`| string | **Required** |
| `b`| integer | Optional | | `b`| integer | Optional |
......
...@@ -117,10 +117,10 @@ String or number… ...@@ -117,10 +117,10 @@ String or number…
`object` with following properties: `object` with following properties:
| Property | Type | Required | Property | Type | Required |
|----------|------|----------| |----------|------|----------|
| `foo`| string | Optional | | `foo`| string | Optional |
| `nonfoo`| boolean | Optional | | `nonfoo`| boolean | Optional |
......
...@@ -208,10 +208,10 @@ All items must be of the type: ...@@ -208,10 +208,10 @@ All items must be of the type:
`object` with following properties: `object` with following properties:
| Property | Type | Required | Property | Type | Required |
|----------|------|----------| |----------|------|----------|
| `a`| string | **Required** | | `a`| string | **Required** |
| `b`| integer | Optional | | `b`| integer | Optional |
......
...@@ -117,10 +117,10 @@ String or number… ...@@ -117,10 +117,10 @@ String or number…
`object` with following properties: `object` with following properties:
| Property | Type | Required | Property | Type | Required |
|----------|------|----------| |----------|------|----------|
| `foo`| string | Optional | | `foo`| string | Optional |
| `nonfoo`| boolean | Optional | | `nonfoo`| boolean | Optional |
......
...@@ -5,12 +5,13 @@ ...@@ -5,12 +5,13 @@
* of the License at http://www.apache.org/licenses/LICENSE-2.0 * of the License at http://www.apache.org/licenses/LICENSE-2.0
*/ %> */ %>
<% const hasDefault = _.keys(props).filter(property => _.has(props, property + '.default')).length > 0; %>
| Property | Type | Required | Property | Type | Required |<% if(hasDefault) { %> Default |<% } %>
|----------|------|----------| |----------|------|----------|<% if(hasDefault) { %>---------|<% } %>
<% _.keys(props).sort().forEach(property => { <% _.keys(props).sort().forEach(property => {
const schema = props[property]; %> const schema = props[property]; %>
| `<%= property %>`| <%= schema.type %> | <%= (Array.isArray(outer.required)&&outer.required.indexOf(property)>=0) ? "**Required**" : "Optional" %> | | `<%= property %>`| <%= schema.type %> | <%= (Array.isArray(outer.required)&&outer.required.indexOf(property)>=0) ? "**Required**" : "Optional" %> |<% if(hasDefault) { %> <% if (schema.default!==undefined) { %>`<%- JSON.stringify(schema.default) %>`<% } %> |<% } %>
<% <%
}); });
%> %>
\ No newline at end of file
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
<% if (schema.maxItems!==undefined&&schema.minItems!==undefined) { %>* between `<%=schema.minItems %>` and `<%=schema.maxItems %>` items in the array<% } <% if (schema.maxItems!==undefined&&schema.minItems!==undefined) { %>* between `<%=schema.minItems %>` and `<%=schema.maxItems %>` items in the array<% }
else if (schema.maxItems!==undefined ) { %>* no more than `<%=schema.maxItems %>` items in the array<% } else if (schema.maxItems!==undefined ) { %>* no more than `<%=schema.maxItems %>` items in the array<% }
else if (schema.minItems!==undefined ) { %>* at least `<%=schema.minItems %>` items in the array<% } %> else if (schema.minItems!==undefined ) { %>* at least `<%=schema.minItems %>` items in the array<% } %>
<% } %><% if (schema.default!==undefined) { %>
* default: `<%- JSON.stringify(schema.default) %>`
<% } %> <% } %>
<% if (schema.const!==undefined) { %> <% if (schema.const!==undefined) { %>
......
...@@ -21,6 +21,8 @@ Applies to all properties that match the regular expression `<%=name %>` ...@@ -21,6 +21,8 @@ Applies to all properties that match the regular expression `<%=name %>`
<% if (schema.maxItems!==undefined&&schema.minItems!==undefined) { %>* between `<%=schema.minItems %>` and `<%=schema.maxItems %>` items in the array<% } <% if (schema.maxItems!==undefined&&schema.minItems!==undefined) { %>* between `<%=schema.minItems %>` and `<%=schema.maxItems %>` items in the array<% }
else if (schema.maxItems!==undefined ) { %>* no more than `<%=schema.maxItems %>` items in the array<% } else if (schema.maxItems!==undefined ) { %>* no more than `<%=schema.maxItems %>` items in the array<% }
else if (schema.minItems!==undefined ) { %>* at least `<%=schema.minItems %>` items in the array<% } %> else if (schema.minItems!==undefined ) { %>* at least `<%=schema.minItems %>` items in the array<% } %>
<% } %><% if (schema.default!==undefined) { %>
* default: `<%- JSON.stringify(schema.default) %>`
<% } %> <% } %>
* defined in <% if (schema.$oSchema) { %>[<%= schema.$oSchema.$linkVal %>](<%= schema.$oSchema.$linkPath %>#<%= name %>)<% } else { %>this schema<% } %> * defined in <% if (schema.$oSchema) { %>[<%= schema.$oSchema.$linkVal %>](<%= schema.$oSchema.$linkPath %>#<%= name %>)<% } else { %>this schema<% } %>
......
...@@ -6,12 +6,13 @@ ...@@ -6,12 +6,13 @@
*/ %> */ %>
# <%=title %> Properties # <%=title %> Properties
<% const hasDefault = _.keys(props).filter(property => _.has(props, property + '.default')).length > 0; %>
| Property | Type | Required | Defined by | | Property | Type | Required |<% if(hasDefault) { %> Default |<% } %> Defined by |
|----------|------|----------|------------| |----------|------|----------|<% if(hasDefault) { %>---------|<% } %>------------|
<% _.keys(props).sort().forEach(property => { <% _.keys(props).sort().forEach(property => {
const schema = props[property]; %> const schema = props[property]; %>
| [<%= property %>](#<%= propertiesSlugs[property] %>) | <%= schema.simpletype %> | <%= schema.isrequired === true ? "**Required**" : "Optional" %> | <% | [<%= property %>](#<%= propertiesSlugs[property] %>) | <%= schema.simpletype %> | <%= schema.isrequired === true ? "**Required**" : "Optional" %> |<% if(hasDefault) { %> <% if (schema.default!==undefined) { %>`<%- JSON.stringify(schema.default) %>`<% } %> |<% } %> <%
if (schema.$oSchema) { if (schema.$oSchema) {
%>[<%= schema.$oSchema.$linkVal %>](<%= schema.$oSchema.$linkPath %>#<%= propertiesSlugs[property] %>)<% %>[<%= schema.$oSchema.$linkVal %>](<%= schema.$oSchema.$linkPath %>#<%= propertiesSlugs[property] %>)<%
} else { } else {
...@@ -20,7 +21,7 @@ ...@@ -20,7 +21,7 @@
}); });
%><% _.keys(pprops).forEach(property => { %><% _.keys(pprops).forEach(property => {
const schema = pprops[property]; %> const schema = pprops[property]; %>
| `<%= property.replace(':', '') %>` | <%= schema.simpletype %> | Pattern | <% | `<%= property.replace(':', '') %>` | <%= schema.simpletype %> | Pattern |<% if(hasDefault) { %> <% if (schema.default!==undefined) { %>`<%- JSON.stringify(schema.default) %>`<% } %> |<% } %> <%
if (schema.$oSchema) { if (schema.$oSchema) {
%>[<%= schema.$oSchema.$linkVal %>](<%= schema.$oSchema.$linkPath %>#<%= property.replace(':', '').toLowerCase() %>)<% %>[<%= schema.$oSchema.$linkVal %>](<%= schema.$oSchema.$linkPath %>#<%= property.replace(':', '').toLowerCase() %>)<%
} else { } else {
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
<% if (schema.maxItems!==undefined&&schema.minItems!==undefined) { %>* between `<%=schema.minItems %>` and `<%=schema.maxItems %>` items in the array<% } <% if (schema.maxItems!==undefined&&schema.minItems!==undefined) { %>* between `<%=schema.minItems %>` and `<%=schema.maxItems %>` items in the array<% }
else if (schema.maxItems!==undefined ) { %>* no more than `<%=schema.maxItems %>` items in the array<% } else if (schema.maxItems!==undefined ) { %>* no more than `<%=schema.maxItems %>` items in the array<% }
else if (schema.minItems!==undefined ) { %>* at least `<%=schema.minItems %>` items in the array<% } %> else if (schema.minItems!==undefined ) { %>* at least `<%=schema.minItems %>` items in the array<% } %>
<% } %><% if (schema.default!==undefined) { %>
* default: `<%- JSON.stringify(schema.default) %>`
<% } %> <% } %>
* defined in <% if (schema.$oSchema) { %>[<%= schema.$oSchema.$linkVal %>](<%= schema.$oSchema.$linkPath %>#<%= nameSlug %>)<% } else { %>this schema<% } %> * defined in <% if (schema.$oSchema) { %>[<%= schema.$oSchema.$linkVal %>](<%= schema.$oSchema.$linkPath %>#<%= nameSlug %>)<% } else { %>this schema<% } %>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment