From 46b97903a5095915f2d2f51db152797bf9a18bcc Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Thu, 25 Jan 2018 18:01:18 -0800 Subject: [PATCH] Account for Immutable data structure in JavaScriptonSchema... ...and create empty Lists instead of Maps by default. --- src/core/json-schema-components.js | 7 ++++--- src/core/plugins/spec/reducers.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/json-schema-components.js b/src/core/json-schema-components.js index 1edf2b12..66cc2e29 100644 --- a/src/core/json-schema-components.js +++ b/src/core/json-schema-components.js @@ -1,6 +1,7 @@ import React, { PureComponent, Component } from "react" import PropTypes from "prop-types" import { List, fromJS } from "immutable" +import ImPropTypes from "react-immutable-proptypes" //import "less/json-schema-form" const noop = ()=> {} @@ -11,7 +12,7 @@ const JsonSchemaPropShape = { keyName: PropTypes.any, fn: PropTypes.object.isRequired, schema: PropTypes.object, - errors: PropTypes.array, + errors: ImPropTypes.list, required: PropTypes.bool, description: PropTypes.any } @@ -22,7 +23,7 @@ const JsonSchemaDefaultProps = { schema: {}, keyName: "", required: false, - errors: [] + errors: List() } export class JsonSchemaForm extends Component { @@ -39,7 +40,7 @@ export class JsonSchemaForm extends Component { let { type, format="" } = schema let Comp = (format ? getComponent(`JsonSchema_${type}_${format}`) : getComponent(`JsonSchema_${type}`)) || getComponent("JsonSchema_string") - return + return } } diff --git a/src/core/plugins/spec/reducers.js b/src/core/plugins/spec/reducers.js index bdeabc04..f49519e0 100644 --- a/src/core/plugins/spec/reducers.js +++ b/src/core/plugins/spec/reducers.js @@ -68,7 +68,7 @@ export default { return state.updateIn( [ "resolved", "paths", ...pathMethod, "parameters" ], fromJS([]), parameters => { return parameters.withMutations( parameters => { for ( let i = 0, len = parameters.count(); i < len; i++ ) { - parameters.setIn([i, "errors"], fromJS({})) + parameters.setIn([i, "errors"], fromJS([])) } }) })