feat(try-it-out): display validation error messages (#8212)

This commit is contained in:
Dan Wallis
2022-10-14 17:36:13 +01:00
committed by GitHub
parent 0a7b3d6b2f
commit 130a1be133
3 changed files with 36 additions and 4 deletions

View File

@@ -112,6 +112,8 @@ export default class Operation extends PureComponent {
let onChangeKey = [ path, method ] // Used to add values to _this_ operation ( indexed by path and method )
const validationErrors = specSelectors.validationErrors([path, method])
return (
<div className={deprecated ? "opblock opblock-deprecated" : isShown ? `opblock opblock-${method} is-open` : `opblock opblock-${method}`} id={escapeDeepLinkPath(isShownKey.join("-"))} >
<OperationSummary operationProps={operationProps} isShown={isShown} toggleShown={toggleShown} getComponent={getComponent} authActions={authActions} authSelectors={authSelectors} specPath={specPath} />
@@ -189,6 +191,14 @@ export default class Operation extends PureComponent {
</div> : null
}
{ !tryItOutEnabled || !allowTryItOut || validationErrors.length <= 0 ? null : <div className="validation-errors errors-wrapper">
Please correct the following validation errors and try again.
<ul>
{ validationErrors.map((error, index) => <li key={index}> { error } </li>) }
</ul>
</div>
}
<div className={(!tryItOutEnabled || !response || !allowTryItOut) ? "execute-wrapper" : "btn-group"}>
{ !tryItOutEnabled || !allowTryItOut ? null :