Move method filtering logic to Operations component

This commit is contained in:
Kyle Shockey
2017-12-06 13:52:06 -08:00
parent eb97b91d7e
commit 328f02c463
3 changed files with 22 additions and 10 deletions

View File

@@ -2,6 +2,13 @@ import React from "react"
import PropTypes from "prop-types"
import { createDeepLinkPath, sanitizeUrl } from "core/utils"
const SWAGGER2_OPERATION_METHODS = [
"get", "put", "post", "delete", "options", "head", "patch"
]
const OAS3_OPERATION_METHODS = SWAGGER2_OPERATION_METHODS.concat(["trace"])
export default class Operations extends React.Component {
static propTypes = {
@@ -113,6 +120,13 @@ export default class Operations extends React.Component {
const path = op.get("path")
const method = op.get("method")
const validMethods = specSelectors.isOAS3() ?
OAS3_OPERATION_METHODS : SWAGGER2_OPERATION_METHODS
if(validMethods.indexOf(method) === -1) {
return null
}
return <OperationContainer
key={`${path}-${method}`}
op={op}