Skip to content

Commit b5e8081

Browse files
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
1 parent a920357 commit b5e8081

File tree

6 files changed

+10
-3
lines changed

6 files changed

+10
-3
lines changed

src/core/components/example.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import ImPropTypes from "react-immutable-proptypes"
88
import { stringify } from "core/utils"
99

1010
export default function Example(props) {
11-
const { example, showValue, getComponent } = props
11+
const { example, showValue, getComponent, getConfigs } = props
1212

1313
const Markdown = getComponent("Markdown", true)
1414
const HighlightCode = getComponent("highlightCode")
@@ -28,7 +28,7 @@ export default function Example(props) {
2828
{showValue && example.has("value") ? (
2929
<section className="example__section">
3030
<div className="example__section-header">Example Value</div>
31-
<HighlightCode value={stringify(example.get("value"))} />
31+
<HighlightCode getConfigs={ getConfigs } value={stringify(example.get("value"))} />
3232
</section>
3333
) : null}
3434
</div>
@@ -39,4 +39,5 @@ Example.propTypes = {
3939
example: ImPropTypes.map.isRequired,
4040
showValue: PropTypes.bool,
4141
getComponent: PropTypes.func.isRequired,
42+
getConfigs: PropTypes.func.getConfigs,
4243
}

src/core/components/model-example.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default class ModelExample extends React.Component {
7676
{
7777
this.state.activeTab === "example" ? (
7878
example ? example : (
79-
<HighlightCode value="(no example available)" />
79+
<HighlightCode value="(no example available)" getConfigs={ getConfigs } />
8080
)
8181
) : null
8282
}

src/core/components/parameter-row.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ export default class ParameterRow extends Component {
369369
oas3Selectors.activeExamplesMember(...pathMethod, "parameters", this.getParamKey())
370370
])}
371371
getComponent={getComponent}
372+
getConfigs={getConfigs}
372373
/>
373374
) : null
374375
}

src/core/components/parameters/parameters.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export default class Parameters extends Component {
107107
const isExecute = tryItOutEnabled && allowTryItOut
108108
const isOAS3 = specSelectors.isOAS3()
109109

110+
110111
const requestBody = operation.get("requestBody")
111112
return (
112113
<div className="opblock-section">
@@ -200,6 +201,7 @@ export default class Parameters extends Component {
200201
requestBodyInclusionSetting={oas3Selectors.requestBodyInclusionSetting(...pathMethod)}
201202
requestBodyErrors={oas3Selectors.requestBodyErrors(...pathMethod)}
202203
isExecute={isExecute}
204+
getConfigs={getConfigs}
203205
activeExamplesKey={oas3Selectors.activeExamplesMember(
204206
...pathMethod,
205207
"requestBody",

src/core/components/response.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ export default class Response extends React.Component {
226226
<Example
227227
example={examplesForMediaType.get(this.getTargetExamplesKey(), Map({}))}
228228
getComponent={getComponent}
229+
getConfigs={getConfigs}
229230
omitValue={true}
230231
/>
231232
) : null}

src/core/plugins/oas3/components/request-body.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ const RequestBody = ({
250250
example={
251251
<HighlightCode
252252
className="body-param__example"
253+
getConfigs={getConfigs}
253254
value={stringify(requestBodyValue) || getDefaultRequestBodyValue(
254255
requestBody,
255256
contentType,
@@ -266,6 +267,7 @@ const RequestBody = ({
266267
<Example
267268
example={examplesForMediaType.get(activeExamplesKey)}
268269
getComponent={getComponent}
270+
getConfigs={getConfigs}
269271
/>
270272
) : null
271273
}

0 commit comments

Comments
 (0)