ThorAPI extension reference
ThorAPI vendor extensions add generation behavior that standard OpenAPI does not describe. Use only the extensions in the live rules endpoint or the downloadable ruleset; unknown x-thorapi-* fields can produce incorrect or nonportable output.
Canonical rules
- Live rules:
GET https://api-0.valkyrlabs.com/v1/abi/rules - Versioned live rules:
GET https://api-0.valkyrlabs.com/v1/abi/rules/{version} - Downloadable ruleset
- OpenAPI spec agent guide
Use the live endpoint when a running environment is available. The downloadable copy supports offline validation and review.
Supported extensions
| Extension | Scope | Value | Purpose |
|---|---|---|---|
x-thorapi-nonCrud | operation | boolean | Marks a command or custom operation as non-CRUD. |
x-thorapi-disable-stats | schema | boolean | Disables generated statistics behavior for the schema. |
x-thorapi-handler-class | operation | string | Selects a delegated handler class. |
x-thorapi-handler-bean | operation | string | Selects a delegated Spring bean. |
x-thorapi-handler-method | operation | string | Selects the delegated method. |
x-thorapi-secureField | property | boolean | Marks a property for generated secure-field handling. |
x-thorapi-dataField | property | object or string | Adds field metadata such as uniqueness, grouping, indexing, and visibility. Object form is preferred. |
x-thorapi-suppress-audit | schema | boolean | Suppresses ThorAPI-managed audit fields for an intentionally nonstandard schema. Use sparingly. |
x-thorapi-hidden | property | boolean | Marks a property hidden or read-only in generated behavior. |
x-thorapi-generateService | schema | boolean | Forces service generation. |
x-thorapi-generateRepository | schema | boolean | Forces repository generation. |
x-thorapi-relationship-contract | property | shared or owned | Declares the persistence lifecycle of a relationship. |
Declare relationship lifecycle
Use shared when the referenced record can be reused or must survive deletion of the current record. Typical examples include customers, organizations, principals, accounts, tags, and catalog objects.
Use owned only for aggregate children whose lifecycle belongs to the parent, such as order lines or local child settings.
components:
schemas:
SalesOrder:
type: object
properties:
customer:
$ref: '#/components/schemas/Customer'
x-thorapi-relationship-contract: shared
orderItems:
type: array
x-thorapi-relationship-contract: owned
items:
$ref: '#/components/schemas/SalesOrderItem'
The generated persistence behavior keeps shared targets independent and applies aggregate lifecycle behavior only to owned children. Do not use an owned contract as a shortcut for access control; generated RBAC and ACL checks remain authoritative.
Author compatible schemas
- Use named component schemas and
$reffor complex objects and array items. - Avoid free-form or complex
additionalPropertieson persisted schemas. Use a named schema, primitive map, or scalar JSON representation. - Do not declare ThorAPI-managed fields such as IDs, ownership, audit dates, trash state, or secure-field key metadata.
- Give shared enum components a scalar
type. - Mark sensitive values with
x-thorapi-secureField: true. - Use stable
operationIdvalues and named request and response schemas for commands. - Keep untrusted specifications self-contained. Do not use remote, local-file, or absolute-path
$reftargets. - Use only the documented value type for each extension.
Secure field example
components:
schemas:
IntegrationAccount:
type: object
properties:
displayName:
type: string
apiKey:
type: string
x-thorapi-secureField: true
Do not include real credentials in specifications, fixtures, or documentation.
Validate and generate
Run the repository's canonical generation path from a ValkyrAI checkout:
./vaix generate
./vaix test
When validation fails, change the source OpenAPI document or the canonical generator template. Do not hand-edit generated Java, TypeScript, enhanced OpenAPI output, or build artifacts.