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
This commit is contained in:
@@ -8,7 +8,7 @@ import ImPropTypes from "react-immutable-proptypes"
|
|||||||
import { stringify } from "core/utils"
|
import { stringify } from "core/utils"
|
||||||
|
|
||||||
export default function Example(props) {
|
export default function Example(props) {
|
||||||
const { example, showValue, getComponent } = props
|
const { example, showValue, getComponent, getConfigs } = props
|
||||||
|
|
||||||
const Markdown = getComponent("Markdown", true)
|
const Markdown = getComponent("Markdown", true)
|
||||||
const HighlightCode = getComponent("highlightCode")
|
const HighlightCode = getComponent("highlightCode")
|
||||||
@@ -28,7 +28,7 @@ export default function Example(props) {
|
|||||||
{showValue && example.has("value") ? (
|
{showValue && example.has("value") ? (
|
||||||
<section className="example__section">
|
<section className="example__section">
|
||||||
<div className="example__section-header">Example Value</div>
|
<div className="example__section-header">Example Value</div>
|
||||||
<HighlightCode value={stringify(example.get("value"))} />
|
<HighlightCode getConfigs={ getConfigs } value={stringify(example.get("value"))} />
|
||||||
</section>
|
</section>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
@@ -39,4 +39,5 @@ Example.propTypes = {
|
|||||||
example: ImPropTypes.map.isRequired,
|
example: ImPropTypes.map.isRequired,
|
||||||
showValue: PropTypes.bool,
|
showValue: PropTypes.bool,
|
||||||
getComponent: PropTypes.func.isRequired,
|
getComponent: PropTypes.func.isRequired,
|
||||||
|
getConfigs: PropTypes.func.getConfigs,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export default class ModelExample extends React.Component {
|
|||||||
{
|
{
|
||||||
this.state.activeTab === "example" ? (
|
this.state.activeTab === "example" ? (
|
||||||
example ? example : (
|
example ? example : (
|
||||||
<HighlightCode value="(no example available)" />
|
<HighlightCode value="(no example available)" getConfigs={ getConfigs } />
|
||||||
)
|
)
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -369,6 +369,7 @@ export default class ParameterRow extends Component {
|
|||||||
oas3Selectors.activeExamplesMember(...pathMethod, "parameters", this.getParamKey())
|
oas3Selectors.activeExamplesMember(...pathMethod, "parameters", this.getParamKey())
|
||||||
])}
|
])}
|
||||||
getComponent={getComponent}
|
getComponent={getComponent}
|
||||||
|
getConfigs={getConfigs}
|
||||||
/>
|
/>
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ export default class Parameters extends Component {
|
|||||||
const isExecute = tryItOutEnabled && allowTryItOut
|
const isExecute = tryItOutEnabled && allowTryItOut
|
||||||
const isOAS3 = specSelectors.isOAS3()
|
const isOAS3 = specSelectors.isOAS3()
|
||||||
|
|
||||||
|
|
||||||
const requestBody = operation.get("requestBody")
|
const requestBody = operation.get("requestBody")
|
||||||
return (
|
return (
|
||||||
<div className="opblock-section">
|
<div className="opblock-section">
|
||||||
@@ -200,6 +201,7 @@ export default class Parameters extends Component {
|
|||||||
requestBodyInclusionSetting={oas3Selectors.requestBodyInclusionSetting(...pathMethod)}
|
requestBodyInclusionSetting={oas3Selectors.requestBodyInclusionSetting(...pathMethod)}
|
||||||
requestBodyErrors={oas3Selectors.requestBodyErrors(...pathMethod)}
|
requestBodyErrors={oas3Selectors.requestBodyErrors(...pathMethod)}
|
||||||
isExecute={isExecute}
|
isExecute={isExecute}
|
||||||
|
getConfigs={getConfigs}
|
||||||
activeExamplesKey={oas3Selectors.activeExamplesMember(
|
activeExamplesKey={oas3Selectors.activeExamplesMember(
|
||||||
...pathMethod,
|
...pathMethod,
|
||||||
"requestBody",
|
"requestBody",
|
||||||
|
|||||||
@@ -226,6 +226,7 @@ export default class Response extends React.Component {
|
|||||||
<Example
|
<Example
|
||||||
example={examplesForMediaType.get(this.getTargetExamplesKey(), Map({}))}
|
example={examplesForMediaType.get(this.getTargetExamplesKey(), Map({}))}
|
||||||
getComponent={getComponent}
|
getComponent={getComponent}
|
||||||
|
getConfigs={getConfigs}
|
||||||
omitValue={true}
|
omitValue={true}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
@@ -250,6 +250,7 @@ const RequestBody = ({
|
|||||||
example={
|
example={
|
||||||
<HighlightCode
|
<HighlightCode
|
||||||
className="body-param__example"
|
className="body-param__example"
|
||||||
|
getConfigs={getConfigs}
|
||||||
value={stringify(requestBodyValue) || getDefaultRequestBodyValue(
|
value={stringify(requestBodyValue) || getDefaultRequestBodyValue(
|
||||||
requestBody,
|
requestBody,
|
||||||
contentType,
|
contentType,
|
||||||
@@ -266,6 +267,7 @@ const RequestBody = ({
|
|||||||
<Example
|
<Example
|
||||||
example={examplesForMediaType.get(activeExamplesKey)}
|
example={examplesForMediaType.get(activeExamplesKey)}
|
||||||
getComponent={getComponent}
|
getComponent={getComponent}
|
||||||
|
getConfigs={getConfigs}
|
||||||
/>
|
/>
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user