diff --git a/docker/configurator/variables.js b/docker/configurator/variables.js
index 1e676c4f1ea..9f8335880bb 100644
--- a/docker/configurator/variables.js
+++ b/docker/configurator/variables.js
@@ -51,6 +51,10 @@ const standardVariables = {
type: "string",
name: "defaultModelRendering"
},
+ DEFAULT_SEND_EMPTY_VAlUE: {
+ type: "boolean",
+ name: "defaultSendEmptyValue"
+ },
DISPLAY_REQUEST_DURATION: {
type: "boolean",
name: "displayRequestDuration"
diff --git a/docs/usage/configuration.md b/docs/usage/configuration.md
index 8670dfcf74b..c38a4fe9142 100644
--- a/docs/usage/configuration.md
+++ b/docs/usage/configuration.md
@@ -96,6 +96,14 @@ Parameter name | Docker variable | Description
Value' links.)
+
+ defaultSendEmptyValue
+ |
+ DEFAULT_SEND_EMPTY_VAlUE |
+ Boolean=true . Controls the initial state of the "Send empty value" checkbox in "Try it out"
+ forms. The default is true (checked).
+ |
+
displayRequestDuration
|
diff --git a/flavors/swagger-ui-react/index.jsx b/flavors/swagger-ui-react/index.jsx
index 3ef06c70b6a..ac2b3845951 100644
--- a/flavors/swagger-ui-react/index.jsx
+++ b/flavors/swagger-ui-react/index.jsx
@@ -32,6 +32,7 @@ const SwaggerUI = ({
defaultModelExpandDepth = config.defaults.defaultModelExpandDepth,
defaultModelsExpandDepth = config.defaults.defaultModelsExpandDepth,
defaultModelRendering = config.defaults.defaultModelRendering,
+ defaultSendEmptyValue = config.defaults.defaultSendEmptyValue,
presets = config.defaults.presets,
deepLinking = config.defaults.deepLinking,
showExtensions = config.defaults.showExtensions,
@@ -59,6 +60,7 @@ const SwaggerUI = ({
layout,
defaultModelsExpandDepth,
defaultModelRendering,
+ defaultSendEmptyValue,
presets: [SwaggerUIConstructor.presets.apis, ...presets],
requestInterceptor,
responseInterceptor,
@@ -153,6 +155,7 @@ SwaggerUI.propTypes = {
defaultModelExpandDepth: PropTypes.number,
defaultModelsExpandDepth: PropTypes.number,
defaultModelRendering: PropTypes.oneOf(["example", "model"]),
+ defaultSendEmptyValue: PropTypes.bool,
presets: PropTypes.arrayOf(PropTypes.func),
deepLinking: PropTypes.bool,
showExtensions: PropTypes.bool,
diff --git a/src/core/config/defaults.js b/src/core/config/defaults.js
index b7daa8fd624..4afc1a9e6fc 100644
--- a/src/core/config/defaults.js
+++ b/src/core/config/defaults.js
@@ -31,6 +31,7 @@ const defaultOptions = Object.freeze({
defaultModelRendering: "example",
defaultModelExpandDepth: 1,
defaultModelsExpandDepth: 1,
+ defaultSendEmptyValue: true,
showExtensions: false,
showCommonExtensions: false,
withCredentials: false,
diff --git a/src/core/config/type-cast/mappings.js b/src/core/config/type-cast/mappings.js
index b025fb1295e..5c0058203a3 100644
--- a/src/core/config/type-cast/mappings.js
+++ b/src/core/config/type-cast/mappings.js
@@ -34,6 +34,10 @@ const mappings = {
typeCaster: numberTypeCaster,
defaultValue: defaultOptions.defaultModelsExpandDepth,
},
+ defaultSendEmptyValue: {
+ typeCaster: booleanTypeCaster,
+ defaultValue: defaultOptions.defaultSendEmptyValue,
+ },
displayOperationId: {
typeCaster: booleanTypeCaster,
defaultValue: defaultOptions.displayOperationId,
diff --git a/src/core/plugins/oas3/components/request-body.jsx b/src/core/plugins/oas3/components/request-body.jsx
index 64318fa9ec9..4fd4e40c540 100644
--- a/src/core/plugins/oas3/components/request-body.jsx
+++ b/src/core/plugins/oas3/components/request-body.jsx
@@ -54,7 +54,7 @@ const RequestBody = ({
const handleFile = (e) => {
onChange(e.target.files[0])
}
- const setIsIncludedOptions = (key) => {
+ const setIsIncludedOptions = (key, defaultSendEmptyValue) => {
let options = {
key,
shouldDispatchInit: false,
@@ -63,7 +63,7 @@ const RequestBody = ({
let currentInclusion = requestBodyInclusionSetting.get(key, "no value")
if (currentInclusion === "no value") {
options.shouldDispatchInit = true
- // future: can get/set defaultValue from a config setting
+ options.defaultValue = defaultSendEmptyValue
}
return options
}
@@ -76,7 +76,7 @@ const RequestBody = ({
const Example = getComponent("Example")
const ParameterIncludeEmpty = getComponent("ParameterIncludeEmpty")
- const { showCommonExtensions } = getConfigs()
+ const { showCommonExtensions, defaultSendEmptyValue } = getConfigs()
const requestBodyDescription = requestBody?.get("description") ?? null
const requestBodyContent = requestBody?.get("content") ?? new OrderedMap()
@@ -223,7 +223,7 @@ const RequestBody = ({
onChangeIncludeEmpty(key, value)}
isIncluded={included}
- isIncludedOptions={setIsIncludedOptions(key)}
+ isIncludedOptions={setIsIncludedOptions(key, defaultSendEmptyValue)}
isDisabled={Array.isArray(currentValue) ? currentValue.length !== 0 : !isEmptyValue(currentValue)}
/>
)}
diff --git a/test/unit/docker/translator.js b/test/unit/docker/translator.js
index 28291971c29..6d6c6718380 100644
--- a/test/unit/docker/translator.js
+++ b/test/unit/docker/translator.js
@@ -238,6 +238,7 @@ describe("docker: env translator", function() {
DEFAULT_MODELS_EXPAND_DEPTH: "0",
DEFAULT_MODEL_EXPAND_DEPTH: "1",
DEFAULT_MODEL_RENDERING: "example",
+ DEFAULT_SEND_EMPTY_VAlUE: "false",
DISPLAY_REQUEST_DURATION: "true",
DOC_EXPANSION: "full",
FILTER: "wowee",
@@ -264,6 +265,7 @@ describe("docker: env translator", function() {
defaultModelsExpandDepth: 0,
defaultModelExpandDepth: 1,
defaultModelRendering: "example",
+ defaultSendEmptyValue: false,
displayRequestDuration: true,
docExpansion: "full",
filter: "wowee",
@@ -294,6 +296,7 @@ describe("docker: env translator", function() {
DEFAULT_MODELS_EXPAND_DEPTH: "0",
DEFAULT_MODEL_EXPAND_DEPTH: "1",
DEFAULT_MODEL_RENDERING: "example",
+ DEFAULT_SEND_EMPTY_VAlUE: "false",
DISPLAY_REQUEST_DURATION: "true",
DOC_EXPANSION: "full",
FILTER: "wowee",
@@ -328,6 +331,7 @@ describe("docker: env translator", function() {
defaultModelsExpandDepth: 0,
defaultModelExpandDepth: 1,
defaultModelRendering: "example",
+ defaultSendEmptyValue: false,
displayRequestDuration: true,
docExpansion: "full",
filter: "wowee",