-
Notifications
You must be signed in to change notification settings - Fork 9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(oas31): add support for rendering OpenAPI.jsonSchemaDialect field (
- Loading branch information
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
|
||
import React from "react" | ||
import PropTypes from "prop-types" | ||
|
||
import { sanitizeUrl } from "core/utils" | ||
|
||
const JsonSchemaDialect = ({ getComponent, specSelectors }) => { | ||
const jsonSchemaDialect = specSelectors.selectJsonSchemaDialectField() | ||
const jsonSchemaDialectDefault = specSelectors.selectJsonSchemaDialectDefault() // prettier-ignore | ||
|
||
const Link = getComponent("Link") | ||
|
||
return ( | ||
<> | ||
{jsonSchemaDialect && jsonSchemaDialect === jsonSchemaDialectDefault && ( | ||
<p className="info__jsonschemadialect"> | ||
JSON Schema dialect:{" "} | ||
<Link target="_blank" href={sanitizeUrl(jsonSchemaDialect)}> | ||
{jsonSchemaDialect} | ||
</Link> | ||
</p> | ||
)} | ||
|
||
{jsonSchemaDialect && jsonSchemaDialect !== jsonSchemaDialectDefault && ( | ||
<div className="error-wrapper"> | ||
<div className="no-margin"> | ||
<div className="errors"> | ||
<div className="errors-wrapper"> | ||
<h4 className="center">Warning</h4> | ||
<p className="message"> | ||
<strong>OpenAPI.jsonSchemaDialect</strong> field contains a | ||
value different from the default value of{" "} | ||
<Link target="_blank" href={jsonSchemaDialectDefault}> | ||
{jsonSchemaDialectDefault} | ||
</Link> | ||
. Values different from the default one are currently not | ||
supported. Please either omit the field or provide it with the | ||
default value. | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
JsonSchemaDialect.propTypes = { | ||
getComponent: PropTypes.func.isRequired, | ||
specSelectors: PropTypes.shape({ | ||
selectJsonSchemaDialectField: PropTypes.func.isRequired, | ||
selectJsonSchemaDialectDefault: PropTypes.func.isRequired, | ||
}).isRequired, | ||
} | ||
|
||
export default JsonSchemaDialect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters