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

Validace výsledného dokumentu #9

Open
zoul opened this issue Mar 12, 2020 · 1 comment
Open

Validace výsledného dokumentu #9

zoul opened this issue Mar 12, 2020 · 1 comment
Labels
tech Věci týkající se technické infrastuktury

Comments

@zoul
Copy link
Member

zoul commented Mar 12, 2020

Kdybysme k tomu napsali něco jako JSON schéma, tak bysme to jednak zdokumentovali, jednak bychom si mohli automaticky ověřit nějaké předpoklady a garance (například neprázdná pole a podobně).

@zoul zoul added the tech Věci týkající se technické infrastuktury label Mar 22, 2020
@michto01
Copy link
Contributor

Můžeme tady prosím určit, které údaje jsou povinné? Při parsování je tam sem tam v adresách "zmatek" a tak nástřelem schéma které by prošlo se současným datasetem:

{
    "$schema": "http://json-schema.org/draft-06/schema#",
    "$ref": "#/definitions/Envelope",
    "definitions": {
        "Envelope": {
            "type": "object",
            "title": "Envelope",
            "properties": {
                "timestamp": {
                    "description": "Date and time of the dataset generation.",
                    "type": "string",
                    "format": "date-time"
                },
                "itemCount": {
                    "description": "Number of the records in the dataset.",
                    "type": "integer"
                },
                "municipalities": {
                    "description": "Array of the individual municipalities",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/Municipality"
                    }
                }
            },
            "required": [
                "itemCount",
                "municipalities",
                "timestamp"
            ],
            "additionalProperties": false
        },
        "Municipality": {
            "description": "Single municipal unit in the dataset.",
            "type": "object",
            "title": "Municipality",
            "additionalProperties": false,
            "properties": {
                "hezkyNazev": {
                    "description": "Name of the Municipality, designated for the displaying, with some processing applied to it.",
                    "type": "string"
                },
                "eDeskyID": {
                    "description": "ID of the Electronical Official Board",
                    "anyOf": [
                        {
                            "type": "string",
                            "format": "integer"
                        },
                        {
                            "type": "null"
                        }
                    ]
                },
                "souradnice": {
                    "description": "Geolocation of the Municipality.",
                    "anyOf": [
                        {
                            "type": "array",
                            "minItems": 2,
                            "maxItems": 2,
                            "items": {
                                "type": "number"
                            }
                        },
                        {
                            "type": "null"
                        }
                    ]
                },
                "zkratka": {
                    "type": "string"
                },
                "ICO": {
                    "description": "Czech Business ID of the Municipality.",
                    "anyOf": [
                        {
                            "type": "null"
                        },
                        {
                            "type": "string",
                            "pattern": "^[0-9]{8}$"
                        }
                    ]
                },
                "nazev": {
                    "description": "Full, official name of the Municipality.",
                    "type": "string"
                },
                "datovaSchrankaID": {
                    "description": "ID of the electronic data-box used to communicate within the government.",
                    "type": "string",
                    "pattern": "^[a-z0-9]{7}$"
                },
                "pravniForma": {
                    "description": "Legal form of the Municipality",
                    "$ref": "#/definitions/LegalForm"
                },
                "mail": {
                    "description": "Email addressed that could be used to inquire the information about the Municipality.",
                    "type": "array",
                    "items": {
                        "type": "string",
                        "format": "email"
                    }
                },
                "adresaUradu": {
                    "description": "Address of the municipality",
                    "$ref": "#/definitions/Address"
                },
                "erb": {
                    "description": "Link to the Coat of Arms of the Municipality.",
                    "anyOf": [
                        {
                            "type": "null"
                        },
                        {
                            "type": "string",
                            "format": "uri",
                            "qt-uri-protocols": [
                                "https"
                            ],
                            "qt-uri-extensions": [
                                ".svg",
                                ".png",
                                ".jpg",
                                ".jpeg",
                                ".webp"
                            ]
                        }
                    ]
                }
            },
            "required": [
                "ICO",
                "adresaUradu",
                "datovaSchrankaID",
                "eDeskyID",
                "hezkyNazev",
                "mail",
                "nazev",
                "pravniForma",
                "souradnice",
                "zkratka"
            ]
        },
        "Address": {
            "type": "object",
            "title": "Address",
            "additionalProperties": false,
            "properties": {
                "ulice": {
                    "anyOf": [
                        {
                            "type": "null"
                        },
                        {
                            "type": "string"
                        }
                    ]
                },
                "cisloDomovni": {
                    "anyOf": [
                        {
                            "type": "null"
                        },
                        {
                            "type": "string"
                        }
                    ]
                },
                "cisloOrientacni": {
                    "anyOf": [
                        {
                            "type": "null"
                        },
                        {
                            "type": "string"
                        }
                    ]
                },
                "obec": {
                   "type": "string"
                },
                "obecKod": {
                    "anyOf": [
                        {
                            "type": "null"
                        },
                        {
                            "type":"string",
                            "pattern": "^[0-9]{6}$"
                        }
                    ]
                },
                "PSC": {
                    "anyOf": [
                        {
                            "type": "null"
                        },
                        {
                            "type":"string",
                            "pattern": "^[0-9]{5}$"
                        }
                    ]
                },
                "castObce": {
                    "anyOf": [
                        {
                            "type": "null"
                        },
                        {
                            "type": "string"
                        }
                    ]
                },
                "kraj": {
                    "anyOf": [
                        {
                            "type": "null"
                        },
                        {
                            "type": "string",
                            "enum": [
                                "Královéhradecký",
                                "Moravskoslezský",
                                "Pardubický",
                                "Olomoucký",
                                "Jihomoravský",
                                "Vysočina",
                                "Zlínský",
                                "Liberecký",
                                "Ústecký",
                                "Karlovarský",
                                "Plzeňský",
                                "Jihočeský",
                                "Středočeský",
                                "Hlavní město Praha"
                            ]
                        }
                    ]
                },
                "adresniBod": {
                    "anyOf": [
                        {
                            "type": "null"
                        },
                        {
                            "type": "string",
                            "pattern": "^[0-9]*$"

                        }
                    ]
                }
            },
            "required": [
                "ulice",
                "cisloDomovni",
                "cisloOrientacni",
                "obec",
                "obecKod",
                "PSC",
                "castObce",
                "kraj",
                "adresniBod"
            ]
        },
        "LegalForm": {
            "type": "object",
            "title": "LegalForm",
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "integer",
                    "enum": [801, 811]
                },
                "label": {
                    "$ref": "#/definitions/LegalFormLabel"
                }
            },
            "required": [
                "label",
                "type"
            ]
        },
        "LegalFormLabel": {
            "type": "string",
            "title": "LegalFormLabel",
            "enum": [
                "Obec",
                "Městská část hlavního města Prahy"
            ]
        }
    }
}

Rád bych třeba v adresách třeba považoval za povinné PSČ a adresní bod. Ale zatím by to neprošlo a nevím jestli je to vůbec možné ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech Věci týkající se technické infrastuktury
Projects
None yet
Development

No branches or pull requests

2 participants