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-patch schema can't be even loaded #174

Closed
s13o opened this issue May 9, 2018 · 2 comments
Closed

json-patch schema can't be even loaded #174

s13o opened this issue May 9, 2018 · 2 comments

Comments

@s13o
Copy link

s13o commented May 9, 2018

Just try to load a json schema from http://json.schemastore.org/json-patch by 'SchemaLoader.load'
The exception is

org.everit.json.schema.SchemaException: #/definitions/operation: expected at most 1 of 'allOf', 'anyOf', 'oneOf', 2 found
@erosb
Copy link
Contributor

erosb commented May 9, 2018

Sad. If it helps, rewriting the schema this way should work (didn't test it):

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "definitions": {
        "operation": {
            "allOf": [
                {
                    "allOf": [
                        {
                            "$ref": "#/definitions/path"
                        }
                    ]
                },
                {
                    "oneOf": [
                        {
                            "properties": {
                                "op": {
                                    "description": "The operation to perform.",
                                    "enum": [
                                        "add",
                                        "replace",
                                        "test"
                                    ],
                                    "type": "string"
                                },
                                "value": {
                                    "description": "The value to add, replace or test."
                                }
                            },
                            "required": [
                                "value"
                            ]
                        },
                        {
                            "properties": {
                                "op": {
                                    "description": "The operation to perform.",
                                    "enum": [
                                        "remove"
                                    ],
                                    "type": "string"
                                }
                            }
                        },
                        {
                            "properties": {
                                "from": {
                                    "description": "A JSON Pointer path pointing to the location to move/copy from.",
                                    "type": "string"
                                },
                                "op": {
                                    "description": "The operation to perform.",
                                    "enum": [
                                        "move",
                                        "copy"
                                    ],
                                    "type": "string"
                                }
                            },
                            "required": [
                                "from"
                            ]
                        }
                    ]
                }
            ],
            "required": [
                "op",
                "path"
            ],
            "type": "object"
        },
        "path": {
            "properties": {
                "path": {
                    "description": "A JSON Pointer path.",
                    "type": "string"
                }
            }
        }
    },
    "items": {
        "$ref": "#/definitions/operation"
    },
    "title": "JSON schema for JSONPatch files",
    "type": "array"
}

Fixing the real issue (properly loading multiple combined schemas at the same nesting level) might not come any soon.

@erosb
Copy link
Contributor

erosb commented Jun 7, 2018

The fix is available in the latest release: 1.9.0

@erosb erosb closed this as completed Jun 7, 2018
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

2 participants