Skip to content

slashformotion/proto_currency_ISO4217

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

proto_currency_ISO4217

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.

Usage

python process.py > currency.proto

The 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.

Example output

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;

  // ...
}

Development

A Nix flake with a dev-shell is provided:

nix develop

Data source

data.csv is a semicolon-delimited ISO 4217 listing with columns: ENTITY, Currency, alphabetic_code, num_code, minor_unit.

License

MIT

About

proto enum for currency ISO4217

Topics

Resources

Stars

Watchers

Forks

Contributors