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

Generalize JSON schemas #5

Open
dennib opened this issue Mar 1, 2020 · 0 comments
Open

Generalize JSON schemas #5

dennib opened this issue Mar 1, 2020 · 0 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@dennib
Copy link
Collaborator

dennib commented Mar 1, 2020

Need help generalizing data schemas currently divided into two files:

  • data-schema.json
  • move-schema.json

move-schema.json is referenced inside of data-schema.json.

Currently data-schema.json is too verbose imho.

{
    "type": "object",
    "required": [
        "ryu",
        "chun-li",
        "nash",
         ...
        "seth"
    ],
    "properties": {
        "abigail": {
            "type": "object",
            "properties": {
                "vt1": {
                    "type": "array",
                    "items": {
                        "allOf": [
                            {
                                "type": "object",
                                "$ref": "file:data/schemas/move-schema.json"
                            }
                        ]
                    }
                },
                "vt2": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "$ref": "file:data/schemas/move-schema.json"
                    }
                }
            }
        },
        "akuma": {
            "type": "object",
            "properties": {
                "vt1": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "$ref": "file:data/schemas/move-schema.json"
                    }
                },
                "vt2": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "$ref": "file:data/schemas/move-schema.json"
                    }
                }
            }
        },
        "alex": {
            "type": "object",
            "properties": {
                "vt1": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "$ref": "file:data/schemas/move-schema.json"
                    }
                },
                "vt2": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "$ref": "file:data/schemas/move-schema.json"
                    }
                }
            }
        },

Every character is repeating its internal structure.

What I would like to do:

  1. Avoid to list evey single character, saying instead something like every root level property is an object of "this" type
  2. "this" type should be a reference to a new schema, the char-schema inside a new file (char-schema.json)
  3. Char schema should say something like required properties are "vt1" and "vt2", every root level properties are of type "array", containing items of type move-schema of move-schema.json

I wasn't able to specify a single rule for all the properties at a specif level (using "allOf") and to reference a local schema from within a referenced schema (reference move-schema from char-schema)

Help please :P

@dennib dennib added the help wanted Extra attention is needed label Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants