-
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 includeReadOnly/WriteOnly options (#8675)
Refs #8513
- Loading branch information
Showing
8 changed files
with
108 additions
and
8 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
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
56 changes: 56 additions & 0 deletions
56
src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/Properties.jsx
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,56 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
import React from "react" | ||
import PropTypes from "prop-types" | ||
import classNames from "classnames" | ||
|
||
const Properties = ({ schema, getSystem }) => { | ||
const { fn } = getSystem() | ||
const { useComponent } = fn.jsonSchema202012 | ||
const { getDependentRequired, getProperties } = fn.jsonSchema202012.useFn() | ||
const config = fn.jsonSchema202012.useConfig() | ||
const required = Array.isArray(schema?.required) ? schema.required : [] | ||
const JSONSchema = useComponent("JSONSchema") | ||
const properties = getProperties(schema, config) | ||
|
||
/** | ||
* Rendering. | ||
*/ | ||
if (Object.keys(properties).length === 0) { | ||
return null | ||
} | ||
|
||
return ( | ||
<div className="json-schema-2020-12-keyword json-schema-2020-12-keyword--properties"> | ||
<ul> | ||
{Object.entries(properties).map(([propertyName, propertySchema]) => { | ||
const isRequired = required.includes(propertyName) | ||
const dependentRequired = getDependentRequired(propertyName, schema) | ||
|
||
return ( | ||
<li | ||
key={propertyName} | ||
className={classNames("json-schema-2020-12-property", { | ||
"json-schema-2020-12-property--required": isRequired, | ||
})} | ||
> | ||
<JSONSchema | ||
name={propertyName} | ||
schema={propertySchema} | ||
dependentRequired={dependentRequired} | ||
/> | ||
</li> | ||
) | ||
})} | ||
</ul> | ||
</div> | ||
) | ||
} | ||
|
||
Properties.propTypes = { | ||
schema: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]).isRequired, | ||
getSystem: PropTypes.func.isRequired, | ||
} | ||
|
||
export default Properties |
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
9 changes: 9 additions & 0 deletions
9
...core/plugins/oas31/json-schema-2020-12-extensions/wrap-components/keywords/Properties.jsx
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,9 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
import PropertiesKeyword from "../../components/keywords/Properties" | ||
import { createOnlyOAS31ComponentWrapper } from "../../../fn" | ||
|
||
const PropertiesWrapper = createOnlyOAS31ComponentWrapper(PropertiesKeyword) | ||
|
||
export default PropertiesWrapper |
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