Skip to content

Commit

Permalink
fix(syntax-highlighter): configuration for Examples (#6455)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
AdrieanKhisbe authored Oct 2, 2020
1 parent a920357 commit b5e8081
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/core/components/example.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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>
Expand All @@ -39,4 +39,5 @@ Example.propTypes = {
example: ImPropTypes.map.isRequired,
showValue: PropTypes.bool,
getComponent: PropTypes.func.isRequired,
getConfigs: PropTypes.func.getConfigs,
}
2 changes: 1 addition & 1 deletion src/core/components/model-example.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/core/components/parameter-row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ export default class ParameterRow extends Component {
oas3Selectors.activeExamplesMember(...pathMethod, "parameters", this.getParamKey())
])}
getComponent={getComponent}
getConfigs={getConfigs}
/>
) : null
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/components/parameters/parameters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/core/components/response.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 2 additions & 0 deletions src/core/plugins/oas3/components/request-body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ const RequestBody = ({
example={
<HighlightCode
className="body-param__example"
getConfigs={getConfigs}
value={stringify(requestBodyValue) || getDefaultRequestBodyValue(
requestBody,
contentType,
Expand All @@ -266,6 +267,7 @@ const RequestBody = ({
<Example
example={examplesForMediaType.get(activeExamplesKey)}
getComponent={getComponent}
getConfigs={getConfigs}
/>
) : null
}
Expand Down

0 comments on commit b5e8081

Please sign in to comment.