Skip to content

Commit 34b8176

Browse files
committed
Generate ISO currency schemas using jq templates
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 70abf40 commit 34b8176

37 files changed

Lines changed: 4618 additions & 3015 deletions

Makefile

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
JSONSCHEMA ?= jsonschema
22
SHELLCHECK ?= shellcheck
3+
JQ ?= jq
34
PYTHON ?= python3
45
CURL ?= curl
56
TAR ?= tar
@@ -42,10 +43,32 @@ test:
4243

4344
build/iso/currency/list-%.json: scripts/xml2json.py vendor/data/iso/currency/list-%.xml
4445
$(PYTHON) $< $(word 2,$^) $@
45-
generate-iso-currency: generate/iso/currency/main.py \
46-
build/iso/currency/list-one.json \
47-
build/iso/currency/list-three.json
48-
$(PYTHON) $<
46+
schemas/iso/currency/2015/%.json: build/iso/currency/list-one.json templates/iso/currency/2015/%.jq
47+
$(MKDIRP) $(dir $@)
48+
$(JQ) --from-file $(word 2,$^) $< > $@
49+
schemas/iso/currency/2015/historical/%.json: build/iso/currency/list-three.json templates/iso/currency/2015/historical/%.jq
50+
$(MKDIRP) $(dir $@)
51+
$(JQ) --from-file $(word 2,$^) $< > $@
52+
53+
generate-iso-currency: \
54+
schemas/iso/currency/2015/alpha-code.json \
55+
schemas/iso/currency/2015/alpha-currency.json \
56+
schemas/iso/currency/2015/alpha-fund.json \
57+
schemas/iso/currency/2015/alpha-precious-metal.json \
58+
schemas/iso/currency/2015/alpha-test.json \
59+
schemas/iso/currency/2015/alpha-unknown.json \
60+
schemas/iso/currency/2015/numeric-code-additional.json \
61+
schemas/iso/currency/2015/numeric-code.json \
62+
schemas/iso/currency/2015/numeric-currency.json \
63+
schemas/iso/currency/2015/numeric-fund.json \
64+
schemas/iso/currency/2015/numeric-precious-metal.json \
65+
schemas/iso/currency/2015/numeric-test.json \
66+
schemas/iso/currency/2015/numeric-unknown.json \
67+
schemas/iso/currency/2015/historical/alpha-code.json \
68+
schemas/iso/currency/2015/historical/alpha-currency.json \
69+
schemas/iso/currency/2015/historical/numeric-code.json \
70+
schemas/iso/currency/2015/historical/numeric-currency.json
71+
4972
generate-iso-language: generate/iso/language/main.py
5073
$(PYTHON) $<
5174
generate-iso-country: generate/iso/country/main.py

generate/iso/currency/main.py

Lines changed: 0 additions & 380 deletions
This file was deleted.

schemas/iso/currency/2015/alpha-code.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
33
"title": "ISO 4217:2015 Alphabetic Currency, Fund, and Precious Metal Code",
44
"description": "A three-letter alphabetic code including currencies, funds, and precious metals (2025-05-12)",
5-
"examples": [ "AED", "AFN", "ALL", "AMD", "BOV", "CHE", "XAG" ],
5+
"examples": [
6+
"AED",
7+
"AFN",
8+
"ALL",
9+
"AMD",
10+
"BOV",
11+
"CHE",
12+
"XAG"
13+
],
614
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
7-
"x-links": [ "https://www.iso.org/iso-4217-currency-codes.html" ],
15+
"x-links": [
16+
"https://www.iso.org/iso-4217-currency-codes.html"
17+
],
818
"anyOf": [
919
{
1020
"$ref": "alpha-currency.json"

0 commit comments

Comments
 (0)