OpenAPI 3.1 & AsyncAPI 3.0
LatticeDX generates both machine-readable interface specifications dynamically at runtime via openapi-spec.js and observability.js: an OpenAPI 3.1.0 specification covering the HTTP REST and MCP endpoints, and an AsyncAPI 3.0.0 specification covering MQTT telemetry, UI surface SSE streams, Redis Pub/Sub channels, and NGSI-LD outbox webhooks.
Discovery Endpoints
Both discovery endpoints set ctx.withoutDataWrapping = true, return raw JSON with Cache-Control: no-store, and allow public read access so API gateways, documentation portals, and code generators can poll them directly.
/api/dxos:openapi/api/dxos:asyncapiServer URL Resolution
resolveRequestServerUrl and normalizeServerUrl compute servers[0].url in priority order:
- Reads protocol from
x-forwarded-proto(httporhttps, using the first proxy value). - Reads hostname/port from
x-forwarded-hostorhost, validating against^[a-zA-Z0-9.:[\]-]{1,253}$. - Rejects URLs containing embedded credentials (
username/password) and falls back tohttp://localhost:13014when no valid host header is present.
OpenAPI 3.1.0 Specification Structure
The OpenAPI document targets openapi: "3.1.0" with Apache-2.0 license metadata and declares two global security schemes under components.securitySchemes:
| Parameter | Type | Default | Description |
|---|---|---|---|
bearerAuth | http (bearer) | JWT / ldx_pat_* | Accepts an OIDC/NocoBase Bearer JWT or a scoped PaaS Personal Access Token (Bearer ldx_pat_*). |
latticeApiKey | apiKey (header) | X-Lattice-API-Key | Accepts a scoped PaaS API key passed via the X-Lattice-API-Key header. |
Unauthenticated endpoints such as /api/dxos:health, /api/dxos:openapi, /api/dxos:asyncapi, /api/dxosWms:publicTrack, /api/dxosBroker:deviceStatusIngest, /api/dxosBroker:orionNotify, and /api/dxosForms:{meta,submit,status} declare security: []. All protected routes require either bearerAuth or latticeApiKey and standardize 400, 401, and 403 error responses.
Operation Tags and operationId Naming
Each entry in API_OPERATIONS receives a deterministic operationId via makeOperationId(pathStr, method) (such as get_dxosLedgerEntries or post_dxosWmsIssueStock) grouped under semantic tags:
| Domain Group | OpenAPI Tag Names |
|---|---|
| Platform & Security | Observability, PaaS API Keys, PKI & Crypto Ledger, Data Governance, Connector & Secrets Vault, Event Bus & Webhooks |
| Operations & Automation | Vouchers, Notifications, SLA Engine, PARA Knowledge Vault, WMS & Cold Logistics, DMN Decision Engine, Native Automation Engine, Unified Approvals, Omnichannel Notifications, Public Forms |
| Studio, Integration & AI | Blocks & IoT Telemetry, IoT Broker Control Plane, DX-OS Studio, Visual Domain Builder, Stock n8n Integration, AI Workforce & MCP, Dynamic Custom Domains |
Dynamic latticeCustom* Collection Introspection
collectCustomCollections(db) scans every runtime collection matching /^latticeCustom[A-Za-z0-9_]+$/ and maps fields into JSON Schema definitions:
| NocoBase Field Type | Generated JSON Schema Type | Format / Constraints |
|---|---|---|
integer, bigint | integer | — |
float, double, decimal, number | number | — |
boolean | boolean | — |
json, jsonb | object | additionalProperties: true |
date, datetime, time | string | format: "date-time" |
string and remaining types | string | Populates enum from uiSchema.enum when present |
Each latticeCustom<Name> collection emits a schema under #/components/schemas/<Name> (including id, organizationId, and required fields derived from allowNull === false) plus five operations tagged Dynamic Custom Domains: list (GET), get (GET), create (POST), update (POST), and destroy (POST).
AsyncAPI 3.0.0 Specification Structure
The asyncapi: "3.0.0" document models event-driven communication across edge devices, message brokers, the transactional outbox, and connected portal clients through 3 servers and 5 channels:
| Server ID | Protocol | Default Host | Role |
|---|---|---|---|
mqttBroker | mqtt | <host>:1883 | Eclipse Mosquitto broker for IoT telemetry and actuator downlink commands |
httpGateway | http / https | <origin> | HTTP/SSE gateway and latticeContextOutbox webhook delivery |
redisPubSub | redis | redis:6379 | Valkey DB 1 Pub/Sub bus synchronizing UI surface mutations across workers |
5 Channels and Message Contracts
| Channel ID | Address | Operation (action) | Message Payload Schema |
|---|---|---|---|
iotTelemetry | latticedx/{org}/{entity}/telemetry | receive (ingestIotTelemetry) | TelemetryPoint: organizationId, entityId, metric, value, unit?, observedAt |
iotDownlinkCommand | latticedx/{org}/{entity}/command | send (dispatchIotCommand) | DownlinkCommand: organizationId, entityId, command, args?, signatureBase64?, issuedAt |
surfaceEventsSse | /api/dxosAi:surfaceEvents | send (subscribeSurfaceEvents) | SurfaceUpdate: portalSlug, kind?, organizationId?, revision? |
redisSurfaceUpdates | latticedx:surface-updates | send (publishSurfaceUpdates) | SurfaceUpdate: portalSlug, kind?, organizationId?, revision? |
contextOutboxWebhooks | latticeContextOutbox | send (deliverContextOutboxWebhook) | ContextOutboxWebhook: eventId, entityId, organizationId, collectionName, recordId, payload |
Message Payload Schemas (components.messages)
Each AsyncAPI 3.0.0 message declares contentType: "application/json" with strict required fields so edge gateways and webhook consumers can validate payloads ahead of ingestion:
| Parameter | Type | Default | Description |
|---|---|---|---|
TelemetryPointrequired | object | — | Requires organizationId, entityId, metric, value (number), and observedAt (date-time); optional unit. |
DownlinkCommandrequired | object | — | Requires organizationId, entityId, command, and issuedAt (date-time); optional args and signatureBase64. |
SurfaceUpdaterequired | object | — | Requires portalSlug; optional kind, organizationId, and revision (integer). |
ContextOutboxWebhookrequired | object | — | Requires eventId, entityId, organizationId, collectionName, recordId (integer), and payload. |
The /api/dxosAi:surfaceEvents SSE endpoint supports up to 1000 concurrent listeners and emits keepalive comments every 25 seconds to prevent idle timeouts across Caddy and APISIX proxies.
SDK and Client Generation
Integrators can fetch both documents at deploy time to generate strongly typed TypeScript clients, run contract tests, or bind MQTT and SSE consumers.
# Download OpenAPI 3.1.0 and AsyncAPI 3.0.0 specs
curl -fsS "https://app.example.com/api/dxos:openapi" -o openapi.json
curl -fsS "https://app.example.com/api/dxos:asyncapi" -o asyncapi.json
# Generate TypeScript definitions from OpenAPI 3.1.0
npx openapi-typescript ./openapi.json -o ./src/types/latticedx-api.d.ts