mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-29 00:54:09 +03:00
Add download swagger button (#1)
This commit is contained in:
parent
544e24a524
commit
dcd9983ce8
|
@ -14,4 +14,8 @@
|
|||
<span *ngIf="!data.license.url"> {{data.license.name}} </span>
|
||||
</span>
|
||||
</p>
|
||||
<p>
|
||||
Download OpenAPI (fka Swagger) specification:
|
||||
<a class="openapi-button" target="_blank" attr.href='{{specUrl}}'> Download </a>
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
'use strict';
|
||||
|
||||
import {RedocComponent, BaseComponent} from '../base';
|
||||
import {SchemaManager, RedocComponent, BaseComponent} from '../base';
|
||||
import OptionsManager from '../../options';
|
||||
|
||||
@RedocComponent({
|
||||
selector: 'api-info',
|
||||
styleUrls: ['./lib/components/ApiInfo/api-info.css'],
|
||||
templateUrl: './lib/components/ApiInfo/api-info.html'
|
||||
})
|
||||
@Reflect.metadata('parameters', [[SchemaManager], [OptionsManager]])
|
||||
export default class ApiInfo extends BaseComponent {
|
||||
constructor(schemaMgr) {
|
||||
constructor(schemaMgr, optionsMgr) {
|
||||
super(schemaMgr);
|
||||
this.optionsMgr = optionsMgr;
|
||||
}
|
||||
|
||||
prepareModel() {
|
||||
this.data = this.componentSchema.info;
|
||||
this.specUrl = this.optionsMgr.options.specUrl;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,9 +57,10 @@ export default class Redoc extends BaseComponent {
|
|||
}, 400);
|
||||
}
|
||||
|
||||
static init(schemaUrl, options) {
|
||||
static init(specUrl, options) {
|
||||
var optionsMgr = new OptionsManager();
|
||||
optionsMgr.options = options;
|
||||
optionsMgr.options.specUrl = optionsMgr.options.specUrl || specUrl;
|
||||
var providers = [
|
||||
provide(OptionsManager, {useValue: optionsMgr})
|
||||
];
|
||||
|
@ -68,7 +69,7 @@ export default class Redoc extends BaseComponent {
|
|||
Redoc.dispose();
|
||||
}
|
||||
Redoc.showLoadingAnimation();
|
||||
return SchemaManager.instance().load(schemaUrl)
|
||||
return SchemaManager.instance().load(specUrl)
|
||||
.then(() => {
|
||||
if (!_modeLocked && !optionsMgr.options.debugMode) {
|
||||
enableProdMode();
|
||||
|
|
|
@ -10,7 +10,7 @@ var defaults = {
|
|||
debugMode: global.redocDebugMode
|
||||
};
|
||||
|
||||
var OPTION_NAMES = new Set(['scrollYOffset', 'disableLazySchemas']);
|
||||
var OPTION_NAMES = new Set(['scrollYOffset', 'disableLazySchemas', 'specUrl']);
|
||||
|
||||
@Reflect.metadata('parameters', [[BrowserDomAdapter]])
|
||||
export default class OptionsManager {
|
||||
|
|
Loading…
Reference in New Issue
Block a user