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

Add a JSON Schema for what the JSON model should look like and validate against invalid JSON input #158

Open
rhamzeh opened this issue Feb 15, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@rhamzeh
Copy link
Member

rhamzeh commented Feb 15, 2024

See: openfga/openfga#1164

The below model is invalid because the intersection definition in the document#viewer relation is malformed. It’s missing a child: […] nested block.

{
  "schema_version": "1.1",
  "type_definitions": [
    {
        "type": "user"
    },
    {
        "type": "folder",
        "relations": {
            "viewer": {"this": {}},
            "parent": {"this": {}}
        },
        "metadata": {
            "relations": {
                "viewer": {
                    "directly_related_user_types": [{"type": "user"}]
                },
                "parent": {
                    "directly_related_user_types": [{"type": "folder"}]
                }
            }
        }
    },
    {
        "type": "document",
        "relations": {
            "parent": {"this": {}},
            "viewer": {
                "union": {
                    "child": [
                        {
                            "intersection": {
                                "tupleToUserset": {
                                    "tupleset": {
                                        "relation": "parent"
                                    },
                                    "computedUserset": {
                                        "relation": "viewer"
                                    }
                                }
                            }
                        },
                        {"this": {}}
                    ]
                }
            }
        },
        "metadata": {
            "relations": {
                "parent": {
                    "directly_related_user_types": [{"type": "folder", "relation": "parent"}]
                },
                "viewer": {
                    "directly_related_user_types": [{"type": "user"}]
                }
            }
        }
    }
  ]
}
@rhamzeh rhamzeh added the enhancement New feature or request label Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Ready
Development

No branches or pull requests

1 participant