Add download swagger button (#1)

This commit is contained in:
Roman Hotsiy 2016-03-31 00:20:31 +03:00
parent 544e24a524
commit dcd9983ce8
4 changed files with 14 additions and 5 deletions

View File

@ -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>

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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 {