Skip to content

The OSOS platform ships a large, typed HTTP surface, and hand-writing request and response models against it is a losing proposition — the domain types are deep and there are hundreds of operations. The supported path is to generate a client from each service’s OpenAPI specification. This page is about doing that correctly: where the specs come from, why a client generated from a current spec is right where an older one is subtly wrong, and the handful of responses a generated client will never model on its own.

It assumes you have read Calling the HTTP API, which owns the routing, versioning and envelope mechanics. This page does not restate them; it explains what they mean for a code generator.

Each LoopBack service produces its own OpenAPI 3 document from its controllers. There is no merged, cross-service document — you generate one client per service and compose them in your own code. The two ways to obtain a spec are covered in The OpenAPI specification: the runtime endpoint ({basePath}/openapi.json, served when ENABLE_SPEC is 'true') and the offline export entry point (which boots the application and writes the document to a file).

Prefer a committed snapshot over hitting a live endpoint. Generating from a file you control means your build does not depend on a running cluster, and — the point of this page — it makes the spec’s provenance something you can inspect and pin. A spec pulled live from whatever cluster happens to answer is a spec whose age you cannot see.

Every JSON response is enveloped as {success, result}, with no version condition — apart from /v3 reads, raw again Since 1.10 (see below). A code generator cannot infer that from an operation’s schema, so the platform documents the envelope in the spec itself, through a spec enhancer. A client generated from a spec that carries the enhancer’s output is generated against the real contract.

The enhancer augments each generated document in three machine-readable ways:

  • A document-root extension key x-osos-response-envelope, so tooling can discover the contract without parsing prose. It names the envelope schema and the result / error property names.
  • Two named component schemas, OsosResponseEnvelope and OsosResponseEnvelopeError. The names are deliberately namespaced rather than reusing the bare model name ResponseBody, because three distinct classes with that name exist in the codebase and a controller contributing its own would otherwise collide.
  • A ## Response envelope section appended to the document’s info.description, stating the invariant in prose for a human reading Swagger UI.

Why operations still type the payload, not the envelope

Section titled “Why operations still type the payload, not the envelope”

Here is the nuance that decides whether your generated client is correct. The enhancer does not rewrite each operation to wrap its response schema in the envelope. An operation’s documented 2xx schema still describes the result payload — not the whole body. The published OsosResponseEnvelope schema is deliberately never referenced by any operation; it exists to be described, not pointed at.

That design is intentional, and it is what keeps generation clean: referencing the envelope from every operation would change the generated result type of every method. Because the platform’s own codegen configs ignore unused models, leaving the envelope schema unreferenced means the enhancer produces zero change in generated client output — the generated method signatures type the payload directly.

The consequence for you: a client generated from a current spec is correctly typed at the payload level, but its transport layer must still unwrap result for successful responses (and read error on failures). result is null when an operation returns no payload. Whether you write that unwrapping by hand or configure your generator to do it, the contract to code against is the single envelope — the same for every version of every operation, with the one Since 1.10 exception of /v3 reads described below.

Telling whether a snapshot predates the enhancer

Section titled “Telling whether a snapshot predates the enhancer”

The envelope became universal in a refactor that also added the enhancer. Before that, the wrapper was version-conditional and the spec said nothing about it at all. A client built from a pre-enhancer snapshot is therefore doubly unsafe: it documents no envelope, and it may have been wired against the old “v3 is raw” behaviour. (Since 1.10 that behaviour is back for /v3 reads only — see The /v3 read exception — so check which shape each operation actually answers with rather than trusting either snapshot.)

You can tell a snapshot’s provenance by inspecting it for the enhancer’s fingerprints. A current spec has all three; a pre-enhancer snapshot has none:

  • the x-osos-response-envelope key at the document root;
  • the OsosResponseEnvelope and OsosResponseEnvelopeError schemas under components.schemas;
  • the ## Response envelope heading inside info.description.

If a snapshot is missing them, do not generate against it — refresh the snapshot from a current backend first. A generated client is only as truthful as the spec it came from, and a stale one describes response shapes that the platform no longer produces.

On the 1.10 line a GET on a /v3/ route is sent raw again — the bare payload, no {success, result} (backend 84742a950, OP#27361); /v3 writes and every v1/v2 route keep the envelope (Calling the HTTP API). The enhancer’s ## Response envelope prose lists “GET on /v3” among the unwrapped cases, and for those operations the documented 2xx schema is the whole body. So a generated client must not unwrap result unconditionally: either special-case GET on /v3, or — the robust option, and what the portal does — unwrap only when the body carries success: true. The robust form also covers 1.8 deployments, which still envelope /v3 reads up to 1.8.21.

Why the OpenAPI document is exempt from the envelope

Section titled “Why the OpenAPI document is exempt from the envelope”

The universal envelope has exactly one non-structural exception: the OpenAPI document itself is served raw, never wrapped (matched on a trailing /openapi.json or /openapi.yaml path segment). This matters directly to client generation, because your generator reads that document.

The reason is mechanical. Wrapping the spec in {success, result} would produce a document whose top-level paths object is buried one level down under result — which is no longer a valid OpenAPI document. Swagger UI would render nothing, and every generator configured to read the spec URL (the platform’s own clients use ng-openapi-gen) would fail to find any operations. The exception is matched on a trailing path segment, so an ordinary API route that merely contains openapi.json somewhere in the middle is still enveloped like any other response.

Practically: point your generator at the spec URL and it receives a normal OpenAPI document. Point a normal API call at a data endpoint and it receives the envelope. The two never blur.

A narrower source: the per-view document Since 1.10

Section titled “A narrower source: the per-view document Since 1.10”

If your integration works against one stable view rather than the whole data plane, there is now a second, much smaller document to generate from. Turning on Swagger document in a view’s display options publishes it for that view:

GET /api/v1/views/{viewId}/openapi.json

It is an ordinary OpenAPI 3.0 document — ng-openapi-gen, openapi-generator or any other OpenAPI-3-aware generator consumes it exactly like a per-service one. What makes it a better input for a scoped integration is what it leaves out. It describes exactly five operations — read the entity schema, list entries, read one entry, create an entry, patch an entry — with the view id and the entity id already baked into each path rather than left as template placeholders. The result is a client whose surface is the integration’s actual surface, and whose paths do not need a template-substitution layer you write yourself. It is also more stable: the five operations are lifted from real controllers, so the document changes when those operations change, not every time an unrelated corner of data-service grows a route.

Two further constraints to design around:

  • Serving the document is gated per view. With the toggle off, a non-privileged caller gets 403 — so a build step that fetches the document needs the toggle on for that view, and needs to keep it on.
  • The entity-schema operation always requires a bearer token, even on a view that otherwise allows anonymous reads. A generated client that assumes one credential policy across all five operations will fail on that one.

The full endpoint contract — status codes, the /v1/v/{viewId} gateway prefix the documented paths carry, and what the entry value schema is built from — is in The per-view OpenAPI document.

Some responses are never {success, result} at all, and a generated client — which assumes JSON bodies — will not model them. These bypass the envelope structurally: the handler writes to the response itself, so the send pipeline returns early (result === response || response.headersSent) rather than wrapping anything.

  • File and binary downloads and streams. Data exports (XLSX, PDF), theme CSS, translation files and fonts return binary or streamed content. Handle them as downloads; do not attempt to parse them as JSON. These are the same responses flagged under long-running operations.
  • The health, readiness and liveness routes (/health, /ready, /live).

For these, drop out of your generated client and read the raw HTTP response. A client that assumes every response is enveloped JSON will fail precisely on the operations — like an export download — that an integration reaches for first.

Generation only covers the LoopBack services that publish a specification. Three edge services are plain Express and emit no OpenAPI document at all: users-service, storage-service and scheduler-service. (shortener-service is no longer part of the backend — the short-link route is served by a separate shared function.) Between them they own authentication and file storage — the two surfaces an external client needs first — so a generated client cannot cover them, and they must be integrated by hand from their own guides. Keep a clear line in your codebase between the generated clients and these hand-written integrations, so a regeneration never silently overwrites hand-maintained code.

Four further services are LoopBack but have no offline spec export: packaging-service, logging-service, dependency-service and integrations-service. No committed snapshot contains their routes, so neither does the Endpoint reference — notably the packaging and store routes and the WhatsApp log and webhook routes. Their inventories are in Calling the HTTP API. Remember too that every service other than data-service sits under its own base path (/api/reaction, /api/packaging, …), and the paths in its specification are relative to it — configure each generated client’s base URL accordingly (details).

Before you trust a generated client:

  • One client per LoopBack service, generated from that service’s own spec — or, for a view-scoped integration, one client from that view’s own per-view document Since 1.10.
  • Generate from a committed snapshot, not a live endpoint, so provenance is inspectable.
  • Confirm the snapshot carries the three enhancer fingerprints before generating; refresh it if not.
  • Unwrap result (and read error) at the transport layer — the generated types describe the payload, not the envelope.
  • Route downloads, streams and the health endpoints around the generated client; read their raw responses.
  • Give each generated client its service’s own base path — /api only for data-service.
  • Integrate the three Express services, and the routes of the four LoopBack services with no export, by hand and keep them out of the regeneration path.

Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27