This repository was archived by the owner on Jun 18, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1
1
< h1 > {{ info?.title }}</ h1 >
2
- < h5 > API VERSION {{ info?.version }}</ h5 >
3
- < p *ngIf ="info?.description "> {{ info.description }}</ p >
2
+ < h5 >
3
+ API VERSION {{ info?.version }}
4
+ -
5
+ < a href ="# " (click) ="download() "> AsyncAPI JSON file</ a >
6
+ </ h5 >
7
+ < p *ngIf ="info?.description "> {{ info.description }}</ p >
Original file line number Diff line number Diff line change 1
1
import { Component , OnInit } from '@angular/core' ;
2
+ import { AsyncApi } from '../shared/models/asyncapi.model' ;
2
3
import { Info } from '../shared/models/info.model' ;
3
4
import { AsyncApiService } from '../shared/asyncapi.service' ;
4
5
import { Subscription } from 'rxjs' ;
@@ -10,15 +11,29 @@ import { Subscription } from 'rxjs';
10
11
} )
11
12
export class InfoComponent implements OnInit {
12
13
14
+ asyncApiData : AsyncApi ;
13
15
info : Info ;
14
16
nameSubscription : Subscription ;
15
17
16
18
constructor ( private asyncApiService : AsyncApiService ) { }
17
19
18
20
ngOnInit ( ) : void {
19
21
this . nameSubscription = this . asyncApiService . getCurrentAsyncApiName ( ) . subscribe ( name => {
20
- this . asyncApiService . getAsyncApis ( ) . subscribe ( asyncapi => this . info = asyncapi . get ( name ) . info ) ;
22
+ this . asyncApiService . getAsyncApis ( ) . subscribe ( asyncapi => {
23
+ this . asyncApiData = asyncapi . get ( name ) ;
24
+ this . info = asyncapi . get ( name ) . info ;
25
+ } ) ;
21
26
} ) ;
22
27
}
23
28
29
+ async download ( ) : Promise < Boolean > {
30
+ var json = JSON . stringify ( this . asyncApiData , null , 2 ) ;
31
+ var bytes = new TextEncoder ( ) . encode ( json ) ;
32
+ var blob = new Blob ( [ bytes ] , { type : 'application/json' } ) ;
33
+ var url = window . URL . createObjectURL ( blob ) ;
34
+ window . open ( url ) ;
35
+
36
+ return false ;
37
+ }
38
+
24
39
}
You can’t perform that action at this time.
0 commit comments