nickcmaynard / jsonschemalint

JSON Schema Lint. Like you I'm busy, so pull requests will get merged quicker than feature requests are implemented.
https://jsonschemalint.com
MIT License
80 stars 31 forks source link

Referenced schema does not match #4

Closed simon-p-r closed 8 years ago

simon-p-r commented 9 years ago

Hi

I keep getting this error when using the validator. I am successfully validating that it is valid json and it passes validation with another validation library so am confused why it is failing?

Here is schema for reference

{
    "type": "object",
    "required": [
        "recType"
    ],
    "properties": {
        "recType": {
            "type": "string"
        },
        "startDate": {
            "type": [
                "object",
                "string"
            ],
            "format": "date"
        },
        "endDate": {
            "type": [
                "object",
                "string"
            ],
            "format": "date"
        },
        "noteList": {
            "type": "array",
            "items": {
                "properties": {
                    "dt": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "text": {
                        "type": "string"
                    },
                    "subject": {
                        "type": "string"
                    },
                    "user": {
                        "type": "object",
                        "format": "dbRef",
                        "properties": {
                            "cn": {
                                "type": "string"
                            },
                            "q": {
                                "type": [
                                    "string",
                                    "object"
                                ]
                            }
                        },
                        "required": [
                            "cn",
                            "q"
                        ],
                        "additionalProperties": false
                    },
                    "noteType": {
                        "type": "object",
                        "format": "luRef",
                        "properties": {
                            "lt": {
                                "type": "string"
                            },
                            "lv": {
                                "type": [
                                    "string",
                                    "array"
                                ]
                            }
                        },
                        "required": [
                            "lt",
                            "lv"
                        ]
                    }
                },
                "required": [
                    "dt",
                    "text",
                    "user",
                    "noteType"
                ]
            }
        },
        "oneOf": [
            {
                "type": "object",
                "required": [
                    "employee",
                    "employer"
                ],
                "properties": {
                    "employee": {
                        "type": "object",
                        "properties": {
                            "password": {
                                "type": "string"
                            }
                        }
                    },
                    "employer": {
                        "type": "object",
                        "properties": {
                            "post": {
                                "type": "string"
                            },
                            "salary": {
                                "type": "number"
                            },
                            "startDate": {
                                "type": "string"
                            },
                            "grade": {
                                "type": "string"
                            },
                            "cv": {
                                "type": "string"
                            },
                            "username": {
                                "type": "string"
                            },
                            "workRole": {
                                "type": "string"
                            },
                            "email": {
                                "type": "object",
                                "properties": {
                                    "addr": {
                                        "type": "string",
                                        "format": "email"
                                    }
                                },
                                "additionalProperties": false
                            }
                        }
                    }
                }
            }
        ],
        "control": {
            "type": "object",
            "properties": {
                "createdAt": {
                    "type": "string",
                    "format": "date-time"
                },
                "id": {
                    "type": "string"
                },
                "schemaVersion": {
                    "type": "integer"
                },
                "updatedAt": {
                    "type": "string",
                    "format": "date-time"
                },
                "createdBy": {
                    "type": "object",
                    "format": "dbRef",
                    "properties": {
                        "cn": {
                            "type": "string"
                        },
                        "q": {
                            "type": [
                                "string",
                                "object"
                            ]
                        }
                    },
                    "required": [
                        "cn",
                        "q"
                    ],
                    "additionalProperties": false
                },
                "updatedBy": {
                    "type": "object",
                    "format": "dbRef",
                    "properties": {
                        "cn": {
                            "type": "string"
                        },
                        "q": {
                            "type": [
                                "string",
                                "object"
                            ]
                        }
                    },
                    "required": [
                        "cn",
                        "q"
                    ],
                    "additionalProperties": false
                }
            },
            "additionalProperties": false
        }
    },
    "additionalProperties": false
}
nickcmaynard commented 8 years ago

oneOf isn't valid directly inside the properties part of an object specification.

https://stackoverflow.com/questions/25014650/json-schema-example-for-oneof-objects