{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/swift/json-schema/swift-currency-schema.json",
  "title": "Currency",
  "x-generated": "2026-11-05",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/swift-swiftref-api-v4-openapi.yml#/components/schemas/Currency",
  "type": "object",
  "required": [
    "name",
    "iso_3a_code"
  ],
  "properties": {
    "name": {
      "$ref": "#/$defs/CurrencyName"
    },
    "iso_3a_code": {
      "$ref": "#/$defs/ThreeLetterCode"
    },
    "iso_3n_code": {
      "$ref": "#/$defs/ThreeDigitCode"
    },
    "fractional_digits": {
      "type": "integer",
      "minimum": 0,
      "maximum": 5,
      "description": "The number of fractional digits to use"
    },
    "countries": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "name",
          "iso_2a_code"
        ],
        "properties": {
          "name": {
            "$ref": "#/$defs/CountryName"
          },
          "iso_2a_code": {
            "$ref": "#/$defs/TwoLetterCode"
          },
          "iso_3a_code": {
            "$ref": "#/$defs/ThreeLetterCode"
          },
          "iso_3n_code": {
            "$ref": "#/$defs/ThreeDigitCode"
          }
        }
      },
      "description": "A list of countries where the currency is used"
    }
  },
  "$defs": {
    "CountryName": {
      "$ref": "#/$defs/StringMax70"
    },
    "CurrencyName": {
      "$ref": "#/$defs/StringMax70"
    },
    "StringMax70": {
      "description": "Generic string definition, from 1 to 70 characters long",
      "type": "string",
      "minLength": 1,
      "maxLength": 70
    },
    "ThreeDigitCode": {
      "description": "Generic 3-digit code",
      "type": "string",
      "pattern": "^[0-9]{3}$"
    },
    "ThreeLetterCode": {
      "description": "Generic 3-letter code",
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "TwoLetterCode": {
      "description": "Generic 2-letter code",
      "type": "string",
      "pattern": "^[A-Z]{2}$"
    }
  }
}