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