diff --git a/lib/components/ApiInfo/api-info.html b/lib/components/ApiInfo/api-info.html index 05765f17..8083a884 100644 --- a/lib/components/ApiInfo/api-info.html +++ b/lib/components/ApiInfo/api-info.html @@ -14,4 +14,8 @@ {{data.license.name}}
++ Download OpenAPI (fka Swagger) specification: + Download +
diff --git a/lib/components/ApiInfo/api-info.js b/lib/components/ApiInfo/api-info.js index d179dae9..8fd9391c 100644 --- a/lib/components/ApiInfo/api-info.js +++ b/lib/components/ApiInfo/api-info.js @@ -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; } } diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index 4faa1353..e1bceb4b 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -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(); diff --git a/lib/options.js b/lib/options.js index 689310a5..d708b86c 100644 --- a/lib/options.js +++ b/lib/options.js @@ -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 {