Skip to main content

Types

OMG has a rich type system that compiles to OpenAPI 3.1 schemas.

Primitive types

TypeDescriptionOpenAPI Mapping
stringTexttype: string
integerWhole numbertype: integer
numberFloat/doubletype: number
decimalPrecise decimaltype: number, format: decimal
booleanTrue/falsetype: boolean
dateDate onlytype: string, format: date
datetimeDate and timetype: string, format: date-time
uuidUUID stringtype: string, format: uuid
anyAny type{}

Objects

Define object schemas with typed fields:

{
id: uuid,
name: string,
email: string,
age: integer? // Optional field
}

Nested objects

{
user: {
id: uuid,
profile: {
name: string,
bio: string?
}
}
}

Arrays

Use [] suffix for arrays:

{
tags: string[], // Array of strings
items: { // Array of objects
id: uuid,
name: string
}[]
}

Enums

Define fixed value sets using union syntax:

{
status: "draft" | "sent" | "paid",
priority: "low" | "medium" | "high"
}

Union types

Combine types with |:

{
value: string | integer,
result: Success | Error
}

Optional fields

Mark fields as optional with ?:

{
name: string, // Required
nickname: string?, // Optional
bio: string? // Optional
}

Nullable fields

Allow null values with | null:

{
deletedAt: datetime | null // Required, can be null
}

Type references

Reference other defined types:

type Address {
street: string,
city: string,
country: string
}
{
id: uuid,
name: string,
address: Address // Reference to Address type
}

Comments

Add descriptions with // comments:

{
id: uuid, // Unique identifier
status: string, // Current status
amount: decimal // Total amount in cents
}