@@ -12,8 +12,10 @@ export default class Operation extends PureComponent {
1212 method : PropTypes . string . isRequired ,
1313 operation : PropTypes . object . isRequired ,
1414 showSummary : PropTypes . bool ,
15+ isShown : PropTypes . bool . isRequired ,
1516
16- isShownKey : CustomPropTypes . arrayOrString . isRequired ,
17+ tagKey : PropTypes . string ,
18+ operationKey : PropTypes . string ,
1719 jumpToKey : CustomPropTypes . arrayOrString . isRequired ,
1820
1921 allowTryItOut : PropTypes . bool ,
@@ -52,38 +54,16 @@ export default class Operation extends PureComponent {
5254 }
5355
5456 componentWillReceiveProps ( nextProps ) {
55- const defaultContentType = "application/json"
56- let { specActions, path, method, operation } = nextProps
57- let producesValue = operation . get ( "produces_value" )
58- let produces = operation . get ( "produces" )
59- let consumes = operation . get ( "consumes" )
60- let consumesValue = operation . get ( "consumes_value" )
61-
6257 if ( nextProps . response !== this . props . response ) {
6358 this . setState ( { executeInProgress : false } )
6459 }
65-
66- if ( producesValue === undefined ) {
67- producesValue = produces && produces . size ? produces . first ( ) : defaultContentType
68- specActions . changeProducesValue ( [ path , method ] , producesValue )
69- }
70-
71- if ( consumesValue === undefined ) {
72- consumesValue = consumes && consumes . size ? consumes . first ( ) : defaultContentType
73- specActions . changeConsumesValue ( [ path , method ] , consumesValue )
74- }
7560 }
7661
7762 toggleShown = ( ) => {
78- let { layoutActions, isShownKey } = this . props
79- layoutActions . show ( isShownKey , ! this . isShown ( ) )
80- }
81-
82- isShown = ( ) => {
83- let { layoutSelectors, isShownKey, getConfigs } = this . props
84- let { docExpansion } = getConfigs ( )
63+ let { layoutActions, tagKey, operationKey, isShown } = this . props
64+ const isShownKey = [ "operations" , tagKey , operationKey ]
8565
86- return layoutSelectors . isShown ( isShownKey , docExpansion === "full" ) // Here is where we set the default
66+ layoutActions . show ( isShownKey , ! isShown )
8767 }
8868
8969 onTryoutClick = ( ) => {
@@ -102,7 +82,9 @@ export default class Operation extends PureComponent {
10282
10383 render ( ) {
10484 let {
105- isShownKey,
85+ operationKey,
86+ tagKey,
87+ isShown,
10688 jumpToKey,
10789 path,
10890 method,
@@ -156,18 +138,17 @@ export default class Operation extends PureComponent {
156138 }
157139
158140 let { tryItOutEnabled } = this . state
159- let shown = this . isShown ( )
160141 let onChangeKey = [ path , method ] // Used to add values to _this_ operation ( indexed by path and method )
161142
162143 return (
163- < div className = { deprecated ? "opblock opblock-deprecated" : shown ? `opblock opblock-${ method } is-open` : `opblock opblock-${ method } ` } id = { isShownKey . join ( "-" ) } >
144+ < div className = { deprecated ? "opblock opblock-deprecated" : isShown ? `opblock opblock-${ method } is-open` : `opblock opblock-${ method } ` } id = { `operations- ${ tagKey } - ${ operationKey } ` } >
164145 < div className = { `opblock-summary opblock-summary-${ method } ` } onClick = { this . toggleShown } >
165146 < span className = "opblock-summary-method" > { method . toUpperCase ( ) } </ span >
166147 < span className = { deprecated ? "opblock-summary-path__deprecated" : "opblock-summary-path" } >
167148 < a
168149 className = "nostyle"
169150 onClick = { isDeepLinkingEnabled ? ( e ) => e . preventDefault ( ) : null }
170- href = { isDeepLinkingEnabled ? `#/${ isShownKey [ 1 ] } /${ isShownKey [ 2 ] } ` : null } >
151+ href = { isDeepLinkingEnabled ? `#/${ tagKey } /${ operationKey } ` : null } >
171152 < span > { path } </ span >
172153 </ a >
173154 < JumpToPath path = { jumpToKey } />
@@ -193,7 +174,7 @@ export default class Operation extends PureComponent {
193174 }
194175 </ div >
195176
196- < Collapse isOpened = { shown } >
177+ < Collapse isOpened = { isShown } >
197178 < div className = "opblock-body" >
198179 { deprecated && < h4 className = "opblock-title_normal" > Warning: Deprecated</ h4 > }
199180 { description &&
0 commit comments