From a887e7236801acde76e814df147b211ba6678c5f Mon Sep 17 00:00:00 2001 From: Timothy Lai Date: Mon, 19 Apr 2021 16:15:28 -0700 Subject: [PATCH 1/5] fix(oas2): syntax highlighting with json values * param-body * response --- src/core/components/param-body.jsx | 15 +++++++++++++-- src/core/components/response.jsx | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/core/components/param-body.jsx b/src/core/components/param-body.jsx index 6ee9e76de03..146247abc47 100644 --- a/src/core/components/param-body.jsx +++ b/src/core/components/param-body.jsx @@ -112,6 +112,16 @@ export default class ParamBody extends PureComponent { let consumes = this.props.consumes && this.props.consumes.size ? this.props.consumes : ParamBody.defaultProp.consumes let { value, isEditBox } = this.state + let language = null + + try { + let testValueForJson = JSON.parse(value) + if (testValueForJson) { + language = "json" + } + } catch(e) { + // do nothing + } return (
@@ -119,8 +129,9 @@ export default class ParamBody extends PureComponent { isEditBox && isExecute ?