From cf030906472bfe811c6779ee9a7d6317673dabb4 Mon Sep 17 00:00:00 2001 From: "Stiliyan Tonev (Bark)" Date: Sun, 9 Mar 2025 10:06:06 +0200 Subject: [PATCH] fix: Add case to handle x-examples value of body param. --- src/core/components/param-body.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/components/param-body.jsx b/src/core/components/param-body.jsx index 878b4546ab4..985d767c499 100644 --- a/src/core/components/param-body.jsx +++ b/src/core/components/param-body.jsx @@ -47,11 +47,19 @@ export default class ParamBody extends PureComponent { } updateValues = (props) => { - let { param, isExecute, consumesValue="" } = props + let { param, isExecute, consumesValue="", specSelectors, pathMethod } = props + let parameter = specSelectors ? specSelectors.parameterWithMetaByIdentity(pathMethod, param) : param let isXml = /xml/i.test(consumesValue) let isJson = /json/i.test(consumesValue) let paramValue = isXml ? param.get("value_xml") : param.get("value") - + let xExample = parameter.get("x-examples") + if (xExample) { + paramValue = xExample.get('default') !== undefined ? xExample.get('default') : paramValue + if (typeof paramValue !== "string") { + paramValue = JSON.stringify(paramValue, null, 2) + } + isJson = true + } if ( paramValue !== undefined ) { let val = !paramValue && isJson ? "{}" : paramValue this.setState({ value: val })