Merge branch 'master' into releases

This commit is contained in:
Roman Hotsiy 2016-02-23 13:57:06 +02:00
commit ffd4255b44
8 changed files with 66 additions and 54 deletions

View File

@ -36,7 +36,7 @@ before_deploy:
deploy:
- skip_cleanup: true
provider: script
script: ./build/deploy_gh_pages.sh
script: npm run deploy
on:
branch: master
condition: $JOB != e2e

View File

@ -1,14 +0,0 @@
#!/bin/bash
set -o pipefail
(
set -e
set -x
cd demo
git init
git config user.name "Travis-CI"
git config user.email "travis@travis"
cp -r ../dist ./dist
git add .
git commit -m "Deployed to Github Pages"
git push --force "https://${GH_TOKEN}@${GH_REF}" master:gh-pages 2>&1
) 2>&1 | sed "s/${GH_TOKEN}/xxPASSxx/"

6
build/prepare_deploy.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e
set -x
cd demo
cp -R ../dist ./dist
cd -

View File

@ -1,22 +1,25 @@
<h2 class="param-list-header" *ngIf="data.params.length"> Parameters </h2>
<div class="params-wrap">
<div *ngFor="#param of data.params" class="param">
<div class="param-name">
<span class="param-name-content"> {{param.name}} </span>
</div>
<div class="param-info">
<div>
<span class="param-type {{param.type}}" [ngClass]="{'with-hint': param._displayTypeHint}"
title="{{param._displayTypeHint}}"> {{param._displayType}} {{param._displayFormat}}</span>
<span *ngIf="param.required" class="param-required">Required</span>
<div *ngIf="param.enum" class="param-enum">
<span *ngFor="#enumItem of param.enum" class="enum-value {{enumItem.type}}"> {{enumItem.val | json}} </span>
</div>
<template ngFor [ngForOf]="data.params" #paramType="$implicit">
<header class="paramType"> {{paramType.place}} Parameters </header>
<div class="params-wrap">
<div *ngFor="#param of paramType.params" class="param">
<div class="param-name">
<span class="param-name-content"> {{param.name}} </span>
</div>
<div class="param-description" innerHtml="{{param.description | marked}}"></div>
</div>
<div class="param-info">
<div>
<span class="param-type {{param.type}}" [ngClass]="{'with-hint': param._displayTypeHint}"
title="{{param._displayTypeHint}}"> {{param._displayType}} {{param._displayFormat}}</span>
<span *ngIf="param.required" class="param-required">Required</span>
<div *ngIf="param.enum" class="param-enum">
<span *ngFor="#enumItem of param.enum" class="enum-value {{enumItem.type}}"> {{enumItem.val | json}} </span>
</div>
</div>
<div class="param-description" innerHtml="{{param.description | marked}}"></div>
</div>
</div>
</div>
</div>
</template>
<div *ngIf="data.bodyParam">
<h2 class="param-list-header" *ngIf="data.bodyParam"> Request Body </h2>

View File

@ -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;
}
}

View File

@ -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 {

View File

@ -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",

View File

@ -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) {