feat(model view): hide applicable readOnly and writeOnly properties (#5832)
This commit is contained in:
@@ -15,7 +15,9 @@ export default class ArrayModel extends Component {
|
||||
required: PropTypes.bool,
|
||||
expandDepth: PropTypes.number,
|
||||
specPath: ImPropTypes.list.isRequired,
|
||||
depth: PropTypes.number
|
||||
depth: PropTypes.number,
|
||||
includeReadOnly: PropTypes.bool,
|
||||
includeWriteOnly: PropTypes.bool,
|
||||
}
|
||||
|
||||
render(){
|
||||
|
||||
@@ -11,6 +11,8 @@ export default class ModelExample extends React.Component {
|
||||
isExecute: PropTypes.bool,
|
||||
getConfigs: PropTypes.func.isRequired,
|
||||
specPath: ImPropTypes.list.isRequired,
|
||||
includeReadOnly: PropTypes.bool,
|
||||
includeWriteOnly: PropTypes.bool,
|
||||
}
|
||||
|
||||
constructor(props, context) {
|
||||
@@ -52,7 +54,7 @@ export default class ModelExample extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
let { getComponent, specSelectors, schema, example, isExecute, getConfigs, specPath } = this.props
|
||||
let { getComponent, specSelectors, schema, example, isExecute, getConfigs, specPath, includeReadOnly, includeWriteOnly } = this.props
|
||||
let { defaultModelExpandDepth } = getConfigs()
|
||||
const ModelWrapper = getComponent("ModelWrapper")
|
||||
const HighlightCode = getComponent("highlightCode")
|
||||
@@ -84,7 +86,9 @@ export default class ModelExample extends React.Component {
|
||||
getConfigs={ getConfigs }
|
||||
specSelectors={ specSelectors }
|
||||
expandDepth={ defaultModelExpandDepth }
|
||||
specPath={specPath} />
|
||||
specPath={specPath}
|
||||
includeReadOnly = {includeReadOnly}
|
||||
includeWriteOnly = {includeWriteOnly}/>
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,9 @@ export default class ModelWrapper extends Component {
|
||||
specSelectors: PropTypes.object.isRequired,
|
||||
expandDepth: PropTypes.number,
|
||||
layoutActions: PropTypes.object,
|
||||
layoutSelectors: PropTypes.object.isRequired
|
||||
layoutSelectors: PropTypes.object.isRequired,
|
||||
includeReadOnly: PropTypes.bool,
|
||||
includeWriteOnly: PropTypes.bool,
|
||||
}
|
||||
|
||||
getSchemaBasePath = () => {
|
||||
|
||||
@@ -16,6 +16,8 @@ export default class Model extends ImmutablePureComponent {
|
||||
expandDepth: PropTypes.number,
|
||||
depth: PropTypes.number,
|
||||
specPath: ImPropTypes.list.isRequired,
|
||||
includeReadOnly: PropTypes.bool,
|
||||
includeWriteOnly: PropTypes.bool,
|
||||
}
|
||||
|
||||
getModelName =( ref )=> {
|
||||
@@ -34,7 +36,8 @@ export default class Model extends ImmutablePureComponent {
|
||||
}
|
||||
|
||||
render () {
|
||||
let { getComponent, getConfigs, specSelectors, schema, required, name, isRef, specPath, displayName } = this.props
|
||||
let { getComponent, getConfigs, specSelectors, schema, required, name, isRef, specPath, displayName,
|
||||
includeReadOnly, includeWriteOnly} = this.props
|
||||
const ObjectModel = getComponent("ObjectModel")
|
||||
const ArrayModel = getComponent("ArrayModel")
|
||||
const PrimitiveModel = getComponent("PrimitiveModel")
|
||||
@@ -70,7 +73,9 @@ export default class Model extends ImmutablePureComponent {
|
||||
schema={ schema }
|
||||
name={ name }
|
||||
deprecated={deprecated}
|
||||
isRef={ isRef } />
|
||||
isRef={ isRef }
|
||||
includeReadOnly = {includeReadOnly}
|
||||
includeWriteOnly = {includeWriteOnly}/>
|
||||
case "array":
|
||||
return <ArrayModel
|
||||
className="array" { ...this.props }
|
||||
@@ -78,7 +83,9 @@ export default class Model extends ImmutablePureComponent {
|
||||
schema={ schema }
|
||||
name={ name }
|
||||
deprecated={deprecated}
|
||||
required={ required } />
|
||||
required={ required }
|
||||
includeReadOnly = {includeReadOnly}
|
||||
includeWriteOnly = {includeWriteOnly}/>
|
||||
case "string":
|
||||
case "number":
|
||||
case "integer":
|
||||
|
||||
@@ -90,7 +90,9 @@ export default class Models extends Component {
|
||||
specSelectors={ specSelectors }
|
||||
getConfigs = {getConfigs}
|
||||
layoutSelectors = {layoutSelectors}
|
||||
layoutActions = {layoutActions}/>
|
||||
layoutActions = {layoutActions}
|
||||
includeReadOnly = {true}
|
||||
includeWriteOnly = {true}/>
|
||||
|
||||
const title = <span className="model-box">
|
||||
<span className="model model-title">
|
||||
|
||||
@@ -19,12 +19,14 @@ export default class ObjectModel extends Component {
|
||||
isRef: PropTypes.bool,
|
||||
expandDepth: PropTypes.number,
|
||||
depth: PropTypes.number,
|
||||
specPath: ImPropTypes.list.isRequired
|
||||
specPath: ImPropTypes.list.isRequired,
|
||||
includeReadOnly: PropTypes.bool,
|
||||
includeWriteOnly: PropTypes.bool,
|
||||
}
|
||||
|
||||
render(){
|
||||
let { schema, name, displayName, isRef, getComponent, getConfigs, depth, onToggle, expanded, specPath, ...otherProps } = this.props
|
||||
let { specSelectors,expandDepth } = otherProps
|
||||
let { specSelectors,expandDepth, includeReadOnly, includeWriteOnly} = otherProps
|
||||
const { isOAS3 } = specSelectors
|
||||
|
||||
if(!schema) {
|
||||
@@ -87,7 +89,12 @@ export default class ObjectModel extends Component {
|
||||
</tr>
|
||||
}
|
||||
{
|
||||
!(properties && properties.size) ? null : properties.entrySeq().map(
|
||||
!(properties && properties.size) ? null : properties.entrySeq().filter(
|
||||
([, value]) => {
|
||||
return (!value.get("readOnly") || includeReadOnly) &&
|
||||
(!value.get("writeOnly") || includeWriteOnly)
|
||||
}
|
||||
).map(
|
||||
([key, value]) => {
|
||||
let isDeprecated = isOAS3() && value.get("deprecated")
|
||||
let isRequired = List.isList(requiredProperties) && requiredProperties.contains(key)
|
||||
|
||||
@@ -105,6 +105,7 @@ export default class ParameterRow extends Component {
|
||||
|
||||
// getSampleSchema could return null
|
||||
const generatedSampleValue = schema ? getSampleSchema(schema.toJS(), parameterMediaType, {
|
||||
|
||||
includeWriteOnly: true
|
||||
}) : null
|
||||
|
||||
@@ -331,7 +332,8 @@ export default class ParameterRow extends Component {
|
||||
isExecute={ isExecute }
|
||||
specSelectors={ specSelectors }
|
||||
schema={ schema }
|
||||
example={ bodyParam }/>
|
||||
example={ bodyParam }
|
||||
includeWriteOnly={ true }/>
|
||||
: null
|
||||
}
|
||||
|
||||
|
||||
@@ -218,7 +218,8 @@ export default class Response extends React.Component {
|
||||
getConfigs={ getConfigs }
|
||||
specSelectors={ specSelectors }
|
||||
schema={ fromJSOrdered(schema) }
|
||||
example={ example }/>
|
||||
example={ example }
|
||||
includeReadOnly={ true }/>
|
||||
) : null }
|
||||
|
||||
{ isOAS3 && examplesForMediaType ? (
|
||||
|
||||
@@ -237,6 +237,7 @@ const RequestBody = ({
|
||||
)}
|
||||
/>
|
||||
}
|
||||
includeWriteOnly={true}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ class ModelComponent extends Component {
|
||||
getComponent: PropTypes.func.isRequired,
|
||||
getConfigs: PropTypes.func.isRequired,
|
||||
specSelectors: PropTypes.object.isRequired,
|
||||
expandDepth: PropTypes.number
|
||||
expandDepth: PropTypes.number,
|
||||
includeReadOnly: PropTypes.bool,
|
||||
includeWriteOnly: PropTypes.bool,
|
||||
}
|
||||
|
||||
render(){
|
||||
|
||||
Reference in New Issue
Block a user