Skip to main content

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​

Use the live endpoint when a running environment is available. The downloadable copy supports offline validation and review.

Supported extensions​

ExtensionScopeValuePurpose
x-thorapi-nonCrudoperationbooleanMarks a command or custom operation as non-CRUD.
x-thorapi-disable-statsschemabooleanDisables generated statistics behavior for the schema.
x-thorapi-handler-classoperationstringSelects a delegated handler class.
x-thorapi-handler-beanoperationstringSelects a delegated Spring bean.
x-thorapi-handler-methodoperationstringSelects the delegated method.
x-thorapi-secureFieldpropertybooleanMarks a property for generated secure-field handling.
x-thorapi-dataFieldpropertyobject or stringAdds field metadata such as uniqueness, grouping, indexing, and visibility. Object form is preferred.
x-thorapi-suppress-auditschemabooleanSuppresses ThorAPI-managed audit fields for an intentionally nonstandard schema. Use sparingly.
x-thorapi-hiddenpropertybooleanMarks a property hidden or read-only in generated behavior.
x-thorapi-generateServiceschemabooleanForces service generation.
x-thorapi-generateRepositoryschemabooleanForces repository generation.
x-thorapi-relationship-contractpropertyshared or ownedDeclares 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​

  1. Use named component schemas and $ref for complex objects and array items.
  2. Avoid free-form or complex additionalProperties on persisted schemas. Use a named schema, primitive map, or scalar JSON representation.
  3. Do not declare ThorAPI-managed fields such as IDs, ownership, audit dates, trash state, or secure-field key metadata.
  4. Give shared enum components a scalar type.
  5. Mark sensitive values with x-thorapi-secureField: true.
  6. Use stable operationId values and named request and response schemas for commands.
  7. Keep untrusted specifications self-contained. Do not use remote, local-file, or absolute-path $ref targets.
  8. 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.