-
- {{param.name}}
-
-
-
-
{{param._displayType}} {{param._displayFormat}}
-
Required
-
- {{enumItem.val | json}}
-
+
+ {{paramType.place}} Parameters
+
+
+
+
+
{{param._displayType}} {{param._displayFormat}}
+
Required
+
+ {{enumItem.val | json}}
+
+
+
+
+
-
+
diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.js
index d027db7c..1a053b5b 100644
--- a/lib/components/ParamsList/params-list.js
+++ b/lib/components/ParamsList/params-list.js
@@ -4,6 +4,11 @@ import {RedocComponent, BaseComponent} from '../base';
import JsonSchema from '../JsonSchema/json-schema';
import JsonSchemaLazy from '../JsonSchema/json-schema-lazy';
+function safePush(obj, prop, item) {
+ if (!obj[prop]) obj[prop] = [];
+ obj[prop].push(item);
+}
+
@RedocComponent({
selector: 'params-list',
templateUrl: './lib/components/ParamsList/params-list.html',
@@ -17,34 +22,37 @@ export default class ParamsList extends BaseComponent {
prepareModel() {
this.data = {};
- let params = this.schemaMgr.getMethodParams(this.pointer, true);
- this.sortParams(params);
+ let paramsList = this.schemaMgr.getMethodParams(this.pointer, true);
- // temporary handle body param
- if (params.length && params[params.length - 1].in === 'body') {
- let bodyParam = params.pop();
- bodyParam.pointer = bodyParam._pointer;
- this.data.bodyParam = bodyParam;
- }
-
- params = params.map((paramData) => {
+ paramsList = paramsList.map((paramData) => {
let propPointer = paramData._pointer;
return JsonSchema.injectPropData(paramData, paramData.name, propPointer);
});
- this.data.noParams = !(params.length || this.data.bodyParam);
+ let paramsMap = this.orderParams(paramsList);
+
+ if (paramsMap.body && paramsMap.body.length) {
+ let bodyParam = paramsMap.body[0];
+ bodyParam.pointer = bodyParam._pointer;
+ this.data.bodyParam = bodyParam;
+ delete paramsMap.body;
+ }
+
+ this.data.noParams = !(Object.keys(paramsMap).length || this.data.bodyParam);
+
+ let paramsPlaces = ['path', 'query', 'formData', 'header', 'body'];
+ let params = [];
+ paramsPlaces.forEach(place => {
+ if (paramsMap[place] && paramsMap[place].length) {
+ params.push({place: place, params: paramsMap[place]});
+ }
+ });
this.data.params = params;
}
- sortParams(params) {
- const sortOrder = {
- 'path' : 0,
- 'query' : 10,
- 'formData' : 20,
- 'header': 40,
- 'body': 50
- };
-
- params.sort((a, b) => sortOrder[a.in] - sortOrder[b.in]);
+ orderParams(params) {
+ let res = {};
+ params.forEach((param) => safePush(res, param.in, param));
+ return res;
}
}
diff --git a/lib/components/ParamsList/params-list.scss b/lib/components/ParamsList/params-list.scss
index 2475d8f7..9f8603c6 100644
--- a/lib/components/ParamsList/params-list.scss
+++ b/lib/components/ParamsList/params-list.scss
@@ -9,10 +9,15 @@
@import '../JsonSchema/json-schema-common';
+header.paramType {
+ margin: 10px 0;
+ text-transform: capitalize;
+}
// paramters can't be multilevel so table representation works for it without javascript
.params-wrap {
display: table;
+ width: 100%;
}
.param-name {
@@ -22,6 +27,7 @@
.param-info {
display: table-cell;
+ width: 100%;
}
.param {
diff --git a/package.json b/package.json
index 47ac0303..9881d8c5 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "redoc",
"description": "Swagger-generated API Reference Documentation",
- "version": "0.6.0",
+ "version": "0.6.1",
"repository": {
"type": "git",
"url": "git://github.com/Rebilly/ReDoc"
@@ -14,7 +14,8 @@
"build-dist": "gulp build",
"branch-release": "git reset --hard && branch-release",
"unit": "gulp test",
- "e2e": "gulp e2e"
+ "e2e": "gulp e2e",
+ "deploy": "build/prepare_deploy.sh && deploy-to-gh-pages demo"
},
"keywords": [
"Swagger",
@@ -55,6 +56,7 @@
"branch-release": "^0.3.1",
"browser-sync": "^2.10.1",
"del": "^2.2.0",
+ "deploy-to-gh-pages": "^1.0.0",
"gulp": "^3.9.0",
"gulp-concat": "^2.6.0",
"gulp-eslint": "^1.1.1",
diff --git a/tests/e2e/redoc.spec.js b/tests/e2e/redoc.spec.js
index f6f3629a..c767db9b 100644
--- a/tests/e2e/redoc.spec.js
+++ b/tests/e2e/redoc.spec.js
@@ -60,6 +60,7 @@ describe('APIs.guru specs test', ()=> {
delete apisGuruList['learnifier.com']; // allof object and no type
delete apisGuruList['googleapis.com:mirror']; // bad urls in images
delete apisGuruList['googleapis.com:discovery']; // non-string references
+ delete apisGuruList['clarify.io']; // non-string references
// run quick version of e2e test on all builds except releases
if (process.env.TRAVIS && !process.env.TRAVIS_TAG) {