{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "allOf": [
        {
            "$ref": "#/definitions/base"
        },
        {
            "$ref": "#/definitions/with-id"
        },
        {
            "oneOf": [
                {
                    "not": {
                        "$ref": "#/definitions/car-type"
                    }
                },
                {
                    "allOf": [
                        {
                            "$ref": "#/definitions/car-type"
                        },
                        {
                            "$ref": "#/definitions/car-properties"
                        }
                    ]
                }
            ]
        }
    ],
    "definitions": {
        "base": {
            "type": "object",
            "required": [
                "type",
                "properties"
            ],
            "properties": {
                "type": {
                    "type": "string"
                },
                "properties": {
                    "type": "object"
                }
            }
        },
        "with-id": {
            "properties": {
                "properties": {
                    "required": [
                        "id"
                    ],
                    "properties": {
                        "id": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "car-type": {
            "properties": {
                "type": {
                    "enum": [
                        "car"
                    ]
                }
            }
        },
        "car-properties": {
            "properties": {
                "properties": {
                    "properties": {
                        "manufacturer": {
                            "type": "string"
                        },
                        "model": {
                            "type": "string"
                        },
                        "fuelType": {
                            "type": "string",
                            "enum": [
                                "diesel",
                                "gasoline",
                                "biodiesel",
                                "kerosene",
                                "electric"
                            ]
                        },
                        "constructionYear": {
                            "type": "integer",
                            "minimum": 0
                        },
                        "VIN": {
                            "type": "string"
                        }
                    }
                }
            }
        }
    }
}