Skip to content

Commit 1e75794

Browse files
committed
generator dict and wrapper function
following the same layout as other spec generators
1 parent 9a6eeec commit 1e75794

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

schema/geography.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,31 @@ def geographies_schema():
4141

4242
return common.check_schema(schema)
4343

44+
45+
def schema_generators():
46+
"""
47+
The dict of schema generators for Geography.
48+
49+
The key is the name of the schema file/template file.
50+
The value is the generator function, taking a dict of common definitions as an argument.
51+
The generator function should return the complete, validated schema document as a dict.
52+
"""
53+
return {
54+
"geography": geography_schema,
55+
"geographies": geographies_schema
56+
}
57+
58+
59+
def write_schema_files():
60+
"""
61+
Create each of the Geography endpoint schema files in the appropriate directory.
62+
"""
63+
print("\nStarting to generate Geography JSON Schemas...\n")
64+
65+
for name, generator in schema_generators().items():
66+
schema = generator()
67+
with open(f"../geography/{name}.json", "w") as schemafile:
68+
schemafile.write(json.dumps(schema, indent=2))
69+
print(f"Wrote {name}.json")
70+
71+
print("\nFinished generating Geography JSON Schemas")

0 commit comments

Comments
 (0)