diff --git a/src/core/components/examples-select-value-retainer.jsx b/src/core/components/examples-select-value-retainer.jsx
index 9f0386243ec..a7149b59877 100644
--- a/src/core/components/examples-select-value-retainer.jsx
+++ b/src/core/components/examples-select-value-retainer.jsx
@@ -189,7 +189,7 @@ export default class ExamplesSelectValueRetainer extends React.PureComponent {
nextProps
)
- const exampleMatchingNewValue = examples.find(
+ const examplesMatchingNewValue = examples.filter(
(example) =>
example.get("value") === newValue ||
// sometimes data is stored as a string (e.g. in Request Bodies), so
@@ -197,8 +197,15 @@ export default class ExamplesSelectValueRetainer extends React.PureComponent {
stringify(example.get("value")) === newValue
)
- if (exampleMatchingNewValue) {
- onSelect(examples.keyOf(exampleMatchingNewValue), {
+ if (examplesMatchingNewValue.size) {
+ let key
+ if(examplesMatchingNewValue.has(nextProps.currentKey))
+ {
+ key = nextProps.currentKey
+ } else {
+ key = examplesMatchingNewValue.keySeq().first()
+ }
+ onSelect(key, {
isSyntheticChange: true,
})
} else if (
diff --git a/src/core/plugins/oas3/components/request-body.jsx b/src/core/plugins/oas3/components/request-body.jsx
index 42abaa20dff..db9f8aab395 100644
--- a/src/core/plugins/oas3/components/request-body.jsx
+++ b/src/core/plugins/oas3/components/request-body.jsx
@@ -83,7 +83,18 @@ const RequestBody = ({
const mediaTypeValue = requestBodyContent.get(contentType, OrderedMap())
const schemaForMediaType = mediaTypeValue.get("schema", OrderedMap())
- const examplesForMediaType = mediaTypeValue.get("examples", null)
+ const rawExamplesOfMediaType = mediaTypeValue.get("examples", null)
+ const sampleForMediaType = rawExamplesOfMediaType?.map((container, key) => {
+ const val = container?.get("value", null)
+ if(val) {
+ container = container.set("value", getDefaultRequestBodyValue(
+ requestBody,
+ contentType,
+ key,
+ ), val)
+ }
+ return container
+ })
const handleExamplesSelect = (key /*, { isSyntheticChange } */) => {
updateActiveExamplesKey(key)
@@ -223,10 +234,10 @@ const RequestBody = ({
}
{
- examplesForMediaType ? (
+ sampleForMediaType ? (