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

JSON Schema for JSON diagram config #81

Closed
ceckoslab opened this issue Mar 30, 2020 · 5 comments · Fixed by #96
Closed

JSON Schema for JSON diagram config #81

ceckoslab opened this issue Mar 30, 2020 · 5 comments · Fixed by #96
Assignees

Comments

@ceckoslab
Copy link
Contributor

Hello @korzol

After we finish with #56 we will implement JSON schema validation and autocomplete.

I did some research and I found this project that looks really promising: https://github.com/josdejong/jsoneditor

We will start with static hardcoded JSON schema but in another ticket we will think how we can make the schema dynamic based on what metrics we have.

@korzol
Copy link
Contributor

korzol commented Apr 8, 2020

Hello @ceckoslab
So I have implemented aforementioned JSON editor but there is a problem with it.
When I use enum in schema it should generate selectbox for that entry. Although it works for static - hardcoded entries, it doesn't for entries lets say in definitions. Once I met this for my schema implementation, I decided to test the one provided as example on json-schema.org - Structuring a complex schema

Here is it:

const schema2 = {
          "$schema": "http://json-schema.org/draft-07/schema#",

          "definitions": {
            "address": {
              "type": "object",
              "properties": {
                "street_address": { "type": "string" },
                "city":           { "enum": ["Washington", "New-York"] },
                "state":          { "type": "string" }
              },
              "required": ["street_address", "city", "state"]
            }
          },

          "type": "object",

          "properties": {
            "billing_address": { "$ref": "#/definitions/address" },
            "shipping_address": { "$ref": "#/definitions/address" }
          }
        };

        const json2 = {
            "shipping_address": {
                "street_address": "1600 Pennsylvania Avenue NW",
                "city": null,
                "state": "DC"
              },
            "billing_address": {
                "street_address": "1st Street SE",
                "city": null,
                "state": "DC"
            }
        };

const options = {
        schema: schema2,
        mode: 'tree',
        modes: ['code', 'text', 'tree', 'preview'],
    };

const container = document.getElementById('jsoneditor');
const editor = new JSONEditor(container, options, json2);

Here is the result:
jsoneditor-bug

As seen from provided screenshot the editor proceed schema although fails to generate selectbox

There is a bug filled out - josdejong/jsoneditor#473

@korzol
Copy link
Contributor

korzol commented Apr 8, 2020

Here is a result for our real schema & json
jsoneditor-bug2

segments.1.presentation.type is enum and should be a select box (html tag)

@korzol
Copy link
Contributor

korzol commented Apr 8, 2020

jsoneditor-bug3
jsoneditor-bug4

@ceckoslab
Copy link
Contributor Author

Hello @korzol

It looks good and I think that we can continue even with the glitch you've described about the Select box.

I played a bit the JSON editor. I see some missing control icons, could we add them?

Also could we make the popup higher and wider in order to have more visible space where we can write?

@korzol
Copy link
Contributor

korzol commented Apr 8, 2020

Okay, thanks for update.

Also could we make the popup higher and wider in order to have more visible space where we can write?

Yes, of course, I will do it in the morning.

Although what control icons you mean?

@korzol korzol linked a pull request Apr 9, 2020 that will close this issue
@ceckoslab ceckoslab added this to the 1. Production ready Alfa milestone Apr 12, 2020
ceckoslab pushed a commit that referenced this issue Apr 13, 2020
* Intermediate commit. Already setup editor and part of schema

* Add outstanding json editor files

* Intermediate commit. Done with schema

* JSON validation & save

* Outstanding icons for JSON editor

* Fix: remove JSON data and leave structure only
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

Successfully merging a pull request may close this issue.

2 participants