feat(RequestBody): set default true for 'send empty value' (#6228)

This commit is contained in:
Tim Lai
2020-07-16 17:01:18 -07:00
committed by GitHub
parent eacc7b92d1
commit b68942c043
4 changed files with 610 additions and 15 deletions

View File

@@ -53,6 +53,19 @@ const RequestBody = ({
const handleFile = (e) => {
onChange(e.target.files[0])
}
const setIsIncludedOptions = (key) => {
let options = {
key,
shouldDispatchInit: false,
defaultValue: true
}
let currentInclusion = requestBodyInclusionSetting.get(key, "no value")
if (currentInclusion === "no value") {
options.shouldDispatchInit = true
// future: can get/set defaultValue from a config setting
}
return options
}
const Markdown = getComponent("Markdown", true)
const ModelExample = getComponent("modelExample")
@@ -173,7 +186,8 @@ const RequestBody = ({
{required ? null : (
<ParameterIncludeEmpty
onChange={(value) => onChangeIncludeEmpty(key, value)}
isIncluded={requestBodyInclusionSetting.get(key)}
isIncluded={requestBodyInclusionSetting.get(key) || false}
isIncludedOptions={setIsIncludedOptions(key)}
isDisabled={!isEmptyValue(currentValue)}
/>
)}