{
    "openapi": "3.1.0",
    "info": {
        "title": "EmissionZone API",
        "description": "Open API for EmissionZones",
        "version": "latest"
    },
    "servers": [
        {
            "url": "https://data.ndw.nu/api/rest/static-road-data",
            "description": "Server url"
        }
    ],
    "paths": {
        "/emission-zones/v1/map": {
            "get": {
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "*/*": {
                                "schema": {
                                    "$ref": "#/components/schemas/FeatureCollection"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "CategoryExemption": {
                "type": "object",
                "properties": {
                    "vehicleType": {
                        "type": "string",
                        "enum": [
                            "CAR",
                            "VAN",
                            "TRUCK",
                            "BUS"
                        ]
                    },
                    "classification": {
                        "type": "string",
                        "enum": [
                            "EURO1",
                            "EURO2",
                            "EURO3",
                            "EURO4",
                            "EURO5",
                            "EURO6"
                        ]
                    }
                },
                "required": [
                    "classification",
                    "vehicleType"
                ]
            },
            "County": {
                "type": "object",
                "properties": {
                    "code": {
                        "type": "string",
                        "minLength": 1
                    },
                    "gmCode": {
                        "type": "string",
                        "minLength": 1
                    },
                    "name": {
                        "type": "string",
                        "minLength": 1
                    },
                    "localName": {
                        "type": "string",
                        "minLength": 1
                    }
                },
                "required": [
                    "code",
                    "gmCode",
                    "localName",
                    "name"
                ]
            },
            "EmissionZone": {
                "type": "object",
                "additionalProperties": true,
                "properties": {
                    "identification": {
                        "type": "string"
                    },
                    "zoneType": {
                        "type": "string",
                        "enum": [
                            "ENVIRONMENTAL_ZONE",
                            "ZERO_EMISSION_ZONE"
                        ]
                    },
                    "validFrom": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "validTo": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "regulationId": {
                        "type": "string"
                    },
                    "trafficOrderStatus": {
                        "type": "string",
                        "enum": [
                            "DEFINITIVE",
                            "PLANNED",
                            "REVOKED",
                            "SUBSTITUTED"
                        ]
                    },
                    "urlForInformation": {
                        "type": "string"
                    },
                    "taxiMaxRegistrationYear": {
                        "type": "integer",
                        "format": "int32"
                    },
                    "exemptions": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/CategoryExemption"
                        }
                    },
                    "environmentalZoneId": {
                        "type": "string"
                    },
                    "county": {
                        "$ref": "#/components/schemas/County"
                    }
                },
                "required": [
                    "area",
                    "identification",
                    "regulationId",
                    "trafficOrderStatus",
                    "validFrom",
                    "zoneType"
                ]
            },
            "Feature": {
                "type": "object",
                "properties": {
                    "type": {
                        "type":"string",
                        "enum":[ "Feature" ]
                    },
                    "properties": {
                      "$ref": "#/components/schemas/EmissionZone"
                    },
                    "geometry": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/MultiPolygon"
                            },
                            {
                                "$ref": "#/components/schemas/Polygon"
                            }
                        ]
                    },
                    "id": {
                        "type": "string"
                    }
                }
            },
            "FeatureCollection": {
                "type": "object",
                "properties": {
                    "type": {
                        "type": "string",
                        "enum":[ "FeatureCollection" ]
                    },
                    "features": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Feature"
                        }
                    }
                },
                "example": {
                    "type": "FeatureCollection",
                    "features": [
                        {
                            "type": "Feature",
                            "properties": {
                                "taxiMaxRegistrationYear": 2020,
                                "trafficOrderStatus": "DEFINITIVE",
                                "identification": "ZEZ",
                                "exemptions": [
                                {
                                    "vehicleType": "BUS",
                                    "classification": "EURO4"
                                }
                                ],
                                "regulationId": "stb-2024-456",
                                "county": {
                                    "code": "307",
                                    "gmCode": "GM0307",
                                    "name": "Amersfoort",
                                    "localName": "Amersfoort"
                                },
                                "zoneType": "ENVIRONMENTAL_ZONE",
                                "urlForInformation": "",
                                "validFrom": "2024-12-31T23:00:00Z",
                                "environmentalZoneId": "5e3c798b-8b18-4685-90ad-3c478e7e4a06",
                                "validTo": null
                            },
                            "geometry": {
                                "type": "Polygon",
                                "coordinates": [
                                [
                                    [5.38412747525686, 52.1489360256196],
                                    [5.3816122257939, 52.1447318312445],
                                    [5.38508477169469, 52.1438448683041],
                                    [5.39045313995294, 52.1450658776429],
                                    [5.38412747525686, 52.1489360256196]
                                ]
                                ]
                            },
                            "id": "5e3c798b-8b18-4685-90ad-3c478e7e4a06"
                        }
                    ]
                }
            },
            "MultiPolygon": {
                "type": "object",
                "properties": {
                    "type": {
                        "type": "string",
                        "enum": [
                            "MultiPolygon"
                        ]
                    },
                    "coordinates": {
                        "type": "array",
                        "items": {
                            "type": "array",
                            "items": {
                                "type": "array",
                                "items": {
                                    "type": "array",
                                    "items": {
                                        "type": "number"
                                    },
                                    "minItems": 2,
                                    "maxItems": 2
                                },
                                "minItems": 3
                            }
                        }
                    }
                }
            },
            "Polygon": {
                "type": "object",
                "properties": {
                    "type": {
                        "type": "string",
                        "enum": [
                            "Polygon"
                        ]
                    },
                    "coordinates": {
                        "type": "array",
                        "items": {
                            "type": "array",
                            "items": {
                                "type": "array",
                                "items": {
                                    "type": "number"
                                },
                                "minItems": 2,
                                "maxItems": 2
                            },
                            "minItems": 3
                        }
                    }
                }
            }
        }
    }
}