mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-28 03:23:44 +03:00
Merge branch 'master' into releases
This commit is contained in:
commit
ffd4255b44
|
@ -36,7 +36,7 @@ before_deploy:
|
||||||
deploy:
|
deploy:
|
||||||
- skip_cleanup: true
|
- skip_cleanup: true
|
||||||
provider: script
|
provider: script
|
||||||
script: ./build/deploy_gh_pages.sh
|
script: npm run deploy
|
||||||
on:
|
on:
|
||||||
branch: master
|
branch: master
|
||||||
condition: $JOB != e2e
|
condition: $JOB != e2e
|
||||||
|
|
|
@ -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
6
build/prepare_deploy.sh
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
cd demo
|
||||||
|
cp -R ../dist ./dist
|
||||||
|
cd -
|
|
@ -1,6 +1,8 @@
|
||||||
<h2 class="param-list-header" *ngIf="data.params.length"> Parameters </h2>
|
<h2 class="param-list-header" *ngIf="data.params.length"> Parameters </h2>
|
||||||
<div class="params-wrap">
|
<template ngFor [ngForOf]="data.params" #paramType="$implicit">
|
||||||
<div *ngFor="#param of data.params" class="param">
|
<header class="paramType"> {{paramType.place}} Parameters </header>
|
||||||
|
<div class="params-wrap">
|
||||||
|
<div *ngFor="#param of paramType.params" class="param">
|
||||||
<div class="param-name">
|
<div class="param-name">
|
||||||
<span class="param-name-content"> {{param.name}} </span>
|
<span class="param-name-content"> {{param.name}} </span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,7 +18,8 @@
|
||||||
<div class="param-description" innerHtml="{{param.description | marked}}"></div>
|
<div class="param-description" innerHtml="{{param.description | marked}}"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<div *ngIf="data.bodyParam">
|
<div *ngIf="data.bodyParam">
|
||||||
<h2 class="param-list-header" *ngIf="data.bodyParam"> Request Body </h2>
|
<h2 class="param-list-header" *ngIf="data.bodyParam"> Request Body </h2>
|
||||||
|
|
|
@ -4,6 +4,11 @@ import {RedocComponent, BaseComponent} from '../base';
|
||||||
import JsonSchema from '../JsonSchema/json-schema';
|
import JsonSchema from '../JsonSchema/json-schema';
|
||||||
import JsonSchemaLazy from '../JsonSchema/json-schema-lazy';
|
import JsonSchemaLazy from '../JsonSchema/json-schema-lazy';
|
||||||
|
|
||||||
|
function safePush(obj, prop, item) {
|
||||||
|
if (!obj[prop]) obj[prop] = [];
|
||||||
|
obj[prop].push(item);
|
||||||
|
}
|
||||||
|
|
||||||
@RedocComponent({
|
@RedocComponent({
|
||||||
selector: 'params-list',
|
selector: 'params-list',
|
||||||
templateUrl: './lib/components/ParamsList/params-list.html',
|
templateUrl: './lib/components/ParamsList/params-list.html',
|
||||||
|
@ -17,34 +22,37 @@ export default class ParamsList extends BaseComponent {
|
||||||
|
|
||||||
prepareModel() {
|
prepareModel() {
|
||||||
this.data = {};
|
this.data = {};
|
||||||
let params = this.schemaMgr.getMethodParams(this.pointer, true);
|
let paramsList = this.schemaMgr.getMethodParams(this.pointer, true);
|
||||||
this.sortParams(params);
|
|
||||||
|
|
||||||
// temporary handle body param
|
paramsList = paramsList.map((paramData) => {
|
||||||
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) => {
|
|
||||||
let propPointer = paramData._pointer;
|
let propPointer = paramData._pointer;
|
||||||
return JsonSchema.injectPropData(paramData, paramData.name, propPointer);
|
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;
|
this.data.params = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
sortParams(params) {
|
orderParams(params) {
|
||||||
const sortOrder = {
|
let res = {};
|
||||||
'path' : 0,
|
params.forEach((param) => safePush(res, param.in, param));
|
||||||
'query' : 10,
|
return res;
|
||||||
'formData' : 20,
|
|
||||||
'header': 40,
|
|
||||||
'body': 50
|
|
||||||
};
|
|
||||||
|
|
||||||
params.sort((a, b) => sortOrder[a.in] - sortOrder[b.in]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,15 @@
|
||||||
|
|
||||||
@import '../JsonSchema/json-schema-common';
|
@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
|
// paramters can't be multilevel so table representation works for it without javascript
|
||||||
.params-wrap {
|
.params-wrap {
|
||||||
display: table;
|
display: table;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.param-name {
|
.param-name {
|
||||||
|
@ -22,6 +27,7 @@
|
||||||
|
|
||||||
.param-info {
|
.param-info {
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.param {
|
.param {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "redoc",
|
"name": "redoc",
|
||||||
"description": "Swagger-generated API Reference Documentation",
|
"description": "Swagger-generated API Reference Documentation",
|
||||||
"version": "0.6.0",
|
"version": "0.6.1",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/Rebilly/ReDoc"
|
"url": "git://github.com/Rebilly/ReDoc"
|
||||||
|
@ -14,7 +14,8 @@
|
||||||
"build-dist": "gulp build",
|
"build-dist": "gulp build",
|
||||||
"branch-release": "git reset --hard && branch-release",
|
"branch-release": "git reset --hard && branch-release",
|
||||||
"unit": "gulp test",
|
"unit": "gulp test",
|
||||||
"e2e": "gulp e2e"
|
"e2e": "gulp e2e",
|
||||||
|
"deploy": "build/prepare_deploy.sh && deploy-to-gh-pages demo"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Swagger",
|
"Swagger",
|
||||||
|
@ -55,6 +56,7 @@
|
||||||
"branch-release": "^0.3.1",
|
"branch-release": "^0.3.1",
|
||||||
"browser-sync": "^2.10.1",
|
"browser-sync": "^2.10.1",
|
||||||
"del": "^2.2.0",
|
"del": "^2.2.0",
|
||||||
|
"deploy-to-gh-pages": "^1.0.0",
|
||||||
"gulp": "^3.9.0",
|
"gulp": "^3.9.0",
|
||||||
"gulp-concat": "^2.6.0",
|
"gulp-concat": "^2.6.0",
|
||||||
"gulp-eslint": "^1.1.1",
|
"gulp-eslint": "^1.1.1",
|
||||||
|
|
|
@ -60,6 +60,7 @@ describe('APIs.guru specs test', ()=> {
|
||||||
delete apisGuruList['learnifier.com']; // allof object and no type
|
delete apisGuruList['learnifier.com']; // allof object and no type
|
||||||
delete apisGuruList['googleapis.com:mirror']; // bad urls in images
|
delete apisGuruList['googleapis.com:mirror']; // bad urls in images
|
||||||
delete apisGuruList['googleapis.com:discovery']; // non-string references
|
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
|
// run quick version of e2e test on all builds except releases
|
||||||
if (process.env.TRAVIS && !process.env.TRAVIS_TAG) {
|
if (process.env.TRAVIS && !process.env.TRAVIS_TAG) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user