Skip to content

Commit e0f0ca2

Browse files
committed
single geography template and generator
inline the reference to https://geojson.org/schema/FeatureCollection.json in the template since we use it directly
1 parent fa29a02 commit e0f0ca2

2 files changed

Lines changed: 118 additions & 0 deletions

File tree

schema/geography.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
Schema generators for Geography endpoints.
3+
"""
4+
5+
import json
6+
7+
import common
8+
9+
10+
def geography_schema():
11+
"""
12+
Create the schema for the Geography endpoint.
13+
"""
14+
# load schema template and insert definitions
15+
schema = common.load_json("./templates/geography/geography.json")
16+
definitions = common.load_definitions(
17+
"string",
18+
"timestamp",
19+
"uuid",
20+
"version"
21+
)
22+
definitions.update(common.load_definitions(
23+
"timestamp",
24+
"uuid_array",
25+
allow_null=True
26+
))
27+
schema["definitions"].update(definitions)
28+
29+
# verify and return
30+
return common.check_schema(schema)
31+
32+
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/geography/geography.json",
3+
"$schema": "http://json-schema.org/draft-06/schema#",
4+
"title": "The MDS Geography Schema",
5+
"type": "object",
6+
"definitions": {
7+
"geography": {
8+
"$id": "#/definitions/geography",
9+
"type": "object",
10+
"title": "The geography object schema",
11+
"additionalProperties": false,
12+
"required": [
13+
"name",
14+
"geography_id",
15+
"geography_json",
16+
"published_date"
17+
],
18+
"properties": {
19+
"name": {
20+
"$id": "#/definitions/geography/properties/name",
21+
"$ref": "#/definitions/string",
22+
"description": "Name of geography"
23+
},
24+
"description": {
25+
"$id": "#/definitions/geography/properties/description",
26+
"$ref": "#/definitions/string",
27+
"description": "Description of geography"
28+
},
29+
"geography_type": {
30+
"$id": "#/definitions/geography/properties/geography_type",
31+
"type": "string",
32+
"description": "The type of geography"
33+
},
34+
"geography_id": {
35+
"$id": "#/definitions/geography/properties/geography_id",
36+
"$ref": "#/definitions/uuid",
37+
"description": "Unique ID of geography"
38+
},
39+
"geography_json": {
40+
"$id": "#/definitions/geography/properties/geography_json",
41+
"$ref": "https://geojson.org/schema/FeatureCollection.json",
42+
"description": "The GeoJSON FeatureCollection that defines the geographical coordinates"
43+
},
44+
"effective_date":{
45+
"$id": "#/definitions/geography/properties/effective_date",
46+
"$ref": "#/definitions/null_timestamp",
47+
"description": "The date at which a Geography is considered 'live'. Must be at or after published_date."
48+
},
49+
"published_date": {
50+
"$id": "#/definitions/geography/properties/published_date",
51+
"$ref": "#/definitions/timestamp",
52+
"description": "Timestamp at which the geography was published i.e. made immutable"
53+
},
54+
"retire_date": {
55+
"$id": "#/definitions/geography/properties/end_date",
56+
"$ref": "#/definitions/null_timestamp",
57+
"description": "Time that the geography is slated to retire. Once the retire date is passed, new policies can no longer reference it and old policies referencing it should be updated. Retired geographies should continue to be returned in the geographies list. Must be after effective_date."
58+
},
59+
"prev_geographies": {
60+
"$id": "#/definitions/geography/properties/prev_geographies",
61+
"$ref": "#/definitions/null_uuid_array",
62+
"description": "Unique IDs of prior geographies replaced by this one",
63+
"uniqueItems": true
64+
}
65+
}
66+
}
67+
},
68+
"required": [
69+
"geography",
70+
"version"
71+
],
72+
"properties": {
73+
"geography": {
74+
"$id": "#/properties/geography",
75+
"$ref": "#/definitions/geography",
76+
"description": "The geography in this payload",
77+
"additionalProperties": false
78+
},
79+
"version": {
80+
"$id": "#/properties/version",
81+
"$ref": "#/definitions/version",
82+
"description": "The version of MDS that the geography represents"
83+
}
84+
},
85+
"additionalProperties": false
86+
}

0 commit comments

Comments
 (0)