Parcourir la source

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
bubble
Adrien Becchis il y a 4 ans
committed by GitHub
Parent
révision
b5e8081115
Aucune clé connue n'a été trouvée dans la base pour cette signature ID de la clé GPG: 4AEE18F83AFDEB23
6 fichiers modifiés avec 10 ajouts et 3 suppressions
  1. +3
    -2
      src/core/components/example.jsx
  2. +1
    -1
      src/core/components/model-example.jsx
  3. +1
    -0
      src/core/components/parameter-row.jsx
  4. +2
    -0
      src/core/components/parameters/parameters.jsx
  5. +1
    -0
      src/core/components/response.jsx
  6. +2
    -0
      src/core/plugins/oas3/components/request-body.jsx

+ 3
- 2
src/core/components/example.jsx Voir le fichier

@@ -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,
}

+ 1
- 1
src/core/components/model-example.jsx Voir le fichier

@@ -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
}


+ 1
- 0
src/core/components/parameter-row.jsx Voir le fichier

@@ -369,6 +369,7 @@ export default class ParameterRow extends Component {
oas3Selectors.activeExamplesMember(...pathMethod, "parameters", this.getParamKey())
])}
getComponent={getComponent}
getConfigs={getConfigs}
/>
) : null
}


+ 2
- 0
src/core/components/parameters/parameters.jsx Voir le fichier

@@ -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",


+ 1
- 0
src/core/components/response.jsx Voir le fichier

@@ -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}


+ 2
- 0
src/core/plugins/oas3/components/request-body.jsx Voir le fichier

@@ -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
}


Chargement…
Annuler
Enregistrer