refactor(oas31): simplify Webhooks component by utilizing selectors (#8481)

Refs #8474
This commit is contained in:
Vladimír Gorej
2023-03-17 18:14:23 +01:00
committed by GitHub
parent 865d98d6be
commit 47e12f1de3
11 changed files with 126 additions and 74 deletions

View File

@@ -126,6 +126,7 @@ export default class BaseLayout extends React.Component {
<Operations />
</Col>
</Row>
{isOAS31 && (
<Row className="webhooks-container">
<Col mobile={12} desktop={12}>
@@ -133,6 +134,7 @@ export default class BaseLayout extends React.Component {
</Col>
</Row>
)}
<Row>
<Col mobile={12} desktop={12}>
<Models />

View File

@@ -2,13 +2,6 @@ import React from "react"
import PropTypes from "prop-types"
import Im from "immutable"
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 = {
@@ -53,6 +46,7 @@ export default class Operations extends React.Component {
layoutActions,
getConfigs,
} = this.props
const validOperationMethods = specSelectors.validOperationMethods()
const OperationContainer = getComponent("OperationContainer", true)
const OperationTag = getComponent("OperationTag")
const operations = tagObj.get("operations")
@@ -74,16 +68,7 @@ export default class Operations extends React.Component {
const method = op.get("method")
const specPath = Im.List(["paths", path, method])
// FIXME: (someday) this logic should probably be in a selector,
// but doing so would require further opening up
// selectors to the plugin system, to allow for dynamic
// overriding of low-level selectors that other selectors
// rely on. --KS, 12/17
const validMethods = specSelectors.isOAS3() ?
OAS3_OPERATION_METHODS : SWAGGER2_OPERATION_METHODS
if (validMethods.indexOf(method) === -1) {
if (validOperationMethods.indexOf(method) === -1) {
return null
}