@@ -45,11 +45,18 @@ import {
4545 distinctUntilChanged ,
4646 catchError ,
4747} from 'rxjs/operators' ;
48- import { HttpClient , HttpErrorResponse } from '@angular/common/http' ;
48+ import {
49+ HttpClient ,
50+ HttpErrorResponse ,
51+ HttpBackend ,
52+ HttpHeaders ,
53+ } from '@angular/common/http' ;
4954import { BASE_URL } from 'src/app/shared/constants/urls' ;
5055import { Subscription , of , forkJoin } from 'rxjs' ;
5156import { DfApiQuickstartComponent } from '../df-api-quickstart/df-api-quickstart.component' ;
5257import { ApiDocJson } from 'src/app/shared/types/files' ;
58+ import { MatSlideToggleModule } from '@angular/material/slide-toggle' ;
59+ import { FormsModule } from '@angular/forms' ;
5360
5461interface ServiceResponse {
5562 resource : Array < {
@@ -88,6 +95,8 @@ interface HealthCheckResult {
8895 MatExpansionModule ,
8996 MatCardModule ,
9097 DfApiQuickstartComponent ,
98+ MatSlideToggleModule ,
99+ FormsModule ,
91100 ] ,
92101} )
93102export class DfApiDocsComponent implements OnInit , AfterContentInit , OnDestroy {
@@ -103,6 +112,7 @@ export class DfApiDocsComponent implements OnInit, AfterContentInit, OnDestroy {
103112 apiDocJson : ApiDocJson ;
104113 apiKeys : ApiKeyInfo [ ] = [ ] ;
105114 faCopy = faCopy ;
115+ expandSchema = false ;
106116
107117 private subscriptions : Subscription [ ] = [ ] ;
108118 healthStatus : 'loading' | 'healthy' | 'unhealthy' | 'warning' = 'loading' ;
@@ -136,6 +146,8 @@ export class DfApiDocsComponent implements OnInit, AfterContentInit, OnDestroy {
136146 ] ,
137147 } ;
138148
149+ private rawHttp : HttpClient ;
150+
139151 constructor (
140152 private activatedRoute : ActivatedRoute ,
141153 private router : Router ,
@@ -145,14 +157,17 @@ export class DfApiDocsComponent implements OnInit, AfterContentInit, OnDestroy {
145157 private clipboard : Clipboard ,
146158 private snackBar : MatSnackBar ,
147159 private currentServiceService : DfCurrentServiceService ,
148- private http : HttpClient
149- ) { }
160+ private http : HttpClient ,
161+ private httpBackend : HttpBackend
162+ ) {
163+ this . rawHttp = new HttpClient ( httpBackend ) ;
164+ }
150165 isDarkMode = this . themeService . darkMode$ ;
151166 ngOnInit ( ) : void {
152167 // Get the service name from the route
153168 this . serviceName = this . activatedRoute . snapshot . params [ 'name' ] ;
154169
155- // First fetch the service ID by name
170+ // First fetch the service ID by name (use normal http)
156171 if ( this . serviceName ) {
157172 this . subscriptions . push (
158173 this . http
@@ -322,6 +337,25 @@ export class DfApiDocsComponent implements OnInit, AfterContentInit, OnDestroy {
322337 this . showUnhealthyErrorDetails = ! this . showUnhealthyErrorDetails ;
323338 }
324339
340+ reloadApiDocs ( ) {
341+ if ( ! this . serviceName ) return ;
342+ const params = this . expandSchema ? '?expand_schema=true' : '' ;
343+ const headers = new HttpHeaders ( {
344+ 'X-DreamFactory-API-Key' : environment . dfApiDocsApiKey ,
345+ 'X-DreamFactory-Session-Token' : this . userDataService . token || '' ,
346+ } ) ;
347+ this . rawHttp
348+ . get < any > ( `${ BASE_URL } /api_docs/${ this . serviceName } ${ params } ` , {
349+ headers,
350+ } )
351+ . subscribe ( data => {
352+ if ( data ) {
353+ this . apiDocJson = data ;
354+ }
355+ this . ngAfterContentInit ( ) ;
356+ } ) ;
357+ }
358+
325359 private injectCustomContent (
326360 swaggerContainer : HTMLElement ,
327361 infoContainer : HTMLElement | null ,
0 commit comments