mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 18:14:07 +03:00
Render externalDocs (resolves #103)
This commit is contained in:
parent
a93cd49123
commit
076fca15a4
|
@ -16,6 +16,7 @@
|
||||||
<a *ngIf="info.license.url" href="{{info.license.url}}"> {{info.license.name}} </a>
|
<a *ngIf="info.license.url" href="{{info.license.url}}"> {{info.license.name}} </a>
|
||||||
<span *ngIf="!info.license.url"> {{info.license.name}} </span>
|
<span *ngIf="!info.license.url"> {{info.license.name}} </span>
|
||||||
</span>
|
</span>
|
||||||
|
<redoc-externalDocs [docs]="componentSchema.externalDocs"></redoc-externalDocs>
|
||||||
</p>
|
</p>
|
||||||
<span class="redoc-markdown-block">
|
<span class="redoc-markdown-block">
|
||||||
<dynamic-ng2-viewer [html]="info['x-redoc-html-description']"></dynamic-ng2-viewer>
|
<dynamic-ng2-viewer [html]="info['x-redoc-html-description']"></dynamic-ng2-viewer>
|
||||||
|
|
18
lib/components/ExternalDocs/external-docs.ts
Normal file
18
lib/components/ExternalDocs/external-docs.ts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
'use strict';
|
||||||
|
import { Component, Input, ChangeDetectionStrategy, OnInit } from '@angular/core';
|
||||||
|
import { BaseComponent, SpecManager } from '../base';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'redoc-externalDocs',
|
||||||
|
template: `<a *ngIf="docs" [href]="docs.url" [innerHtml]="docs.description | marked"></a>`,
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
|
})
|
||||||
|
export class ExternalDocs implements OnInit {
|
||||||
|
@Input() docs;
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
if (this.docs && !this.docs.description) {
|
||||||
|
this.docs.description = 'External Docs';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@
|
||||||
<p *ngIf="method.info.description" class="method-description"
|
<p *ngIf="method.info.description" class="method-description"
|
||||||
[innerHtml]="method.info.description | marked">
|
[innerHtml]="method.info.description | marked">
|
||||||
</p>
|
</p>
|
||||||
|
<redoc-externalDocs [docs]="method.externalDocs"></redoc-externalDocs>
|
||||||
<params-list pointer="{{pointer}}/parameters"> </params-list>
|
<params-list pointer="{{pointer}}/parameters"> </params-list>
|
||||||
<responses-list pointer="{{pointer}}/responses"> </responses-list>
|
<responses-list pointer="{{pointer}}/responses"> </responses-list>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -17,6 +17,10 @@ interface MethodInfo {
|
||||||
bodyParam: any;
|
bodyParam: any;
|
||||||
summary: any;
|
summary: any;
|
||||||
anchor: any;
|
anchor: any;
|
||||||
|
externalDocs: {
|
||||||
|
url: string;
|
||||||
|
description?: string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -50,7 +54,8 @@ export class Method extends BaseComponent implements OnInit {
|
||||||
bodyParam: this.findBodyParam(),
|
bodyParam: this.findBodyParam(),
|
||||||
summary: SchemaHelper.methodSummary(this.componentSchema),
|
summary: SchemaHelper.methodSummary(this.componentSchema),
|
||||||
apiUrl: this.getBaseUrl(),
|
apiUrl: this.getBaseUrl(),
|
||||||
anchor: this.buildAnchor()
|
anchor: this.buildAnchor(),
|
||||||
|
externalDocs: this.componentSchema.externalDocs
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<div class="tag-info" *ngIf="tag.name">
|
<div class="tag-info" *ngIf="tag.name">
|
||||||
<h1 class="sharable-header"> <a class="share-link" href="#{{tag.id}}"></a>{{tag.name}} </h1>
|
<h1 class="sharable-header"> <a class="share-link" href="#{{tag.id}}"></a>{{tag.name}} </h1>
|
||||||
<p *ngIf="tag.description" [innerHtml]="tag.description | marked"> </p>
|
<p *ngIf="tag.description" [innerHtml]="tag.description | marked"> </p>
|
||||||
|
<redoc-externalDocs [docs]="tag.metadata.externalDocs"></redoc-externalDocs>
|
||||||
</div>
|
</div>
|
||||||
<method *lazyFor="let methodItem of tag.items; let ready = ready;"
|
<method *lazyFor="let methodItem of tag.items; let ready = ready;"
|
||||||
[hidden]="!ready" [pointer]="methodItem.metadata.pointer"
|
[hidden]="!ready" [pointer]="methodItem.metadata.pointer"
|
||||||
|
|
|
@ -16,15 +16,16 @@ import { Warnings } from './Warnings/warnings';
|
||||||
import { SecurityDefinitions } from './SecurityDefinitions/security-definitions';
|
import { SecurityDefinitions } from './SecurityDefinitions/security-definitions';
|
||||||
import { LoadingBar } from './LoadingBar/loading-bar';
|
import { LoadingBar } from './LoadingBar/loading-bar';
|
||||||
import { RedocSearch } from './Search/redoc-search';
|
import { RedocSearch } from './Search/redoc-search';
|
||||||
|
import { ExternalDocs } from './ExternalDocs/external-docs';
|
||||||
|
|
||||||
import { Redoc } from './Redoc/redoc';
|
import { Redoc } from './Redoc/redoc';
|
||||||
|
|
||||||
export const REDOC_DIRECTIVES = [
|
export const REDOC_DIRECTIVES = [
|
||||||
ApiInfo, ApiLogo, JsonSchema, JsonSchemaLazy, ParamsList, RequestSamples, ResponsesList,
|
ApiInfo, ApiLogo, JsonSchema, JsonSchemaLazy, ParamsList, RequestSamples, ResponsesList,
|
||||||
ResponsesSamples, SchemaSample, SideMenu, MethodsList, Method, Warnings, Redoc, SecurityDefinitions,
|
ResponsesSamples, SchemaSample, SideMenu, MethodsList, Method, Warnings, Redoc, SecurityDefinitions,
|
||||||
LoadingBar, SideMenuItems, RedocSearch
|
LoadingBar, SideMenuItems, RedocSearch, ExternalDocs
|
||||||
];
|
];
|
||||||
|
|
||||||
export { ApiInfo, ApiLogo, JsonSchema, JsonSchemaLazy, ParamsList, RequestSamples, ResponsesList,
|
export { ApiInfo, ApiLogo, JsonSchema, JsonSchemaLazy, ParamsList, RequestSamples, ResponsesList,
|
||||||
ResponsesSamples, SchemaSample, SideMenu, MethodsList, Method, Warnings, Redoc, SecurityDefinitions,
|
ResponsesSamples, SchemaSample, SideMenu, MethodsList, Method, Warnings, Redoc, SecurityDefinitions,
|
||||||
LoadingBar, SideMenuItems, RedocSearch }
|
LoadingBar, SideMenuItems, RedocSearch, ExternalDocs }
|
||||||
|
|
|
@ -107,7 +107,7 @@ export class MenuService {
|
||||||
|
|
||||||
makeSureLastItemsEnabled() {
|
makeSureLastItemsEnabled() {
|
||||||
let lastIdx = this.flatItems.length - 1;
|
let lastIdx = this.flatItems.length - 1;
|
||||||
let item = this.flatItems[lastIdx]
|
let item = this.flatItems[lastIdx];
|
||||||
while(item && (!item.metadata || !item.items)) {
|
while(item && (!item.metadata || !item.items)) {
|
||||||
item.ready = true;
|
item.ready = true;
|
||||||
item = this.flatItems[lastIdx -= 1];
|
item = this.flatItems[lastIdx -= 1];
|
||||||
|
@ -357,7 +357,7 @@ export class MenuService {
|
||||||
name: tag['x-displayName'] || tag.name,
|
name: tag['x-displayName'] || tag.name,
|
||||||
id: id,
|
id: id,
|
||||||
description: tag.description,
|
description: tag.description,
|
||||||
metadata: { type: 'tag' },
|
metadata: { type: 'tag', externalDocs: tag.externalDocs },
|
||||||
parent: parent,
|
parent: parent,
|
||||||
items: null
|
items: null
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user