Revert "Merge pull request #3516 from owenconti/bug/3511-query-formData-parameters"
This reverts commit6a7e9d2e88, reversing changes made toeb01beedfa.
This commit is contained in:
@@ -47,7 +47,7 @@ export default class ParamBody extends PureComponent {
|
|||||||
|
|
||||||
updateValues = (props) => {
|
updateValues = (props) => {
|
||||||
let { specSelectors, pathMethod, param, isExecute, consumesValue="" } = props
|
let { specSelectors, pathMethod, param, isExecute, consumesValue="" } = props
|
||||||
let parameter = specSelectors ? specSelectors.getParameter(pathMethod, param.get("name"), param.get("in")) : {}
|
let parameter = specSelectors ? specSelectors.getParameter(pathMethod, param.get("name")) : {}
|
||||||
let isXml = /xml/i.test(consumesValue)
|
let isXml = /xml/i.test(consumesValue)
|
||||||
let isJson = /json/i.test(consumesValue)
|
let isJson = /json/i.test(consumesValue)
|
||||||
let paramValue = isXml ? parameter.get("value_xml") : parameter.get("value")
|
let paramValue = isXml ? parameter.get("value_xml") : parameter.get("value")
|
||||||
@@ -107,7 +107,7 @@ export default class ParamBody extends PureComponent {
|
|||||||
const HighlightCode = getComponent("highlightCode")
|
const HighlightCode = getComponent("highlightCode")
|
||||||
const ContentType = getComponent("contentType")
|
const ContentType = getComponent("contentType")
|
||||||
// for domains where specSelectors not passed
|
// for domains where specSelectors not passed
|
||||||
let parameter = specSelectors ? specSelectors.getParameter(pathMethod, param.get("name"), param.get("in")) : param
|
let parameter = specSelectors ? specSelectors.getParameter(pathMethod, param.get("name")) : param
|
||||||
let errors = parameter.get("errors", List())
|
let errors = parameter.get("errors", List())
|
||||||
let consumesValue = specSelectors.contentTypeValues(pathMethod).get("requestContentType")
|
let consumesValue = specSelectors.contentTypeValues(pathMethod).get("requestContentType")
|
||||||
let consumes = this.props.consumes && this.props.consumes.size ? this.props.consumes : ParamBody.defaultProp.consumes
|
let consumes = this.props.consumes && this.props.consumes.size ? this.props.consumes : ParamBody.defaultProp.consumes
|
||||||
|
|||||||
@@ -19,17 +19,13 @@ export default class ParameterRow extends Component {
|
|||||||
|
|
||||||
let { specSelectors, pathMethod, param } = props
|
let { specSelectors, pathMethod, param } = props
|
||||||
let defaultValue = param.get("default")
|
let defaultValue = param.get("default")
|
||||||
let parameter = specSelectors.getParameter(pathMethod, param.get("name"), param.get("in"))
|
let parameter = specSelectors.getParameter(pathMethod, param.get("name"))
|
||||||
let value = parameter ? parameter.get("value") : ""
|
let value = parameter ? parameter.get("value") : ""
|
||||||
if ( defaultValue !== undefined && value === undefined ) {
|
if ( defaultValue !== undefined && value === undefined ) {
|
||||||
this.onChangeWrapper(defaultValue)
|
this.onChangeWrapper(defaultValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps) {
|
|
||||||
return nextProps.param !== this.props.param
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillReceiveProps(props) {
|
componentWillReceiveProps(props) {
|
||||||
let { specSelectors, pathMethod, param } = props
|
let { specSelectors, pathMethod, param } = props
|
||||||
let example = param.get("example")
|
let example = param.get("example")
|
||||||
@@ -90,7 +86,7 @@ export default class ParameterRow extends Component {
|
|||||||
let isFormDataSupported = "FormData" in win
|
let isFormDataSupported = "FormData" in win
|
||||||
let required = param.get("required")
|
let required = param.get("required")
|
||||||
let itemType = param.getIn(isOAS3 && isOAS3() ? ["schema", "items", "type"] : ["items", "type"])
|
let itemType = param.getIn(isOAS3 && isOAS3() ? ["schema", "items", "type"] : ["items", "type"])
|
||||||
let parameter = specSelectors.getParameter(pathMethod, param.get("name"), param.get("in"))
|
let parameter = specSelectors.getParameter(pathMethod, param.get("name"))
|
||||||
let value = parameter ? parameter.get("value") : ""
|
let value = parameter ? parameter.get("value") : ""
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export default class Parameters extends Component {
|
|||||||
onChangeKey,
|
onChangeKey,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
changeParam( onChangeKey, param.get("name"), param.get("in"), value, isXml)
|
changeParam( onChangeKey, param.get("name"), value, isXml)
|
||||||
}
|
}
|
||||||
|
|
||||||
onChangeConsumesWrapper = ( val ) => {
|
onChangeConsumesWrapper = ( val ) => {
|
||||||
@@ -94,7 +94,7 @@ export default class Parameters extends Component {
|
|||||||
<ParameterRow fn={ fn }
|
<ParameterRow fn={ fn }
|
||||||
getComponent={ getComponent }
|
getComponent={ getComponent }
|
||||||
param={ parameter }
|
param={ parameter }
|
||||||
key={ `${parameter.get( "in" )}.${parameter.get("name")}` }
|
key={ parameter.get( "name" ) }
|
||||||
onChange={ this.onChange }
|
onChange={ this.onChange }
|
||||||
onChangeConsumes={this.onChangeConsumesWrapper}
|
onChangeConsumes={this.onChangeConsumesWrapper}
|
||||||
specSelectors={ specSelectors }
|
specSelectors={ specSelectors }
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class Parameters extends Component {
|
|||||||
onChangeKey,
|
onChangeKey,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
changeParam( onChangeKey, param.get("name"), param.get("in"), value, isXml)
|
changeParam( onChangeKey, param.get("name"), value, isXml)
|
||||||
}
|
}
|
||||||
|
|
||||||
onChangeConsumesWrapper = ( val ) => {
|
onChangeConsumesWrapper = ( val ) => {
|
||||||
|
|||||||
@@ -130,10 +130,10 @@ export const formatIntoYaml = () => ({specActions, specSelectors}) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function changeParam( path, paramName, paramIn, value, isXml ){
|
export function changeParam( path, paramName, value, isXml ){
|
||||||
return {
|
return {
|
||||||
type: UPDATE_PARAM,
|
type: UPDATE_PARAM,
|
||||||
payload:{ path, value, paramName, paramIn, isXml }
|
payload:{ path, value, paramName, isXml }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,6 +206,7 @@ export const executeRequest = (req) =>
|
|||||||
// if url is relative, parseUrl makes it absolute by inferring from `window.location`
|
// if url is relative, parseUrl makes it absolute by inferring from `window.location`
|
||||||
req.contextUrl = parseUrl(specSelectors.url()).toString()
|
req.contextUrl = parseUrl(specSelectors.url()).toString()
|
||||||
|
|
||||||
|
|
||||||
if(op && op.operationId) {
|
if(op && op.operationId) {
|
||||||
req.operationId = op.operationId
|
req.operationId = op.operationId
|
||||||
} else if(op && pathName && method) {
|
} else if(op && pathName && method) {
|
||||||
|
|||||||
@@ -40,10 +40,9 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
[UPDATE_PARAM]: ( state, {payload} ) => {
|
[UPDATE_PARAM]: ( state, {payload} ) => {
|
||||||
let { path, paramName, paramIn, value, isXml } = payload
|
let { path, paramName, value, isXml } = payload
|
||||||
|
|
||||||
return state.updateIn( [ "resolved", "paths", ...path, "parameters" ], fromJS([]), parameters => {
|
return state.updateIn( [ "resolved", "paths", ...path, "parameters" ], fromJS([]), parameters => {
|
||||||
const index = parameters.findIndex(p => p.get( "name" ) === paramName && p.get("in") === paramIn )
|
const index = parameters.findIndex(p => p.get( "name" ) === paramName )
|
||||||
if (!(value instanceof win.File)) {
|
if (!(value instanceof win.File)) {
|
||||||
value = fromJSOrdered( value )
|
value = fromJSOrdered( value )
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,10 +260,10 @@ export const allowTryItOutFor = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the parameter value by parameter name
|
// Get the parameter value by parameter name
|
||||||
export function getParameter(state, pathMethod, name, inType) {
|
export function getParameter(state, pathMethod, name) {
|
||||||
let params = spec(state).getIn(["paths", ...pathMethod, "parameters"], fromJS([]))
|
let params = spec(state).getIn(["paths", ...pathMethod, "parameters"], fromJS([]))
|
||||||
return params.filter( (p) => {
|
return params.filter( (p) => {
|
||||||
return Map.isMap(p) && p.get("name") === name && p.get("in") === inType
|
return Map.isMap(p) && p.get("name") === name
|
||||||
}).first()
|
}).first()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ export function parameterValues(state, pathMethod, isXml) {
|
|||||||
let params = spec(state).getIn(["paths", ...pathMethod, "parameters"], fromJS([]))
|
let params = spec(state).getIn(["paths", ...pathMethod, "parameters"], fromJS([]))
|
||||||
return params.reduce( (hash, p) => {
|
return params.reduce( (hash, p) => {
|
||||||
let value = isXml && p.get("in") === "body" ? p.get("value_xml") : p.get("value")
|
let value = isXml && p.get("in") === "body" ? p.get("value_xml") : p.get("value")
|
||||||
return hash.set(`${p.get("in")}.${p.get("name")}`, value)
|
return hash.set(p.get("name"), value)
|
||||||
}, fromJS({}))
|
}, fromJS({}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ describe("spec plugin - selectors", function(){
|
|||||||
"/one": {
|
"/one": {
|
||||||
get: {
|
get: {
|
||||||
parameters: [
|
parameters: [
|
||||||
{ name: "one", in: "query", value: 1},
|
{ name: "one", value: 1},
|
||||||
{ name: "two", in: "query", value: "duos"}
|
{ name: "two", value: "duos"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,8 +43,8 @@ describe("spec plugin - selectors", function(){
|
|||||||
|
|
||||||
// Then
|
// Then
|
||||||
expect(paramValues.toJS()).toEqual({
|
expect(paramValues.toJS()).toEqual({
|
||||||
"query.one": 1,
|
one: 1,
|
||||||
"query.two": "duos"
|
two: "duos"
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user