Generates a protobuf enum containing all ISO 4217 currency codes, with grpc-gateway OpenAPI annotations.
Note
This is merely a prototype to showcase how protobuf code can be generated from authoritative sources (ISO standards in this case) to ensure the generated APIs contain all the valid values.
python process.py > currency.protoThe script reads data.csv and prints a CurrencyCode enum to stdout. Each entry includes the currency name, ISO numeric code, and associated entities as comments.
enum CurrencyCode {
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_enum) = {
title: "Currency Code ISO 4217"
description: "CurrencyCode is an enum representing the ISO 4217 currency codes. Some codes might not be used in practice, but they are included for completeness."
};
CURRENCY_CODE_UNSPECIFIED = 0;
//AFN: Afghani (ISO Numeric Code: 971)
// Associated Entities: AFGHANISTAN
AFN = 971;
//EUR: Euro (ISO Numeric Code: 978)
// Associated Entities: FALKLAND ISLANDS, ANDORRA, ...
EUR = 978;
// ...
}A Nix flake with a dev-shell is provided:
nix developdata.csv is a semicolon-delimited ISO 4217 listing with columns: ENTITY, Currency, alphabetic_code, num_code, minor_unit.
MIT