{
    "title": "Multi code model generator",
    "description": "The scheme describes the data models and methods structure for the generation of a uniform code using various programming languages",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "additionalProperties": false,
    "definitions": {
        "simpleTypes": {
            "enum": [
                "boolean",
                "integer",
                "integer64",
                "float",
                "string",
                "any"
            ]
        },
        "stringOrArr": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
            ]
        },
        "attrType": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "^.+$": {
                        "$ref": "#/definitions/stringOrArr"
                    }
                },
                "required": [
                    "id"
                ]
            }
        },
        "typeBoth": {
            "anyOf": [
                {
                    "$ref": "#/definitions/simpleTypes"
                },
                {
                    "type": "string"
                }
            ]
        }
    },
    "properties": {
        "$schema": {
            "type": "string"
        },
        "imports": {
            "type": "array",
            "description": "The physical path to the other module types for use. Example: ../data/time.json",
            "items": {
                "type": "object",
                "properties": {
                    "file": {
                        "type": "string"
                    },
                    "type": {
                        "type": "string"
                    }
                },
                "required": [
                    "file",
                    "type"
                ]
            },
            "minItems": 1,
            "_uniqueItems": true,
            "messages": {
                "_uniqueItems": "Error unique imports"
            }
        },
        "consts": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "description": {
                        "type": "string"
                    },
                    "items": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "name": {
                                    "type": "string"
                                },
                                "description": {
                                    "type": "string"
                                },
                                "type": {
                                    "$ref": "#/definitions/simpleTypes"
                                },
                                "value": {}
                            }
                        },
                        "required": [
                            "name",
                            "type",
                            "value"
                        ],
                        "minItems": 1
                    }
                }
            },
            "required": [
                "name",
                "items"
            ]
        },
        "enums": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "description": {
                        "type": "string"
                    },
                    "items": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "name": {
                                    "type": "string"
                                },
                                "description": {
                                    "type": "string"
                                },
                                "value": {
                                    "type": "integer"
                                }
                            }
                        },
                        "required": [
                            "name"
                        ],
                        "minItems": 1
                    }
                }
            },
            "required": [
                "name",
                "items"
            ]
        },
        "models": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "attrs": {
                        "$ref": "#/definitions/attrType"
                    },
                    "name": {
                        "type": "string"
                    },
                    "basetype": {
                        "type": "string"
                    },
                    "description": {
                        "type": "string"
                    },
                    "items": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "attrs": {
                                    "$ref": "#/definitions/attrType"
                                },
                                "name": {
                                    "type": "string"
                                },
                                "description": {
                                    "type": "string"
                                },
                                "type": {
                                    "$ref": "#/definitions/typeBoth"
                                },
                                "array": {
                                    "type": "boolean"
                                },
                                "required": {
                                    "type": "boolean",
                                    "default": true
                                }
                            }
                        },
                        "required": [
                            "name",
                            "type"
                        ],
                        "minItems": 1
                    }
                }
            },
            "required": [
                "name",
                "items"
            ]
        },
        "contracts": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "basetype": {
                        "type": "string"
                    },
                    "description": {
                        "type": "string"
                    },
                    "methods": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "name": {
                                    "type": "string"
                                },
                                "description": {
                                    "type": "string"
                                },
                                "args": {
                                    "type": "array",
                                    "items": {
                                        "type": "object",
                                        "properties": {
                                            "name": {
                                                "type": "string"
                                            },
                                            "description": {
                                                "type": "string"
                                            },
                                            "type": {
                                                "$ref": "#/definitions/typeBoth"
                                            },
                                            "array": {
                                                "type": "boolean"
                                            },
                                            "arrayparams": {
                                                "type": "boolean",
                                                "description": "Rest Parameters. ts: func(...data[])"
                                            }
                                        }
                                    },
                                    "required": [
                                        "name",
                                        "type"
                                    ],
                                    "minItems": 1
                                },
                                "result": {
                                    "type": "object",
                                    "properties": {
                                        "type": {
                                            "$ref": "#/definitions/typeBoth"
                                        },
                                        "array": {
                                            "type": "boolean"
                                        },
                                        "description": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "type"
                                    ]
                                }
                            },
                            "required": [
                                "name"
                            ],
                            "minItems": 1
                        }
                    }
                },
                "required": [
                    "name"
                ]
            }
        }
    }
}