mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 10:04:08 +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>
|
||||
<span *ngIf="!info.license.url"> {{info.license.name}} </span>
|
||||
</span>
|
||||
<redoc-externalDocs [docs]="componentSchema.externalDocs"></redoc-externalDocs>
|
||||
</p>
|
||||
<span class="redoc-markdown-block">
|
||||
<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"
|
||||
[innerHtml]="method.info.description | marked">
|
||||
</p>
|
||||
<redoc-externalDocs [docs]="method.externalDocs"></redoc-externalDocs>
|
||||
<params-list pointer="{{pointer}}/parameters"> </params-list>
|
||||
<responses-list pointer="{{pointer}}/responses"> </responses-list>
|
||||
</div>
|
||||
|
|
|
@ -17,6 +17,10 @@ interface MethodInfo {
|
|||
bodyParam: any;
|
||||
summary: any;
|
||||
anchor: any;
|
||||
externalDocs: {
|
||||
url: string;
|
||||
description?: string;
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
|
@ -50,7 +54,8 @@ export class Method extends BaseComponent implements OnInit {
|
|||
bodyParam: this.findBodyParam(),
|
||||
summary: SchemaHelper.methodSummary(this.componentSchema),
|
||||
apiUrl: this.getBaseUrl(),
|
||||
anchor: this.buildAnchor()
|
||||
anchor: this.buildAnchor(),
|
||||
externalDocs: this.componentSchema.externalDocs
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<div class="tag-info" *ngIf="tag.name">
|
||||
<h1 class="sharable-header"> <a class="share-link" href="#{{tag.id}}"></a>{{tag.name}} </h1>
|
||||
<p *ngIf="tag.description" [innerHtml]="tag.description | marked"> </p>
|
||||
<redoc-externalDocs [docs]="tag.metadata.externalDocs"></redoc-externalDocs>
|
||||
</div>
|
||||
<method *lazyFor="let methodItem of tag.items; let ready = ready;"
|
||||
[hidden]="!ready" [pointer]="methodItem.metadata.pointer"
|
||||
|
|
|
@ -16,15 +16,16 @@ import { Warnings } from './Warnings/warnings';
|
|||
import { SecurityDefinitions } from './SecurityDefinitions/security-definitions';
|
||||
import { LoadingBar } from './LoadingBar/loading-bar';
|
||||
import { RedocSearch } from './Search/redoc-search';
|
||||
import { ExternalDocs } from './ExternalDocs/external-docs';
|
||||
|
||||
import { Redoc } from './Redoc/redoc';
|
||||
|
||||
export const REDOC_DIRECTIVES = [
|
||||
ApiInfo, ApiLogo, JsonSchema, JsonSchemaLazy, ParamsList, RequestSamples, ResponsesList,
|
||||
ResponsesSamples, SchemaSample, SideMenu, MethodsList, Method, Warnings, Redoc, SecurityDefinitions,
|
||||
LoadingBar, SideMenuItems, RedocSearch
|
||||
LoadingBar, SideMenuItems, RedocSearch, ExternalDocs
|
||||
];
|
||||
|
||||
export { ApiInfo, ApiLogo, JsonSchema, JsonSchemaLazy, ParamsList, RequestSamples, ResponsesList,
|
||||
ResponsesSamples, SchemaSample, SideMenu, MethodsList, Method, Warnings, Redoc, SecurityDefinitions,
|
||||
LoadingBar, SideMenuItems, RedocSearch }
|
||||
LoadingBar, SideMenuItems, RedocSearch, ExternalDocs }
|
||||
|
|
|
@ -107,7 +107,7 @@ export class MenuService {
|
|||
|
||||
makeSureLastItemsEnabled() {
|
||||
let lastIdx = this.flatItems.length - 1;
|
||||
let item = this.flatItems[lastIdx]
|
||||
let item = this.flatItems[lastIdx];
|
||||
while(item && (!item.metadata || !item.items)) {
|
||||
item.ready = true;
|
||||
item = this.flatItems[lastIdx -= 1];
|
||||
|
@ -357,7 +357,7 @@ export class MenuService {
|
|||
name: tag['x-displayName'] || tag.name,
|
||||
id: id,
|
||||
description: tag.description,
|
||||
metadata: { type: 'tag' },
|
||||
metadata: { type: 'tag', externalDocs: tag.externalDocs },
|
||||
parent: parent,
|
||||
items: null
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user