ginkgobioworks / react-json-schema-form-builder

Visual editor for forms based on json schema, built in React JS
Apache License 2.0
310 stars 80 forks source link

The data schema generated is not in json format #307

Open kenzhang-mark43 opened 2 years ago

kenzhang-mark43 commented 2 years ago

Tried the form builder here https://ginkgobioworks.github.io/react-json-schema-form-builder/ I can see the data schema is not in json format... so it is harder to test generated schema in the rjsf playground: https://rjsf-team.github.io/react-jsonschema-form/

should be quoted like

{
  "type": "object" ,
  "title": "hello"
}

This is what I get.

{
  type: 'object',
  title: 'hello',
  description: 'ta',
  properties: {
    newInput1: {
      enum: [
        '1',
        '2',
        '3'
      ],
      title: 'New Input 1',
      type: 'string',
      enumNames: [
        'Yes',
        'No',
        'Other'
      ]
    }
  },
  dependencies: {
    newInput1: {
      oneOf: [
        {
          properties: {
            newInput1: {
              enum: [
                '3'
              ]
            },
            Hello: {
              title: 'Hello,friend',
              type: 'string'
            }
          },
          required: []
        }
      ]
    }
  },
  required: []
}
nateplusplus commented 1 year ago

@raymond-lam I looked into this as a first issue to contribute but it looks to me like this is actually an issue with the package being used for JSON editors on the example pages. I'm getting the correct output from FormBuilder itself, showing double-quotes for all outputted JSON schemas.

When passing double-quoted JSON into react-json-editor-ajrm, that library will convert the quotes to single quotes every time.

Unfortunately, that package has been deprecated, however I have left a comment for the maintainer of that project to consider changing this in their next iteration.

I did some hunting to find a good alternative for this package but I honestly can't find one that does what react-json-editor-ajrm can do. Others use more of a form-style interface for editing JSON which is not ideal for this scenario.

Alternatively, we could simply display the JSON output on the example rather than allow it to be editable, but I do think showing that the JSON can be manipulated to change the form is a valuable demonstration. In my opinion, it might be best to wait until the new version of this JSON editor is released, as this issue is likely not a highly disruptive one.