未验证 提交 b5e80811 编写于 作者: A Adrien Becchis 提交者: GitHub

fix(syntax-highlighter): configuration for Examples (#6455)

* Complement #5259, getConfigs was not correctly forwarded to Examples. As a result, syntax highlight could not be disabled be disabled or configured in that elements
上级 a920357c
......@@ -8,7 +8,7 @@ import ImPropTypes from "react-immutable-proptypes"
import { stringify } from "core/utils"
export default function Example(props) {
const { example, showValue, getComponent } = props
const { example, showValue, getComponent, getConfigs } = props
const Markdown = getComponent("Markdown", true)
const HighlightCode = getComponent("highlightCode")
......@@ -28,7 +28,7 @@ export default function Example(props) {
{showValue && example.has("value") ? (
<section className="example__section">
<div className="example__section-header">Example Value</div>
<HighlightCode value={stringify(example.get("value"))} />
<HighlightCode getConfigs={ getConfigs } value={stringify(example.get("value"))} />
</section>
) : null}
</div>
......@@ -39,4 +39,5 @@ Example.propTypes = {
example: ImPropTypes.map.isRequired,
showValue: PropTypes.bool,
getComponent: PropTypes.func.isRequired,
getConfigs: PropTypes.func.getConfigs,
}
......@@ -76,7 +76,7 @@ export default class ModelExample extends React.Component {
{
this.state.activeTab === "example" ? (
example ? example : (
<HighlightCode value="(no example available)" />
<HighlightCode value="(no example available)" getConfigs={ getConfigs } />
)
) : null
}
......
......@@ -369,6 +369,7 @@ export default class ParameterRow extends Component {
oas3Selectors.activeExamplesMember(...pathMethod, "parameters", this.getParamKey())
])}
getComponent={getComponent}
getConfigs={getConfigs}
/>
) : null
}
......
......@@ -107,6 +107,7 @@ export default class Parameters extends Component {
const isExecute = tryItOutEnabled && allowTryItOut
const isOAS3 = specSelectors.isOAS3()
const requestBody = operation.get("requestBody")
return (
<div className="opblock-section">
......@@ -200,6 +201,7 @@ export default class Parameters extends Component {
requestBodyInclusionSetting={oas3Selectors.requestBodyInclusionSetting(...pathMethod)}
requestBodyErrors={oas3Selectors.requestBodyErrors(...pathMethod)}
isExecute={isExecute}
getConfigs={getConfigs}
activeExamplesKey={oas3Selectors.activeExamplesMember(
...pathMethod,
"requestBody",
......
......@@ -226,6 +226,7 @@ export default class Response extends React.Component {
<Example
example={examplesForMediaType.get(this.getTargetExamplesKey(), Map({}))}
getComponent={getComponent}
getConfigs={getConfigs}
omitValue={true}
/>
) : null}
......
......@@ -250,6 +250,7 @@ const RequestBody = ({
example={
<HighlightCode
className="body-param__example"
getConfigs={getConfigs}
value={stringify(requestBodyValue) || getDefaultRequestBodyValue(
requestBody,
contentType,
......@@ -266,6 +267,7 @@ const RequestBody = ({
<Example
example={examplesForMediaType.get(activeExamplesKey)}
getComponent={getComponent}
getConfigs={getConfigs}
/>
) : null
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册