mirror of
				https://github.com/Redocly/redoc.git
				synced 2025-11-04 01:37:32 +03:00 
			
		
		
		
	fix: don't show download button if initialized with an object
This commit is contained in:
		
							parent
							
								
									0f6f0359d9
								
							
						
					
					
						commit
						476d6c44fe
					
				| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
<div class="api-info-wrapper">
 | 
			
		||||
  <h1>{{info.title}} <span class="api-info-version">({{info.version}})</span></h1>
 | 
			
		||||
  <p>
 | 
			
		||||
  <p class="donwload-openapi" *ngIf="specUrl">
 | 
			
		||||
    Download OpenAPI (fka Swagger) specification:
 | 
			
		||||
    <a class="openapi-button" target="_blank" attr.href='{{specUrl}}'> Download </a>
 | 
			
		||||
  </p>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,7 @@ export class ApiInfo extends BaseComponent implements OnInit {
 | 
			
		|||
 | 
			
		||||
  init() {
 | 
			
		||||
    this.info = this.componentSchema.info;
 | 
			
		||||
    this.specUrl = this.optionsService.options.specUrl;
 | 
			
		||||
    this.specUrl = this.specMgr.specUrl;
 | 
			
		||||
    if (!isNaN(parseInt(this.info.version.toString().substring(0, 1)))) {
 | 
			
		||||
      this.info.version = 'v' + this.info.version;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,7 +32,7 @@ export class SpecManager {
 | 
			
		|||
  public basePath: string;
 | 
			
		||||
 | 
			
		||||
  public spec = new BehaviorSubject<any|null>(null);
 | 
			
		||||
  public _specUrl: string;
 | 
			
		||||
  public specUrl: string;
 | 
			
		||||
  private parser: any;
 | 
			
		||||
  private options: Options;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -46,7 +46,7 @@ export class SpecManager {
 | 
			
		|||
      this.parser.bundle(urlOrObject, {http: {withCredentials: false}})
 | 
			
		||||
      .then(schema => {
 | 
			
		||||
        if (typeof urlOrObject === 'string') {
 | 
			
		||||
          this._specUrl = urlOrObject;
 | 
			
		||||
          this.specUrl = urlOrObject;
 | 
			
		||||
        }
 | 
			
		||||
        this._schema = snapshot(schema);
 | 
			
		||||
        try {
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +64,7 @@ export class SpecManager {
 | 
			
		|||
 | 
			
		||||
  /* calculate common used values */
 | 
			
		||||
  init() {
 | 
			
		||||
    let urlParts = this._specUrl ? urlParse(urlResolve(window.location.href, this._specUrl)) : {};
 | 
			
		||||
    let urlParts = this.specUrl ? urlParse(urlResolve(window.location.href, this.specUrl)) : {};
 | 
			
		||||
    let schemes = this._schema.schemes;
 | 
			
		||||
    let protocol;
 | 
			
		||||
    if (!schemes || !schemes.length) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,21 +46,21 @@ describe('Utils', () => {
 | 
			
		|||
 | 
			
		||||
      it('should substitute api scheme when spec schemes are undefined', () => {
 | 
			
		||||
        specMgr._schema.schemes = undefined;
 | 
			
		||||
        specMgr._specUrl = 'https://petstore.swagger.io/v2';
 | 
			
		||||
        specMgr.specUrl = 'https://petstore.swagger.io/v2';
 | 
			
		||||
        specMgr.init();
 | 
			
		||||
        specMgr.apiUrl.should.be.equal('https://petstore.swagger.io/v2');
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
      it('should substitute api host when spec host is undefined', () => {
 | 
			
		||||
        specMgr._schema.host = undefined;
 | 
			
		||||
        specMgr._specUrl = 'http://petstore.swagger.io/v2';
 | 
			
		||||
        specMgr.specUrl = 'http://petstore.swagger.io/v2';
 | 
			
		||||
        specMgr.init();
 | 
			
		||||
        specMgr.apiUrl.should.be.equal('http://petstore.swagger.io/v2');
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
      it('should use empty basePath when basePath is not present', () => {
 | 
			
		||||
        specMgr._schema.basePath = undefined;
 | 
			
		||||
        specMgr._specUrl = 'https://petstore.swagger.io';
 | 
			
		||||
        specMgr.specUrl = 'https://petstore.swagger.io';
 | 
			
		||||
        specMgr.init();
 | 
			
		||||
        specMgr.basePath.should.be.equal('');
 | 
			
		||||
      });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user