From 50299e768b339bef62ca751aa4b92f5bb53ccf51 Mon Sep 17 00:00:00 2001 From: Zambonilli Date: Tue, 21 Apr 2015 12:20:34 -0500 Subject: [PATCH 1/5] Fix for issue #2 to support custom group names on apiParam --- templates/default.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/templates/default.md b/templates/default.md index edd4269..0b796d5 100644 --- a/templates/default.md +++ b/templates/default.md @@ -32,15 +32,18 @@ | <%- header.field %> | <%- header.type %> | <%- header.optional ? '**optional**' : '' %> <%- header.description %> | <% }); //forech parameter -%> <% } //if parameters -%> -<% if (data[group][sub][0].parameter && data[group][sub][0].parameter.fields.Parameter.length) { -%> +<% if (data[group][sub][0].parameter) { -%> -### Parameters +<% Object.keys(data[group][sub][0].parameter.fields).forEach(function(g) { -%> + +### <%= g %> Parameters | Name | Type | Description | |---------|-----------|--------------------------------------| -<% data[group][sub][0].parameter.fields.Parameter.forEach(function (param) { -%> +<% data[group][sub][0].parameter.fields[g].forEach(function (param) { -%> | <%- param.field %> | <%- param.type %> | <%- param.optional ? '**optional**' : '' %> <%- param.description %> | -<% }); //forech parameter -%> +<% }); //forech (group) parameter -%> +<% }); //forech param parameter -%> <% } //if parameters -%> <% if (data[group][sub][0].examples && data[group][sub][0].examples.length) { -%> From 4e459ef275d553df5b107bbc109dbc4190644630 Mon Sep 17 00:00:00 2001 From: Zambonilli Date: Tue, 21 Apr 2015 13:46:13 -0500 Subject: [PATCH 2/5] Issue #4 Add the defaultValue and allowedValues to the parameter(s) tables --- templates/default.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/default.md b/templates/default.md index 0b796d5..627b463 100644 --- a/templates/default.md +++ b/templates/default.md @@ -38,10 +38,10 @@ ### <%= g %> Parameters -| Name | Type | Description | -|---------|-----------|--------------------------------------| +| Name | Type | Description | Default | Allowed | +|:---------|:-----------|:--------------------------------------|:-----------|:-----------| <% data[group][sub][0].parameter.fields[g].forEach(function (param) { -%> -| <%- param.field %> | <%- param.type %> | <%- param.optional ? '**optional**' : '' %> <%- param.description %> | +| <%- param.field %> | <%- param.type %> | <%- param.optional ? '**optional**' : '' %> <%- param.description %> | <%- param.defaultValue %> | <%- param.allowedValues %> | <% }); //forech (group) parameter -%> <% }); //forech param parameter -%> <% } //if parameters -%> From 73e9fe851ac8112497ab4e7a00241044b1531a6e Mon Sep 17 00:00:00 2001 From: Zambonilli Date: Tue, 21 Apr 2015 14:28:52 -0500 Subject: [PATCH 3/5] Issue #5 Add a back to top link on every endpoint for very large APIs --- templates/default.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/default.md b/templates/default.md index 627b463..b0ed761 100644 --- a/templates/default.md +++ b/templates/default.md @@ -1,3 +1,4 @@ + # <%= project.name %> v<%= project.version %> <%= project.description %> @@ -18,6 +19,7 @@ <% Object.keys(data[group]).forEach(function (sub) { -%> ## <%= data[group][sub][0].title %> +[Back to top](#top) <%-: data[group][sub][0].description | undef %> From b8563240e808d62f07bcdebda6712ad124d62392 Mon Sep 17 00:00:00 2001 From: Tinisi Date: Fri, 18 Sep 2015 23:20:38 -0500 Subject: [PATCH 4/5] Several Template fixes: * Added Success params/fields to the output * Removed last two columns for request and success * Moved Allowed, Default into Description block, with c/r and italics * Added size range with same formatting --- templates/default.md | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/templates/default.md b/templates/default.md index b0ed761..5ee1d3a 100644 --- a/templates/default.md +++ b/templates/default.md @@ -40,10 +40,16 @@ ### <%= g %> Parameters -| Name | Type | Description | Default | Allowed | -|:---------|:-----------|:--------------------------------------|:-----------|:-----------| +| Name | Type | Description | +|:---------|:-----------|:--------------------------------------| <% data[group][sub][0].parameter.fields[g].forEach(function (param) { -%> -| <%- param.field %> | <%- param.type %> | <%- param.optional ? '**optional**' : '' %> <%- param.description %> | <%- param.defaultValue %> | <%- param.allowedValues %> | +| <%- param.field %> | <%- param.type %> | <%- param.optional ? '**optional**' : '' %> <%- param.description -%> +<% if (param.defaultValue) { -%> +_Default value: <%= param.defaultValue %>_
<% } -%> +<% if (param.size) { -%> +_Size range: <%- param.size %>_
<% } -%> +<% if (param.allowedValues) { -%> +_Allowed values: <%- param.allowedValues %>_<% } %>| <% }); //forech (group) parameter -%> <% }); //forech param parameter -%> <% } //if parameters -%> @@ -71,6 +77,25 @@ ``` <% }); //foreach success example -%> <% } //if examples -%> + +<% if (data[group][sub][0].success && data[group][sub][0].success.fields) { -%> +<% Object.keys(data[group][sub][0].success.fields).forEach(function(g) { -%> +### <%= g %> + +| Name | Type | Description | +|:---------|:-----------|:--------------------------------------| +<% data[group][sub][0].success.fields[g].forEach(function (param) { -%> +| <%- param.field %> | <%- param.type %> | <%- param.optional ? '**optional**' : '' %><%- param.description -%> +<% if (param.defaultValue) { -%> +_Default value: <%- param.defaultValue %>_
<% } -%> +<% if (param.size) { -%> +_Size range: <%- param.size -%>_
<% } -%> +<% if (param.allowedValues) { -%> +_Allowed values: <%- param.allowedValues %>_<% } %>| +<% }); //forech (group) parameter -%> +<% }); //forech field -%> +<% } //if success.fields -%> + <% if (data[group][sub][0].error && data[group][sub][0].error.examples && data[group][sub][0].error.examples.length) { -%> ### Error Response From 61e8519efc3635702c21ee120e9e9d9184ed0d02 Mon Sep 17 00:00:00 2001 From: Tinisi Date: Fri, 18 Sep 2015 23:27:09 -0500 Subject: [PATCH 5/5] WTF whitespace --- templates/default.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/templates/default.md b/templates/default.md index 5ee1d3a..b71a938 100644 --- a/templates/default.md +++ b/templates/default.md @@ -31,7 +31,7 @@ | Name | Type | Description | |---------|-----------|--------------------------------------| <% data[group][sub][0].header.fields.Header.forEach(function (header) { -%> -| <%- header.field %> | <%- header.type %> | <%- header.optional ? '**optional**' : '' %> <%- header.description %> | +| <%- header.field %> | <%- header.type %> | <%- header.optional ? '**optional**' : '' %><%- header.description %>| <% }); //forech parameter -%> <% } //if parameters -%> <% if (data[group][sub][0].parameter) { -%> @@ -43,7 +43,7 @@ | Name | Type | Description | |:---------|:-----------|:--------------------------------------| <% data[group][sub][0].parameter.fields[g].forEach(function (param) { -%> -| <%- param.field %> | <%- param.type %> | <%- param.optional ? '**optional**' : '' %> <%- param.description -%> +| <%- param.field %> | <%- param.type %> | <%- param.optional ? '**optional**' : '' %><%- param.description -%> <% if (param.defaultValue) { -%> _Default value: <%= param.defaultValue %>_
<% } -%> <% if (param.size) { -%> @@ -54,7 +54,6 @@ _Allowed values: <%- param.allowedValues %>_<% } %>| <% }); //forech param parameter -%> <% } //if parameters -%> <% if (data[group][sub][0].examples && data[group][sub][0].examples.length) { -%> - ### Examples <% data[group][sub][0].examples.forEach(function (example) { -%> @@ -85,7 +84,7 @@ _Allowed values: <%- param.allowedValues %>_<% } %>| | Name | Type | Description | |:---------|:-----------|:--------------------------------------| <% data[group][sub][0].success.fields[g].forEach(function (param) { -%> -| <%- param.field %> | <%- param.type %> | <%- param.optional ? '**optional**' : '' %><%- param.description -%> +| <%- param.field %> | <%- param.type %> | <%- param.optional ? '**optional**' : '' %><%- param.description -%> <% if (param.defaultValue) { -%> _Default value: <%- param.defaultValue %>_
<% } -%> <% if (param.size) { -%>