import React, { PureComponent } from "react" import PropTypes from "prop-types" import { getList } from "core/utils" import { sanitizeUrl } from "core/utils" import { Iterable } from "immutable" export default class Operation extends PureComponent { static propTypes = { operation: PropTypes.instanceOf(Iterable).isRequired, response: PropTypes.instanceOf(Iterable), request: PropTypes.instanceOf(Iterable), toggleShown: PropTypes.func.isRequired, onTryoutClick: PropTypes.func.isRequired, onCancelClick: PropTypes.func.isRequired, onExecute: PropTypes.func.isRequired, getComponent: PropTypes.func.isRequired, getConfigs: PropTypes.func.isRequired, authActions: PropTypes.object, authSelectors: PropTypes.object, specActions: PropTypes.object.isRequired, specSelectors: PropTypes.object.isRequired, oas3Actions: PropTypes.object.isRequired, layoutActions: PropTypes.object.isRequired, layoutSelectors: PropTypes.object.isRequired, fn: PropTypes.object.isRequired } static defaultProps = { operation: null, response: null, request: null } render() { let { response, request, toggleShown, onTryoutClick, onCancelClick, onExecute, fn, getComponent, getConfigs, specActions, specSelectors, authActions, authSelectors, oas3Actions } = this.props let operationProps = this.props.operation let { isShown, isShownKey, jumpToKey, path, method, op, showSummary, operationId, allowTryItOut, displayOperationId, displayRequestDuration, isDeepLinkingEnabled, tryItOutEnabled, executeInProgress } = operationProps.toJS() let { summary, description, deprecated, externalDocs, schemes } = op.operation let operation = operationProps.getIn(["op", "operation"]) let responses = operation.get("responses") let produces = operation.get("produces") let security = operation.get("security") || specSelectors.security() let parameters = getList(operation, ["parameters"]) let operationScheme = specSelectors.operationScheme(path, method) const Responses = getComponent("responses") const Parameters = getComponent( "parameters" ) const Execute = getComponent( "execute" ) const Clear = getComponent( "clear" ) const AuthorizeOperationBtn = getComponent( "authorizeOperationBtn" ) const JumpToPath = getComponent("JumpToPath", true) const Collapse = getComponent( "Collapse" ) const Markdown = getComponent( "Markdown" ) const Schemes = getComponent( "schemes" ) // Merge in Live Response if(responses && response && response.size > 0) { let notDocumented = !responses.get(String(response.get("status"))) response = response.set("notDocumented", notDocumented) } let onChangeKey = [ path, method ] // Used to add values to _this_ operation ( indexed by path and method ) return (
{method.toUpperCase()} e.preventDefault() : null} href={isDeepLinkingEnabled ? `#/${tagKey}/${operationKey}` : null}> {path} { !showSummary ? null :
{ summary }
} { displayOperationId && operationId ? {operationId} : null } { (!security || !security.count()) ? null : { const applicableDefinitions = authSelectors.definitionsForRequirements(security) authActions.showDefinitions(applicableDefinitions) }} /> }
{ deprecated &&

Warning: Deprecated

} { description &&
} { externalDocs && externalDocs.get("url") ?

Find more details

{ externalDocs.get("url") }
: null } {!tryItOutEnabled || !allowTryItOut ? null : schemes && schemes.size ?
: null }
{ !tryItOutEnabled || !allowTryItOut ? null : } { (!tryItOutEnabled || !response || !allowTryItOut) ? null : }
{executeInProgress ?
: null} { !responses ? null : }
) } }