@@ -401,12 +401,6 @@ export function contentTypeValues(state, pathMethod) {
401401 } )
402402}
403403
404- // Get the consumes/produces by path
405- export function operationConsumes ( state , pathMethod ) {
406- pathMethod = pathMethod || [ ]
407- return specJsonWithResolvedSubtrees ( state ) . getIn ( [ "paths" , ...pathMethod , "consumes" ] , fromJS ( { } ) )
408- }
409-
410404// Get the currently selected produces value for an operation
411405export function currentProducesFor ( state , pathMethod ) {
412406 pathMethod = pathMethod || [ ]
@@ -425,6 +419,48 @@ export function currentProducesFor(state, pathMethod) {
425419
426420}
427421
422+ // Get the produces options for an operation
423+ export function producesOptionsFor ( state , pathMethod ) {
424+ pathMethod = pathMethod || [ ]
425+
426+ const spec = specJsonWithResolvedSubtrees ( state )
427+ const operation = spec . getIn ( [ "paths" , ...pathMethod ] , null )
428+
429+ if ( operation === null ) {
430+ // return nothing if the operation does not exist
431+ return
432+ }
433+
434+ const [ path ] = pathMethod
435+
436+ const operationProduces = operation . get ( "produces" , null )
437+ const pathItemProduces = spec . getIn ( [ "paths" , path , "produces" ] , null )
438+ const globalProduces = spec . getIn ( [ "produces" ] , null )
439+
440+ return operationProduces || pathItemProduces || globalProduces
441+ }
442+
443+ // Get the consumes options for an operation
444+ export function consumesOptionsFor ( state , pathMethod ) {
445+ pathMethod = pathMethod || [ ]
446+
447+ const spec = specJsonWithResolvedSubtrees ( state )
448+ const operation = spec . getIn ( [ "paths" , ...pathMethod ] , null )
449+
450+ if ( operation === null ) {
451+ // return nothing if the operation does not exist
452+ return
453+ }
454+
455+ const [ path ] = pathMethod
456+
457+ const operationConsumes = operation . get ( "consumes" , null )
458+ const pathItemConsumes = spec . getIn ( [ "paths" , path , "consumes" ] , null )
459+ const globalConsumes = spec . getIn ( [ "consumes" ] , null )
460+
461+ return operationConsumes || pathItemConsumes || globalConsumes
462+ }
463+
428464export const operationScheme = ( state , path , method ) => {
429465 let url = state . get ( "url" )
430466 let matchResult = url . match ( / ^ ( [ a - z ] [ a - z 0 - 9 + \- . ] * ) : / )
0 commit comments