Revert "revert: feat: Allow to skip submitting empty values in form data (#5830)" (#6227)

This reverts commit 1b6cb7d1bf.
This commit is contained in:
Tim Lai
2020-07-15 16:07:32 -07:00
committed by GitHub
parent 1b6cb7d1bf
commit eacc7b92d1
10 changed files with 75 additions and 27 deletions

View File

@@ -5,7 +5,7 @@ import serializeError from "serialize-error"
import isString from "lodash/isString"
import debounce from "lodash/debounce"
import set from "lodash/set"
import { isJSONObject, paramToValue } from "core/utils"
import { isJSONObject, paramToValue, isEmptyValue } from "core/utils"
// Actions conform to FSA (flux-standard-actions)
// {type: string,payload: Any|Error, meta: obj, error: bool}
@@ -401,11 +401,12 @@ export const executeRequest = (req) =>
req.requestContentType = oas3Selectors.requestContentType(pathName, method)
req.responseContentType = oas3Selectors.responseContentType(pathName, method) || "*/*"
const requestBody = oas3Selectors.requestBodyValue(pathName, method)
const requestBodyInclusionSetting = oas3Selectors.requestBodyInclusionSetting(pathName, method)
if(isJSONObject(requestBody)) {
req.requestBody = JSON.parse(requestBody)
} else if(requestBody && requestBody.toJS) {
req.requestBody = requestBody.toJS()
req.requestBody = requestBody.filter((value, key) => !isEmptyValue(value) || requestBodyInclusionSetting.get(key)).toJS()
} else{
req.requestBody = requestBody
}