mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-28 11:33:43 +03:00
Merge branch 'master' into releases
This commit is contained in:
commit
14750d020b
|
@ -59,8 +59,8 @@ export default class JsonSchema extends BaseComponent {
|
||||||
this.pointer = schema._pointer || this.pointer;
|
this.pointer = schema._pointer || this.pointer;
|
||||||
|
|
||||||
this.requiredMap = {};
|
this.requiredMap = {};
|
||||||
if (this.schema.required) {
|
if (this.componentSchema.required) {
|
||||||
this.schema.required.forEach(prop => this.requiredMap[prop] = true);
|
this.componentSchema.required.forEach(prop => this.requiredMap[prop] = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!schema.properties) {
|
if (!schema.properties) {
|
||||||
|
@ -108,15 +108,18 @@ export default class JsonSchema extends BaseComponent {
|
||||||
propData.format = itemFormat;
|
propData.format = itemFormat;
|
||||||
propData._isArray = true;
|
propData._isArray = true;
|
||||||
propData.type = 'array ' + propData.items.type;
|
propData.type = 'array ' + propData.items.type;
|
||||||
}
|
} else if (propData.type === 'object') {
|
||||||
|
|
||||||
if (propData.type === 'object') {
|
|
||||||
propData._displayType = propData.title || 'object';
|
propData._displayType = propData.title || 'object';
|
||||||
}
|
} else if (!propData.type) {
|
||||||
|
|
||||||
if (!propData.type) {
|
|
||||||
propData._displayType = '< * >';
|
propData._displayType = '< * >';
|
||||||
propData._displayTypeHint = 'This field may contain data of any type';
|
propData._displayTypeHint = 'This field may contain data of any type';
|
||||||
|
} else {
|
||||||
|
// here we are sure that property has simple type
|
||||||
|
// delete pointer for simple types to not show it as subschema
|
||||||
|
if (propData._pointer) {
|
||||||
|
propData._pointer = undefined;
|
||||||
|
propData._displayType = propData.title ? `${propData.title} (${propData.type})` : propData.type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (propData.format) propData._displayFormat = `<${propData.format}>`;
|
if (propData.format) propData._displayFormat = `<${propData.format}>`;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="method">
|
<div class="method">
|
||||||
<div class="method-content">
|
<div class="method-content">
|
||||||
<h2 class="method-header sharable-header">
|
<h2 class="method-header sharable-header">
|
||||||
<a class="share-link" href="#{{data.methodAnchor}}"></a>{{data.methodInfo.summary}}
|
<a class="share-link" href="#{{data.methodAnchor | encodeURIComponent }}"></a>{{data.methodInfo.summary}}
|
||||||
</h2>
|
</h2>
|
||||||
<h3 class="method-endpoint">
|
<h3 class="method-endpoint">
|
||||||
<span class="http-method" [ngClass]="data.httpMethod">{{data.httpMethod}}</span>
|
<span class="http-method" [ngClass]="data.httpMethod">{{data.httpMethod}}</span>
|
||||||
|
|
|
@ -8,13 +8,15 @@ import ResponsesList from '../ResponsesList/responses-list';
|
||||||
import ResponsesSamples from '../ResponsesSamples/responses-samples';
|
import ResponsesSamples from '../ResponsesSamples/responses-samples';
|
||||||
import SchemaSample from '../SchemaSample/schema-sample';
|
import SchemaSample from '../SchemaSample/schema-sample';
|
||||||
import RequestSamples from '../RequestSamples/request-samples';
|
import RequestSamples from '../RequestSamples/request-samples';
|
||||||
|
import {EncodeURIComponentPipe} from '../../utils/pipes';
|
||||||
|
|
||||||
@RedocComponent({
|
@RedocComponent({
|
||||||
selector: 'method',
|
selector: 'method',
|
||||||
templateUrl: './lib/components/Method/method.html',
|
templateUrl: './lib/components/Method/method.html',
|
||||||
styleUrls: ['./lib/components/Method/method.css'],
|
styleUrls: ['./lib/components/Method/method.css'],
|
||||||
directives: [ParamsList, ResponsesList, ResponsesSamples, SchemaSample, RequestSamples],
|
directives: [ParamsList, ResponsesList, ResponsesSamples, SchemaSample, RequestSamples],
|
||||||
inputs: ['tag']
|
inputs: ['tag'],
|
||||||
|
pipes: [EncodeURIComponentPipe]
|
||||||
})
|
})
|
||||||
export default class Method extends BaseComponent {
|
export default class Method extends BaseComponent {
|
||||||
constructor(schemaMgr) {
|
constructor(schemaMgr) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="methods">
|
<div class="methods">
|
||||||
<div class="tag" *ngFor="#tag of data.tags">
|
<div class="tag" *ngFor="#tag of data.tags">
|
||||||
<div class="tag-info" [attr.tag]="tag.name">
|
<div class="tag-info" [attr.tag]="tag.name">
|
||||||
<h1 class="sharable-header"> <a class="share-link" href="#tag/{{tag.name}}"></a>{{tag.name}} </h1>
|
<h1 class="sharable-header"> <a class="share-link" href="#tag/{{tag.name | encodeURIComponent}}"></a>{{tag.name}} </h1>
|
||||||
<p *ngIf="tag.description" innerHtml="{{ tag.description | marked }}"> </p>
|
<p *ngIf="tag.description" innerHtml="{{ tag.description | marked }}"> </p>
|
||||||
</div>
|
</div>
|
||||||
<method *ngFor="#method of tag.methods" [pointer]="method.pointer" [attr.pointer]="method.pointer"
|
<method *ngFor="#method of tag.methods" [pointer]="method.pointer" [attr.pointer]="method.pointer"
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
|
|
||||||
import {RedocComponent, BaseComponent} from '../base';
|
import {RedocComponent, BaseComponent} from '../base';
|
||||||
import Method from '../Method/method';
|
import Method from '../Method/method';
|
||||||
|
import {EncodeURIComponentPipe} from '../../utils/pipes';
|
||||||
|
|
||||||
@RedocComponent({
|
@RedocComponent({
|
||||||
selector: 'methods-list',
|
selector: 'methods-list',
|
||||||
templateUrl: './lib/components/MethodsList/methods-list.html',
|
templateUrl: './lib/components/MethodsList/methods-list.html',
|
||||||
styleUrls: ['./lib/components/MethodsList/methods-list.css'],
|
styleUrls: ['./lib/components/MethodsList/methods-list.css'],
|
||||||
directives: [Method]
|
directives: [Method],
|
||||||
|
pipes: [EncodeURIComponentPipe]
|
||||||
})
|
})
|
||||||
export default class MethodsList extends BaseComponent {
|
export default class MethodsList extends BaseComponent {
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ export default class ParamsList extends BaseComponent {
|
||||||
|
|
||||||
paramsList = paramsList.map((paramData) => {
|
paramsList = paramsList.map((paramData) => {
|
||||||
let propPointer = paramData._pointer;
|
let propPointer = paramData._pointer;
|
||||||
|
if (paramData.in === 'body') return paramData;
|
||||||
return JsonSchema.injectPropData(paramData, paramData.name, propPointer);
|
return JsonSchema.injectPropData(paramData, paramData.name, propPointer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ export default class ParamsList extends BaseComponent {
|
||||||
let bodyParam = paramsMap.body[0];
|
let bodyParam = paramsMap.body[0];
|
||||||
bodyParam.pointer = bodyParam._pointer;
|
bodyParam.pointer = bodyParam._pointer;
|
||||||
this.data.bodyParam = bodyParam;
|
this.data.bodyParam = bodyParam;
|
||||||
delete paramsMap.body;
|
paramsMap.body = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.data.noParams = !(Object.keys(paramsMap).length || this.data.bodyParam);
|
this.data.noParams = !(Object.keys(paramsMap).length || this.data.bodyParam);
|
||||||
|
|
|
@ -62,7 +62,7 @@ export default class SideMenu extends BaseComponent {
|
||||||
let $el;
|
let $el;
|
||||||
hash = hash.substr(1);
|
hash = hash.substr(1);
|
||||||
let namespace = hash.split('/')[0];
|
let namespace = hash.split('/')[0];
|
||||||
let ptr = hash.substr(namespace.length + 1);
|
let ptr = decodeURIComponent(hash.substr(namespace.length + 1));
|
||||||
if (namespace === 'operation') {
|
if (namespace === 'operation') {
|
||||||
$el = this.getMethodElByOperId(ptr);
|
$el = this.getMethodElByOperId(ptr);
|
||||||
} else if (namespace === 'tag') {
|
} else if (namespace === 'tag') {
|
||||||
|
|
|
@ -118,3 +118,14 @@ export class PrismPipe {
|
||||||
return Prism.highlight(value, grammar);
|
return Prism.highlight(value, grammar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Pipe({ name: 'encodeURIComponent' })
|
||||||
|
export class EncodeURIComponentPipe {
|
||||||
|
transform(value) {
|
||||||
|
if (isBlank(value)) return value;
|
||||||
|
if (!isString(value)) {
|
||||||
|
throw new InvalidPipeArgumentException(EncodeURIComponentPipe, value);
|
||||||
|
}
|
||||||
|
return encodeURIComponent(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "redoc",
|
"name": "redoc",
|
||||||
"description": "Swagger-generated API Reference Documentation",
|
"description": "Swagger-generated API Reference Documentation",
|
||||||
"version": "0.6.2",
|
"version": "0.6.3",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/Rebilly/ReDoc"
|
"url": "git://github.com/Rebilly/ReDoc"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user