This repository was archived by the owner on Nov 28, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +39
-2
lines changed
packages/api-explorer-ui/src Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ class Doc extends React.Component {
21
21
loading : false ,
22
22
showAuthBox : false ,
23
23
needsAuth : false ,
24
+ responseTabClass : 'hub-reference-right hub-reference-results tabber-parent' ,
24
25
} ;
25
26
this . onChange = this . onChange . bind ( this ) ;
26
27
this . oas = new Oas ( this . props . oas ) ;
@@ -75,8 +76,7 @@ class Doc extends React.Component {
75
76
formData = { this . state . formData }
76
77
/>
77
78
</ div >
78
- { /* TODO add ClassNames*/ }
79
- < div className = "hub-reference-right hub-reference-results tabber-parent" >
79
+ < div className = { this . state . responseTabClass } >
80
80
< div className = "hub-reference-results-slider" >
81
81
< div className = "hub-reference-results-explorer code-sample" />
82
82
< div className = "hub-reference-results-examples code-sample" >
Original file line number Diff line number Diff line change
1
+ const { constructRequest } = require ( 'fetch-har' ) ;
2
+ const { statusCodes } = require ( './statuscodes' ) ;
3
+
4
+ const req = constructRequest ;
5
+
6
+ function result ( res ) {
7
+ const data = res . responseJSON ? JSON . stringify ( res . responseJSON , undefined , 2 ) : res . responseText ;
8
+
9
+ const isBinary = ! ! res . getAllResponseHeaders ( ) . match ( / C o n t e n t - D i s p o s i t i o n : a t t a c h m e n t ; / ) ;
10
+
11
+ const headersFormatted = [ ] ;
12
+
13
+ req . headers . forEach ( ( ele , i ) => {
14
+ headersFormatted . push ( `${ i } : ${ ele } ` ) ;
15
+ } ) ;
16
+
17
+ let responseHeaders = res . getAllResponseHeaders ( ) ;
18
+ responseHeaders = responseHeaders
19
+ . filter ( responseHeaders . split ( '\n' ) , v => ! v . match ( / x - f i n a l - u r l : / i) )
20
+ . join ( '\n' ) ;
21
+
22
+ const results = {
23
+ init : true ,
24
+ method : req . method ,
25
+ requestHeaders : headersFormatted . join ( '\n' ) ,
26
+ responseHeaders,
27
+ isBinary,
28
+ url : req . url ,
29
+ data : res . responseText ,
30
+ statusCode : statusCodes ( res . status || 404 ) ,
31
+ dataString : data ,
32
+ } ;
33
+
34
+ this . setState ( { responseTabClass : 'hub-reference-right hub-reference-results tabber-parent on' } ) ;
35
+
36
+ setTab ( '[data-tab=result]' ) ;
37
+ }
You can’t perform that action at this time.
0 commit comments