Gable data contracts use a flexible type system to define the schema portion of a data contract. The below types cover the majority of uses cases in data contracts.

Primitives

  • null: A null value.
  • bool: A boolean value.
  • int32: A 32-bit signed integer.
  • uint32: A 32-bit unsigned integer.
  • int64: A 64-bit signed integer.
  • uint64: A 64-bit unsigned integer.
  • float32: A 32-bit IEEE 754 encoded floating point number.
  • float64: A 64-bit IEEE 754 encoded floating point number.
  • string: A UTF-8 encoded string with variable length, and a length of 65,536 bytes.
  • bytes32: A variable-length byte array with a maximum length of 2_147_483_648.
  • bytes64: A variable-length byte array with a maximum length of 9_223_372_036_854_775_807.
  • uuid: A fixed-length 36 byte string in UUID 8-4-4-4-12 string format as defined in RFC 4122.
  • time32: Time since midnight without timezones and leap seconds in a 32-bit signed integer.
  • time64: Time since midnight without timezones and leap seconds in a 64-bit signed integer.
  • timestamp64: Time elapsed (in a time unit) since a specific epoch.
  • date32: Date since the UNIX epoch without timezones and leap seconds in a 32-bit integer.
  • date64: Date since the UNIX epoch without timezones and leap seconds in a 64-bit integer.

Complex Types

list A list of values all sharing the same type. Example
# A list of signed 32-bit integers
type: list
values:
  type: int32
map A map of key/value pairs where each key is the same type and each value is the same type. Example
# A map from strings to signed 32-bit integers
type: map
keys:
  type: string
values:
  type: in32
struct A collection of types, used to represent complex, often nested objects. Example
# A nested struct representing a person's contact information
type: struct
fields:
  - name: first_name
    type: string
  - name: last_name
    type: string
  - name: phone
    type: string
  - name: address
    type: struct
    fields:
      - name: street_name
        type: string
      - name: street_number
        type: string
      - name: postal_code
        type: string
      - name: city_state
        type: string
enum A string enum. Example
# An enum of cardinal directions
type: enum
symbols: ['NORTH', 'SOUTH', 'EAST', 'WEST']
union & nullable A value that can be one of several types. Nullable properties are represented as the union of their base type, and the null type. Example
# A nullable 32-bit integer.
type: union
types:
  - type: 'null'
  - type: int32
Unions can be written in short-hand format when composed of common types. Example
# A nullable 32-bit integer.
type: union
types: ['null', int32]