Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported field schema #611

Closed
1 task done
gastonche opened this issue Jun 14, 2017 · 3 comments
Closed
1 task done

Unsupported field schema #611

gastonche opened this issue Jun 14, 2017 · 3 comments

Comments

@gastonche
Copy link

gastonche commented Jun 14, 2017

Prerequisites

Description

I am trying to generate forms for a schema onthe playground but i keep getting an error, and I am unable to solve the error. The schema is tested valid on jsonschemalint.com the error i get is

Unsupported field schema { "definitions": { "address": { "type": "object", "properties": { "street_address": { "type": "string" }, "city": { "type": "string" }, "state": { "type": "string" } }, "required": [ "street_address", "city", "state" ] } }, "allOf": [ { "$ref": "#/definitions/address" }, { "properties": { "type": { "enum": [ "residential", "business" ] } } } ] }.

the json I am trying to use is

{
  "definitions": {
    "address": {
      "type": "object",
      "properties": {
        "street_address": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "state": {
          "type": "string"
        }
      },
      "required": [
        "street_address",
        "city",
        "state"
      ]
    }
  },
  "allOf": [
    {
      "$ref": "#/definitions/address"
    },
    {
      "properties": {
        "type": {
          "enum": [
            "residential",
            "business"
          ]
        }
      }
    }
  ]
}

I don't understand what is wrong. I intend to use this library for my project

Steps to Reproduce

  1. visit https://mozilla-services.github.io/react-jsonschema-form/
    2.enter the obove schema in place of the json schema
    3.replace the ui-schema and formData contents with { }

Ideally, I'm providing a shared playground link demonstrating the issue.

Expected behavior

I expected the playground to generate forms from the schema

Actual behavior

Gives this error instead:

Unsupported field schema { "definitions": { "address": { "type": "object", "properties": { "street_address": { "type": "string" }, "city": { "type": "string" }, "state": { "type": "string" } }, "required": [ "street_address", "city", "state" ] } }, "allOf": [ { "$ref": "#/definitions/address" }, { "properties": { "type": { "enum": [ "residential", "business" ] } } } ] }.
@tappleby
Copy link

I ran into this issue as well, it was caused by the enum definition without a "type": "string" set, looks like its a known issue: #66.

penx added a commit to penx/react-jsonschema-form that referenced this issue Aug 15, 2017
penx added a commit to penx/react-jsonschema-form that referenced this issue Aug 15, 2017
@penx penx mentioned this issue Aug 15, 2017
4 tasks
glasserc pushed a commit that referenced this issue Jan 10, 2018
* Failing test for enum without type (#66 #611)

* Proposed fix for enum without type (#66 #611)

* PR feedback - getSchemaType function

https://github.com/mozilla-services/react-jsonschema-form/pull/668/files#r133395455
jnorris-carecloud added a commit to CareCloud/react-jsonschema-form that referenced this issue Jul 2, 2018
* Fix rjsf-team#221: No validating but updating errorSchema base on array operation when live validation is off.

* Fix comparing

* Directly update errorSchema in onChange

* Typo fix (rjsf-team#737)

* Make form submission example clearer (rjsf-team#736)

In the example, the `onSubmit` function receives a `formData` obj. However, the actual data is in `formData.formData`. While this is explained in the docs, I propose making it clearer in the example as well.

* Update prettier to v1.8.2 (rjsf-team#756)

* fix: Pass `disabled` prop to `FieldTemplate`. (rjsf-team#741)

If you want to change how your FieldTemplate is rendered based on
ui:disabled, you currently have to check `uiSchema["ui:disabled"]`,
which is unlike the pattern for `readonly` and other known `ui:*`
settings.

* Fix issue rjsf-team#747 (rjsf-team#748)

* 66 enum no type (rjsf-team#668)

* Failing test for enum without type (rjsf-team#66 rjsf-team#611)

* Proposed fix for enum without type (rjsf-team#66 rjsf-team#611)

* PR feedback - getSchemaType function

https://github.com/mozilla-services/react-jsonschema-form/pull/668/files#r133395455

* Fix onAddClick signature in ArrayFieldTemplate (rjsf-team#775)

According to https://github.com/mozilla-services/react-jsonschema-form/blob/master/src/components/fields/ArrayField.js#L224 `onAddClick` is not returning function as specified in the documentation.

* fix typo in css code (rjsf-team#799)

* README: fix code snippet (rjsf-team#785)

* Generating idSchema based on dependency changes Fix rjsf-team#778 , Fix rjsf-team#803

* Add idPrefix option (Fix rjsf-team#796) (rjsf-team#806)

* Make .editorconfig valid (rjsf-team#807)

* typo (rjsf-team#811)

* Add span and class to label required symbol (rjsf-team#765)

* a priori should be italicized for readibility (rjsf-team#825)

* Priori should by prior, I think

* Italicizing a priori based on suggestion

* pass raw errors to  field widgets (rjsf-team#826)

* pass raw errors to  field widgets

* fixed formatting

* fixing line endings

* Pass raw errors into Field at creation; object destructuring; added test for passing of raw errors; removed unused prop from ArrayField.

* fix lineEndings

* Bump 1.0.1

* Move to the 3.x series of react-codemirror2 (rjsf-team#857)

* Move to the 3.x series of react-codemirror2

* Move to the 4.x series of react-codemirror2

See scniro/react-codemirror2#63 for more details.

* Pass formContext to ArrayFieldTemplate when rendering fixed array (rjsf-team#858)

* handle errors to correctly display schema errors in form (rjsf-team#864)

* Bump version 1.0.2

* Link to official JSON Schema site (rjsf-team#873)

* Updated README to mention the support from JSON Schema compliant drop-down enums (rjsf-team#882)

* Add passing of raw errors to ArrayField template and components (rjsf-team#876)

* Fixed multiplicative errors on schema dependencies (rjsf-team#884)

* Add idPrefix option (rjsf-team#883)

* Fix warning on FileWidget (rjsf-team#842)

* Update prettier and fix files (rjsf-team#892)

* Bump 1.0.3
@epicfaace
Copy link
Member

@gastonche It looks like the problem is that you are trying to use allOf, while allOf is not supported by this library yet. Tracking progress on that in #52.

@Abhiwolf
Copy link

npm install @rjsf/core --save

import Form from '@rjsf/core';

export class JsonSchemaFormVersionPage extends React.PureComponent {
static propTypes = {
updateJsonSchema: PropTypes.func.isRequired,
};

handleChange = (formData) => {
this.props.updateJsonSchema(formData.formData);
};

render() {
// const { updateJsonSchema } = this.props;
return (




);
}
}

Try above code. It will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants