diff --git a/src/core/components/operation.jsx b/src/core/components/operation.jsx index f8d8095d..ea1877f3 100644 --- a/src/core/components/operation.jsx +++ b/src/core/components/operation.jsx @@ -22,6 +22,7 @@ export default class Operation extends PureComponent { specActions: PropTypes.object.isRequired, specSelectors: PropTypes.object.isRequired, oas3Actions: PropTypes.object.isRequired, + oas3Selectors: PropTypes.object.isRequired, layoutActions: PropTypes.object.isRequired, layoutSelectors: PropTypes.object.isRequired, fn: PropTypes.object.isRequired @@ -48,7 +49,8 @@ export default class Operation extends PureComponent { specSelectors, authActions, authSelectors, - oas3Actions + oas3Actions, + oas3Selectors } = this.props let operationProps = this.props.operation @@ -186,8 +188,15 @@ export default class Operation extends PureComponent { { !tryItOutEnabled ? null : } diff --git a/src/core/containers/OperationContainer.jsx b/src/core/containers/OperationContainer.jsx index 74371db1..c939ef38 100644 --- a/src/core/containers/OperationContainer.jsx +++ b/src/core/containers/OperationContainer.jsx @@ -35,6 +35,7 @@ export default class OperationContainer extends PureComponent { getComponent: PropTypes.func.isRequired, authActions: PropTypes.object, oas3Actions: PropTypes.object, + oas3Selectors: PropTypes.object, authSelectors: PropTypes.object, specActions: PropTypes.object.isRequired, specSelectors: PropTypes.object.isRequired, @@ -149,6 +150,7 @@ export default class OperationContainer extends PureComponent { authActions, authSelectors, oas3Actions, + oas3Selectors, fn } = this.props @@ -189,6 +191,7 @@ export default class OperationContainer extends PureComponent { specActions={ specActions } specSelectors={ specSelectors } oas3Actions={oas3Actions} + oas3Selectors={oas3Selectors} layoutActions={ layoutActions } layoutSelectors={ layoutSelectors } authActions={ authActions } diff --git a/src/core/plugins/oas3/components/operation-servers.jsx b/src/core/plugins/oas3/components/operation-servers.jsx index f59e1fac..5db8683a 100644 --- a/src/core/plugins/oas3/components/operation-servers.jsx +++ b/src/core/plugins/oas3/components/operation-servers.jsx @@ -5,13 +5,13 @@ import ImPropTypes from "react-immutable-proptypes" export default class OperationServers extends React.PureComponent { static propTypes = { // for self + path: PropTypes.string.isRequired, + method: PropTypes.string.isRequired, operationServers: ImPropTypes.list, pathServers: ImPropTypes.list, - - // for Servers - currentServer: PropTypes.string.isRequired, setSelectedServer: PropTypes.func.isRequired, setServerVariableValue: PropTypes.func.isRequired, + getSelectedServer: PropTypes.func.isRequired, getServerVariable: PropTypes.func.isRequired, getEffectiveServerValue: PropTypes.func.isRequired, @@ -19,25 +19,51 @@ export default class OperationServers extends React.PureComponent { getComponent: PropTypes.func.isRequired } + setSelectedServer = (server) => { + const { path, method } = this.props + return this.props.setSelectedServer(server, `${path}:${method}`) + } + + setServerVariableValue = (obj) => { + const { path, method } = this.props + return this.props.setServerVariableValue({ + ...obj, + namespace: `${path}:${method}` + }) + } + + getSelectedServer = () => { + const { path, method } = this.props + debugger + return this.props.getSelectedServer(`${path}:${method}`) + } + + getServerVariable = (obj) => { + const { path, method } = this.props + return this.props.getServerVariable({ + ...obj, + namespace: `${path}:${method}` + }) + } + + getEffectiveServerValue = (obj) => { + const { path, method } = this.props + return this.props.getEffectiveServerValue({ + ...obj, + namespace: `${path}:${method}` + }) + } + render() { const { // for self operationServers, pathServers, - // for Servers - currentServer, - setSelectedServer, - setServerVariableValue, - getServerVariable, - getEffectiveServerValue, - // util getComponent } = this.props - const serverPassthroughProps = { currentServer, setSelectedServer, setServerVariableValue, getServerVariable, getEffectiveServerValue } - const Servers = getComponent("Servers") const serversToDisplay = operationServers || pathServers @@ -52,8 +78,12 @@ export default class OperationServers extends React.PureComponent {

These {displaying}-level options override the global server options.

diff --git a/src/core/plugins/oas3/components/servers.jsx b/src/core/plugins/oas3/components/servers.jsx index 5ebfcf5a..dd073976 100644 --- a/src/core/plugins/oas3/components/servers.jsx +++ b/src/core/plugins/oas3/components/servers.jsx @@ -18,6 +18,7 @@ export default class Servers extends React.Component { let { servers } = this.props //fire 'change' event to set default 'value' of select + debugger this.setServer(servers.first().get("url")) }