import React, { Component } from "react" import PropTypes from "prop-types" import { Map, List } from "immutable" import ImPropTypes from "react-immutable-proptypes" import createHtmlReadyId from "core/utils/create-html-ready-id" export default class Parameters extends Component { constructor(props) { super(props) this.state = { callbackVisible: false, parametersVisible: true, } } static propTypes = { parameters: ImPropTypes.list.isRequired, operation: PropTypes.object.isRequired, specActions: PropTypes.object.isRequired, getComponent: PropTypes.func.isRequired, specSelectors: PropTypes.object.isRequired, oas3Actions: PropTypes.object.isRequired, oas3Selectors: PropTypes.object.isRequired, fn: PropTypes.object.isRequired, tryItOutEnabled: PropTypes.bool, allowTryItOut: PropTypes.bool, onTryoutClick: PropTypes.func, onResetClick: PropTypes.func, onCancelClick: PropTypes.func, onChangeKey: PropTypes.array, pathMethod: PropTypes.array.isRequired, getConfigs: PropTypes.func.isRequired, specPath: ImPropTypes.list.isRequired, } static defaultProps = { onTryoutClick: Function.prototype, onCancelClick: Function.prototype, tryItOutEnabled: false, allowTryItOut: true, onChangeKey: [], specPath: [], } onChange = (param, value, isXml) => { let { specActions: { changeParamByIdentity }, onChangeKey, } = this.props changeParamByIdentity(onChangeKey, param, value, isXml) } onChangeConsumesWrapper = (val) => { let { specActions: { changeConsumesValue }, onChangeKey, } = this.props changeConsumesValue(onChangeKey, val) } toggleTab = (tab) => { if (tab === "parameters") { return this.setState({ parametersVisible: true, callbackVisible: false, }) } else if (tab === "callbacks") { return this.setState({ callbackVisible: true, parametersVisible: false, }) } } onChangeMediaType = ({ value, pathMethod }) => { let { specActions, oas3Selectors, oas3Actions } = this.props const userHasEditedBody = oas3Selectors.hasUserEditedBody(...pathMethod) const shouldRetainRequestBodyValue = oas3Selectors.shouldRetainRequestBodyValue(...pathMethod) oas3Actions.setRequestContentType({ value, pathMethod }) oas3Actions.initRequestBodyValidateError({ pathMethod }) if (!userHasEditedBody) { if(!shouldRetainRequestBodyValue) { oas3Actions.setRequestBodyValue({ value: undefined, pathMethod }) } specActions.clearResponse(...pathMethod) specActions.clearRequest(...pathMethod) specActions.clearValidateParams(pathMethod) } } render() { let { onTryoutClick, onResetClick, parameters, allowTryItOut, tryItOutEnabled, specPath, fn, getComponent, getConfigs, specSelectors, specActions, pathMethod, oas3Actions, oas3Selectors, operation, } = this.props const ParameterRow = getComponent("parameterRow") const TryItOutButton = getComponent("TryItOutButton") const ContentType = getComponent("contentType") const Callbacks = getComponent("Callbacks", true) const RequestBody = getComponent("RequestBody", true) const isExecute = tryItOutEnabled && allowTryItOut const isOAS3 = specSelectors.isOAS3() const regionId = createHtmlReadyId(`${pathMethod[1]}${pathMethod[0]}_requests`) const controlId = `${regionId}_select` const requestBody = operation.get("requestBody") const groupedParametersArr = Object.values(parameters .reduce((acc, x) => { const key = x.get("in") acc[key] ??= [] acc[key].push(x) return acc }, {})) .reduce((acc, x) => acc.concat(x), []) const retainRequestBodyValueFlagForOperation = (f) => oas3Actions.setRetainRequestBodyValueFlag({ value: f, pathMethod }) return (
No parameters
Name | Description |
---|