Typed operations and the OpenAPI document
Status: written 2026-10-14, before any code, for the UI direction decided that day (Nuxt UI SPA as
the primary UI for the Java and Go frameworks; [../handover.mdnull, “UI direction”).
Built in Java with MO (2026-10-14); amendments found by the build are marked (MO). Built in Go with G3 (2026-10-15, httpfw/openapi, httpfw/validate): the three vectors of section 10 pass byte for byte; Go’s differences are listed in [../go/milestones.mdnull under “G3 as built” (a pointer field needs omitzero; int, unsigned and float32 are refused; the declaration is Declared.Operations and the command a fw declaration-phase command). The document rules (sections 4 to 9) are language-neutral: the Java
emitter (framework-http) and the Go emitter (httpfw, [../go/capabilities.mdnull
section 5, decision 18) produce the same document for the same API, checked by a shared conformance
vector (section 10). The declaration API (sections 2 and 3) is described in its Java shape; Go’s
shape is in the Go capabilities page and follows the same rules.
This contract amends http contract section 11, which listed OpenAPI generation as out of scope, and core contract section 5 (a declaration-phase command, section 9 below).
1. Shape
Section titled “1. Shape”operations declared in code (descriptors: method, pattern, id, parameters, body, response, errors, security) -> bound to handlers when the module boots; the router serves them like any route -> the emitter writes an OpenAPI 3.1 document from the descriptors and the Java records they name (the `openapi` command, registration phase only: no configuration, no database, no network) -> the application commits it (web/openapi.json); a test fails the Maven build when it is stale -> @hey-api/openapi-ts generates the TypeScript types, one SDK function per operation and Zod schemas -> the SPA calls the SDK; Nuxt UI's UForm validates with the Zod schema of the request body -> the server decodes and validates again (http contract section 7) and stays the authorityDeclared in code (ruled 2026-10-13). Operations are values the application writes; the document is a by-product and is never edited by hand. There is no spec-first generation and no runtime validation of responses against the document.
Typed operations are an addition, not a replacement: plain Routes.get(...) routes keep working
and are not in the document (receivers, health, metrics, the SPA’s files, login redirects, Datastar
streams, application routes that are not JSON).
2. Operations (Java)
Section titled “2. Operations (Java)”// Values, written once (names are a sketch; final at build).static final PathParam<String> ID = PathParam.string("id");static final QueryParam<@Nullable String> CLIENT = QueryParam.string("clientId").optional;
static final Operation<NoBody, IngestionList> LIST = Operation.get("/api/v1/ingestions", IngestionList.class) .id("listIngestions").summary("List ingestions").tag("ingestions") .query(CLIENT).requiresContext.permission(MANAGE) .build;
static final Operation<IngestionBody, IngestionView> CREATE = Operation.post("/api/v1/ingestions", IngestionBody.V, IngestionView.class) // body type from the Validator .id("createIngestion").summary("Create an ingestion").tag("ingestions") .status(201).requiresContext.permission(MANAGE) .error(409, "CODE_TAKEN", "the client already has an ingestion with that code") .build;| Part | Rule |
|---|---|
| method and pattern | as http contract section 2 (GET PUT POST PATCH DELETE; {name} segments). HEAD and OPTIONS are not operations (the router answers them) |
id |
required; [a-z][A-Za-z0-9]* (it becomes the TypeScript function name); unique in the application |
summary, description, tags |
optional text; tags [a-z][a-z0-9-]* |
| path parameters | every {name} in the pattern is declared with a type (PathParam.string, .integer, .longInt, .enumOf(Class)); a declared name missing from the pattern, or a pattern name not declared, is a start-up problem |
| query parameters | declared with a type; required unless .optional (then @Nullable) or .defaultValue(v); .list for a repeated parameter (?status=A&status=B) |
| request body | given by a Validator<B> (http contract section 7), so decoding, validation and the schema have one source; GET and DELETE operations have none (NoBody) |
| response | a record class, NoBody (then the status is 204), or a generic record through a type token (new TypeRef<CursorPage<IngestionView>> {}); never a Map, a bare list or a primitive at the top level |
status |
the success status, one per operation: 200 by default, 201, 202 or 204 (204 if and only if the response is NoBody) |
error(status, code, message) |
an expected failure; documents the status (and the code in its description). Repeatable |
requiresContext |
as RouteOptions.requiresContext; documents the security schemes (section 7) and the statuses section 6 implies |
permission(p) |
the permission the Context must hold (core contract section 3 matching); enforced by framework-http with Context.hasPermission (403 FORBIDDEN, the same answer as Auth.require); implies requiresContext; emitted as x-fw-permission |
operatorsOnly() |
the operation is for platform operators only, in addition to its permission (admin contract section 3a): after the 401 and the permission check a Context whose tier is not exactly ANCHOR gets 403 FORBIDDEN “this is for platform operators only”, before the request is read; implies requiresContext; emitted as x-fw-operators-only: true (absent otherwise). Go Builder.OperatorsOnly() |
Amended by the build (MO):
- Factories, as built:
Operation.get(pattern, Class|TypeRef),delete(...)the same,post,put,patch(pattern, Validator, Class|TypeRef), and a body-lesspost(pattern, Class|TypeRef)(logout): a body sent to a body-less operation is not read.id,summary,description,tag(...),path(...),query(...),status,requiresContext,permission,error,build. buildnever throws for a descriptor mistake (a missing or malformed id, a bad tag, a malformed pattern, a path parameter missing from the pattern or a pattern name not declared, a parameter declared twice, a success status other than 200, 201, 202 and 204,204withoutNoBodyorNoBodywith another status, an error status outside 400 to 599, an error code not[A-Z][A-Z0-9_]*, an error declared twice or without a message, a blank permission). They are listed byOperation.problemsand reported as start-up problems when the route table is compiled and as dump problems by theopenapicommand, so a static field never fails class initialisation.- Parameters:
PathParam.string|integer|longInt(name),PathParam.enumOf(name, Class);QueryParam.string|integer|longInt|bool(name),QueryParam.enumOf(name, Class), then at most one of.optional(QueryParam<@Nullable T>),.defaultValue(v)(documented as the schema’sdefault) or.list(QueryParam<List<T>>, empty when absent). Query names match[A-Za-z][A-Za-z0-9_.-]*. A missing required value isREQUIRED: is required, a bad oneINVALID: ..., all parameter errors in one400 VALIDATION. - The response may also be a sealed interface (a union), not only a record.
3. Declaring and binding (Java)
Section titled “3. Declaring and binding (Java)”Operations are declared in register (so the document needs no service, configuration or
database) and bound in boot (where the services exist):
// register(AppBuilder app)OpenApi.declare(app, LIST, CREATE, READ, CHANGE, REMOVE);OpenApi.info(app, "ingest-control-plane", "1"); // once per application: title and version
// boot(App app)routes.bind(CREATE, request -> { String id = ids.generate("ing"); return switch (store.create(id, request.body)) { case TAKEN -> Outcome.failed(409, "CODE_TAKEN", "the client already has an ingestion with that code"); case DONE -> Outcome.ok(store.find(id).orElseThrow); };});Amended by the build (MO): binding is Routes.bind(operation, handler) or bind(operation, handler, RouteOptions) for route middleware (options that require a context on an operation that
does not are a start-up problem: the document would call it public). The HTTP module’s Routes is
given every declared operation (Routes.declare, from OpenApi.operations(lookup)); a table built by
hand in a test (new Routes) that is never given declarations does not check that bound
operations were declared. Order of the checks on a request: the permission (403), then every
parameter (one 400), then the body (415, 400), then the handler, so a caller without the
permission learns nothing about the body rules.
OperationHandler<B, R>isOutcome<R> handle(OperationRequest<B> request) throws Exception.OperationRequest<B>givesbody(decoded and validated),path(PathParam<T>),query(QueryParam<T>),context, andraw(theRequest, for headers).Outcome<R>is a sealed result (house rule):Outcome.Ok<R>(the value, optional extra headers such asLocationorSet-Cookie) orOutcome.Failed<R>(aServiceError, so aUseCaseErrorpasses straight through;Outcome.failed(status, code, message)builds one). ThrowingHttpExceptionstill works and maps as before. As built (MO):Outcome.ok(value)returnsOutcome.Ok, whoseheader(name, value)appends (twoSet-Cookies are fine);Outcome.noContentfor aNoBodyresponse;Outcome.failed(error)andfailed(status, code, message[, details])(status 400 to 599).- Start-up problems, collected as usual: a declared operation that is not bound; a bound operation that was not declared; an operation bound twice; two operations with one id; the route rules of http contract section 2 (a bound operation is a route).
- A
Failedoutcome whose status is neither declared nor implied (section 6) is answered as given and logged once per operation and status at WARN (“status 409 is not in the document for createIngestion”); as built (MO): once per process. - Responses of typed operations omit absent values: a
@Nullablerecord component that isnullis left out of the JSON (JacksonNON_NULLon the typed-operation writer only; plain routes andResponse.jsonkeep writingnull, unchanged). This matches the Go emitter (omitzero), the session JSON (sessions contract section 6.1) and the document (section 5). As built (MO): the typed-operation mapper isJson.operationMapper:Json.mapper’s strictness,NON_NULLfor record components,BigDecimalwritten as a string (read from a string or a number),Durationas ISO-8601, and the context id types (ClientId,PrincipalId,ApplicationCode,CorrelationId) as plain strings (Jackson would otherwise write{"value": ...}, which the document does not describe).
4. The document
Section titled “4. The document”OpenAPI 3.1.0, JSON. Top level, in this order: openapi ("3.1.0"), info (title,
version from OpenApi.info; a missing info is a dump problem), paths, components
(schemas, responses, securitySchemes, in that order), tags (only when an operation has a tag: {"name": ...} sorted by
name). No servers (the SPA calls its own origin), no jsonSchemaDialect, no webhooks.
An operation object, in this order: operationId, summary, description, tags, parameters,
requestBody, responses, security, x-fw-permission, x-fw-operators-only; absent parts are left out.
parameters: path parameters in pattern order, then query parameters in declaration order; each{"name", "in", "required", "schema"}(path parameters alwaysrequired: true); a list query parameter has"style": "form", "explode": trueand an array schema.requestBody:{"required": true, "content": {"application/json": {"schema": {"$ref": ...}}}}.responses: the success status with{"description": "OK"|"Created"|"Accepted"|"No Content", "content": {"application/json": {"schema": ...}}}(nocontentfor204), then each error status ascending (section 6), thendefault.
Example (one operation, abridged):
"/api/v1/ingestions/{id}": { "get": { "operationId": "getIngestion", "summary": "Read an ingestion", "tags": ["ingestions"], "parameters": [ {"name": "id", "in": "path", "required": true, "schema": {"type": "string"}} ], "responses": { "200": {"description": "OK", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/IngestionView"}}}}, "400": {"$ref": "#/components/responses/Error"}, "401": {"$ref": "#/components/responses/Error"}, "403": {"$ref": "#/components/responses/Error"}, "404": {"$ref": "#/components/responses/Error"}, "default": {"$ref": "#/components/responses/Error"} }, "security": [{"session": []}, {"bearer": []}], "x-fw-permission": "ingestor:admin:ingestion:manage" }}4.1 Deterministic output
Section titled “4.1 Deterministic output”The same declarations produce the same bytes, on every machine and in both implementations:
- UTF-8,
\nline ends, a final newline; two-space indentation;"key": valuewith one space after the colon (the output of JavaScript’sJSON.stringify(document, null, 2)plus\n); non-ASCII characters written as they are;<,>,&and/not escaped. - Fixed key order for every OpenAPI object (as listed in this section);
pathssorted by the path string (UTF-8 byte order); in a path item, methods in the orderget, put, post, delete, patch;components.schemassorted by name; schema keywords in the order of section 5.4;propertiesin declaration order (record component order in Java, field order in Go);requiredin the same order asproperties;enumvalues in declaration order;discriminator.mappingsorted by key;securitywithsession, thenbearer, then other schemes sorted by name. - Nothing from the build or the clock (no timestamps, no git hashes, no host names).
5. Schemas from types
Section titled “5. Schemas from types”The emitter walks the types reachable from the declared operations once, at the JSON edge. Reading record components and the generic types of their accessors is reflection, allowed there for the same reason Jackson uses it; it is not wiring and never scans the classpath.
5.1 Type table
Section titled “5.1 Type table”| Java | JSON Schema | TypeScript (hey-api) | Go (for comparison) |
|---|---|---|---|
String |
{"type": "string"} |
string |
string |
boolean / Boolean |
{"type": "boolean"} |
boolean |
bool |
int / Integer |
{"type": "integer", "format": "int32"} |
number |
int32 |
long / Long |
{"type": "integer", "format": "int64"} |
number (exact only below 2^53: ids are strings) |
int64 |
double / Double |
{"type": "number", "format": "double"} |
number |
float64 |
BigDecimal |
{"type": "string", "format": "decimal"}; the typed-operation writer writes it as a JSON string and reads a string or a number |
string |
a decimal type with a SchemaProvider |
Instant |
{"type": "string", "format": "date-time"} (ISO-8601 UTC, as Jackson writes it with WRITE_DATES_AS_TIMESTAMPS off) |
string |
fw.Instant |
LocalDate |
{"type": "string", "format": "date"} |
string |
civil.Date-like value type |
Duration |
{"type": "string", "format": "duration"} (ISO-8601 PT5M: Jackson 3.2’s default, WRITE_DURATIONS_AS_TIMESTAMPS off) |
string |
a duration value type |
UUID |
{"type": "string", "format": "uuid"} |
string |
uuid.UUID |
an enum |
{"type": "string", "enum": [names in declaration order]} |
a literal union (enums: "javascript" gives an as const object) |
a string type with EnumValues |
| a record | {"$ref": "#/components/schemas/<Name>"} (5.2) |
an object type | a struct |
| a sealed interface | {"$ref": ...} to a oneOf component (5.3) |
a union | an interface with registered variants |
List<T>, Collection<T> |
{"type": "array", "items": T} |
Array<T> |
[]T |
Set<T> |
{"type": "array", "items": T, "uniqueItems": true} |
Array<T> |
[]T with a uniqueness rule |
Map<String, V> |
{"type": "object", "additionalProperties": V} |
Record<string, V> (with noPropertyAccessFromIndexSignature) |
map[string]V |
JsonNode |
{} |
unknown |
jsontext.Value |
a framework value type (ids, ClientId) |
its built-in schema (a string, with a pattern where the type has one) |
string |
its SchemaProvider |
| an application value type | a schema registered in code: OpenApi.schema(app, Money.class, Schema.string.pattern("^-?[0-9]+\\.[0-9]{2}$")) |
per the schema | SchemaProvider |
Amended by the build (MO): the framework value types are ClientId ({"type": "string", "pattern": "^[A-Za-z0-9._-]{1,100}$"}), ApplicationCode ("pattern": "^[a-z][a-z0-9-]*$"),
PrincipalId and CorrelationId ("pattern": "\\S", "minLength": 1, the non-blank rule). A
registered schema that is a union (Schema.oneOf(...)) or an object is a component under the type’s
name; any other registered schema is written inline wherever the type appears. Jackson annotations
on a registered type are not checked (the registration is the application’s word for what Jackson
writes; a Money record with @JsonValue is the example). float, short, byte and char are not
in the table and are refused.
Refused (the dump fails, naming the type and the path from the operation to it, for example
createIngestion.body.source.Sftp.every): Optional (house rule: never a field), Object, raw or
wildcard generic types, a Map whose key is not String, arrays of primitives other than
byte[] (and byte[], which Jackson writes as base64, is {"type": "string", "contentEncoding": "base64"}), classes that are not records, enums or registered value types, and any type with a
Jackson annotation the emitter does not understand (5.5).
5.2 Records
Section titled “5.2 Records”- One component per record type. Name: the simple name; a nested record is prefixed by its
enclosing types (
IngestionView.RouteisIngestionViewRoute). Amended (MO): only enclosing records, interfaces and enums count; an enclosing class that is none of those (a holder of API types such asOrdersApi) adds nothing, soOrdersApi.OrderViewisOrderView, the name a Go package-level type would have. The nameErroris the framework’s envelope; a type named so is a name collision. A recursive record (Node(List<Node> children)) is one component; a generic record is followed by its type arguments’ names (CursorPage<IngestionView>isCursorPageIngestionView). Two types that produce one name is a dump problem (rename one, or register a name in code:OpenApi.name(app, Type.class, "OtherName")). {"type": "object", "properties": {...}, "required": [...], "additionalProperties": false}: property names are the component names (Jackson’s default for records); a component is required unless it is@Nullable(JSpecify, runtime-retained); primitives are always required.@Nullablemeans “may be absent”, never “may benull”: the property is not required and its schema is not nullable (TypeScriptx?: T; withexactOptionalPropertyTypesabsent andundefinedare distinct). Typed operations omit it when null (section 3); on input Jackson still accepts an explicitnullfor it, which the document does not advertise. A three-state value (absent, null, a value) is not supported in this version; Go does not emitNullable[T]either.additionalProperties: falseon every record schema, request and response alike: the framework’s decoder refuses unknown properties (http contract section 7), so a request schema without it would be wrong, and the SPA and its document ship together, so a closed response type costs nothing. (The platform’s huma output had the same closed request schemas, and its SPA sent supersets that were refused; the generated, fully typed client of section 11 is what prevents that here.)@JsonIgnore-free public methods named like getters (getX,isX) on a record are a dump problem: Jackson would serialise them as properties the walk does not see.- Added (MO):
OpenApi.property(app, Record.class, "component", schema)replaces one property’s schema (whether it is required still follows@Nullable), for a property with a fixed value (Schema.bool.constant(true)), used by the session components (sessions contract 4.5). An override naming no component is a dump problem.@JsonIgnoreon a record component is a dump problem (Jackson would drop the property).
5.3 Sealed interfaces
Section titled “5.3 Sealed interfaces”A sealed interface reachable from an operation must carry @JsonTypeInfo(use = NAME, include = PROPERTY, property = "<name>") and @JsonSubTypes naming exactly its permitted subtypes (the
form the first application’s Source, Split and DispatchTarget already use); anything else is
a dump problem, because Jackson’s wire form and the document would disagree.
"Source": { "oneOf": [{"$ref": "#/components/schemas/SourceDatabasePoll"}, {"$ref": "#/components/schemas/SourceHttp"}], "discriminator": {"propertyName": "kind", "mapping": {"database-poll": "#/components/schemas/SourceDatabasePoll", "http": "#/components/schemas/SourceHttp"}}}oneOfin the order ofdiscriminator.mapping’s sorted keys; each variant is a record component named<Interface><Variant>whose first property is the discriminator,{"type": "string", "const": "<name>"}, required.- The interface’s own
@JsonIgnoredefault methods (for exampleSource.singleOwner) are not properties and are ignored. - Amended by the build (MO): every
@JsonSubTypes.Typeneeds an explicitname(Jackson’s default for a nested class is not portable);namesaliases,defaultImplandvisible = trueare dump problems; every permitted subtype must be a record; a variant component with the discriminator’s name is a dump problem. A variant record used on its own (as a response) is still the variant component<Interface><Variant>with the discriminator first, because Jackson inherits the type id from the interface. A sealed interface with a registeredSchema.oneOf(...)needs no Jackson annotations and is documented without adiscriminator(the session answer).
5.4 Constraints from the Validator
Section titled “5.4 Constraints from the Validator”The request body’s Validator (http contract section 7) is the only source of constraints; they are
merged into the body type’s component and its nested types (nested(...)). Rule gains a way to
describe itself (Java: a default method returning a constraint, empty for custom); the standard
rules map as follows:
| Rule | Schema |
|---|---|
notNull |
none (required-ness comes from the type: a @Nullable component the validator requires is documented as optional; the server refuses it with 400) |
notBlank |
"minLength": 1, "pattern": "\\S" |
minLength(n), maxLength(n) |
minLength, maxLength |
pattern(regex) |
"pattern": "^(?:regex)$" (Java’s matches is whole-string; JSON Schema patterns are not anchored). A regex using constructs ECMA-262 lacks (inline flags (?i), possessive quantifiers, \A, \Z, \z, \h, \p{Java...}) is a dump problem: use custom instead, which documents nothing |
range(min, max) |
minimum, maximum |
size(min, max) |
minItems, maxItems |
oneOf(values) |
enum |
each(rule) |
the rule’s constraint on items |
custom(...) |
none |
Amended by the build (MO): when rules overlap, the tighter bound wins (minLength, minimum,
minItems take the largest, the maxima the smallest); an explicit pattern replaces notBlank’s
\S (its minLength: 1 stays; a pattern that accepts only whitespace is then under-documented); two
explicit patterns, or oneOf with a value outside an enum’s constants, are dump problems; oneOf on an
enum narrows its enum; a rule that does not fit the value (oneOf on a list) is a dump problem.
The ECMA refusal list, as built: inline flags (?i), atomic groups (?>, possessive quantifiers,
\A \Z \z \G \h \H \v \V \R \X \Q \E \e \a \N, every \p{...}/\P{...} (ECMA reads them only with the
u flag, which a browser validator may not set), \x{...}, a nested class or && in a class, a
class starting with ], and a pattern compiled with flags. Validator fields that are not record
components are dump problems. Constraints are compared as documented: custom and notNull rules do
not make two validators differ.
One component per type: two operations whose validators give the same type different constraints is a dump problem (give each its own body type, or share the validator). A type used both as a request body and in a response carries the body’s constraints in both places (data the server produces is valid data).
Schema keyword order (for section 4.1): $ref, type, const, enum, format,
contentEncoding, pattern, minLength, maxLength, minimum, maximum, items, minItems,
maxItems, uniqueItems, properties, required, additionalProperties, oneOf,
discriminator, description. Amended (MO): default (a query parameter’s default value) comes
before description. A record with no required component has no required keyword.
5.5 Jackson annotations
Section titled “5.5 Jackson annotations”The emitter must describe what Jackson does, so it accepts only: @JsonTypeInfo and
@JsonSubTypes on sealed interfaces (5.3) and @JsonIgnore on non-component methods. Any other
Jackson annotation on a reachable type, record component or accessor (@JsonProperty,
@JsonInclude, @JsonFormat, @JsonUnwrapped, @JsonValue, @JsonCreator, @JsonAlias, …) is
a dump problem naming it; the fix is to remove it or to register a schema for the type in code. A
test in the emitter suite serialises a sample of every row of the 5.1 table with the
typed-operation writer and validates the JSON against the emitted schema, so the table cannot drift
from Jackson.
5.6 Proposed: constraints on the variants of a sealed interface (not built; 2026-10-16)
Section titled “5.6 Proposed: constraints on the variants of a sealed interface (not built; 2026-10-16)”Status: proposed, from the first application’s feedback (Camel feedback 2026-10-16, item b). Nothing here is built; the a decision is pending.
What works today. A sealed interface is a oneOf with a discriminator (5.3) and each variant is
its own record component, so what a kind requires is already in the document: an sftp source
has a required host, an http source does not have one at all, and the generated TypeScript and
Zod narrow on source.kind. A nullable component of a variant is optional, a non-null one is
required.
What does not. The rules that depend on the kind and are not about presence: the pattern a host
must match, the range of a poll interval, the shape of an S3 prefix. Validator.of(Source.class) has
no fields (an interface has no record components), so .nested("source", IngestionBody::source, ...)
cannot carry per-variant rules, and a Rules.custom on the field runs at the server but documents
nothing. The application therefore keeps those rules in code the browser does not see
(IngestionRules.check) and the generated Zod schema accepts a value the server refuses; the server
answers 400 with the field’s path and the page shows it. That is correct but late.
Proposal. A validator for a union is a set of validators, one per permitted subtype:
static final Validator<IngestionBody> BODY = Validator.of(IngestionBody.class) .nested("source", IngestionBody::source, Validator.union(Source.class) .variant(Source.Sftp.class, Validator.of(Source.Sftp.class).field("host", Source.Sftp::host, Rules.pattern(HOST))) .variant(Source.Http.class, Validator.of(Source.Http.class) .field("url", Source.Http::url, Rules.pattern(URL))));- Run time.
validatepicks the variant validator by the value’s class (a subtype with no validator has no rules) and reports paths assource.host, as the application’s own checks do today. A null value passes, as fornested. - Emitter. The constraints of a variant validator merge into the variant’s component
(
SourceSftp), by the existing “one component per type” machinery of 5.4; theoneOfand thediscriminatordo not change, so the generated Zod union members carry the pattern and the form marks the field before the request. Dump problems: avariant(...)class that is not a permitted subtype of the interface; two operations that give one variant different constraints (as 5.4). - Not proposed. Rules across fields or across the union and a sibling (the split against the source
kind, “interval at least the minimum for this kind”): JSON Schema can say them with
if/then, but hey-api’s Zod plugin does not turn those into a schema, so documenting them would only mislead. They stay incustomrules, server side. - Cost. About a day of Java (
Validator.union,Rules.validfor a union, the emitter merge, a dump test for each refusal, anOpenApiDocumentTestcase and a conformance vector for Go); no change to the TypeScript packages. The application’sIngestionRuleswould shrink to the cross-field rules.
6. Errors
Section titled “6. Errors”One shared component, the http contract’s envelope:
"Error": { "type": "object", "properties": { "error": {"type": "string"}, "message": {"type": "string"}, "details": {"type": "object", "additionalProperties": {"type": "string"}} }, "required": ["error", "message"], "additionalProperties": false}and one shared response, components.responses.Error: {"description": "Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}. Every operation lists,
each pointing at it:
| Status | Listed when |
|---|---|
400 |
the operation has a body or any parameter (VALIDATION, INVALID_JSON) |
401 |
requiresContext (UNAUTHENTICATED) |
403 |
requiresContext (FORBIDDEN, CLIENT_NOT_PERMITTED, CROSS_ORIGIN_REQUEST) |
413, 415 |
the operation has a body |
each error(status, ...) |
declared; the codes are listed in the response’s description ("CODE_TAKEN: the client already has an ingestion with that code"), one line per code, sorted |
default |
always (everything else: 429, 500, 503) |
As built (MO): a declared error(status, ...) on a status the shape already implies (for example
403) replaces that status’s $ref with the described response. A response object for a declared
status is {"description": "<CODE>: <message>" lines joined with "\n", "content": {...Error...}}.
error stays a string, not an enum: use-case codes are an open set. hey-api types the SDK’s
error result as Error, so the SPA never handles unknown.
7. Security schemes
Section titled “7. Security schemes”The schemes are contributed by the module that resolves the Context, because only it knows how
callers authenticate:
framework-authcontributes"session": {"type": "apiKey", "in": "cookie", "name": "__Host-fw_session"}(the production name always, whatever the environment) and, when bearer tokens are accepted,"bearer": {"type": "http", "scheme": "bearer", "bearerFormat": "JWT"};- an application’s own resolver contributes its own (Java:
OpenApi.securityScheme(app, "basic", SecurityScheme.httpBasic)), for example the first application’s fixed token and basic login.
As built (MO): SecurityScheme.cookie(name), header(name), bearer(format) and httpBasic;
scheme names match [A-Za-z][A-Za-z0-9_-]*, and one name contributed twice is a dump problem.
components.securitySchemes is left out when nothing was contributed.
Amended 2026-11-03 (field workers, sessions-and-login contract section 15): when field workers are
enabled (Go auth.FieldWorkers(...), Java AuthModule.Builder.fieldWorkers(...)), framework-auth
also contributes
"dpop": { "type": "http", "scheme": "DPoP", "bearerFormat": "fc-field+jwt", "description": "A FlowCatalyst field access token as `Authorization: DPoP <token>`, with a `DPoP` proof header (RFC 9449, ES256). The application answers `401` with a `DPoP-Nonce` header when the proof needs its nonce."}DPoP is the scheme name RFC 9449 registers in the IANA HTTP Authentication Scheme registry, which
OpenAPI 3.1 refers to for http schemes. The member order is the one shown. Without field workers
nothing changes, so the existing vectors in conformance/openapi/ stay as they are. A context
operation’s security then lists session, bearer, dpop: the dpop entry sorts among “other
schemes by name”. Java adds SecurityScheme.dpop (record Dpop) to the public factories; Go
adds openapi.DPoP (kind DPoPToken). Both are usable by an application that resolves field
tokens itself. Each language has a test that pins the exact JSON above in a field-enabled
document.
As built (2026-11-03): Java contributes dpop from AuthModule.register when
Builder.fieldWorkers was set. Go writes the document in the declare phase, before Build sees
auth.FieldWorkers, so the application also passes auth.DeclareFieldWorkers to auth.Declare;
Build fails, naming both, when only one of the two is given. The description text is fixed in
the emitter (the factories take no arguments).
An operation that requiresContext gets security listing every contributed scheme (each as its
own alternative); a public operation gets none. An operation that requires a context when no
scheme was contributed is a dump problem (“say how callers authenticate”).
8. The framework’s own operations
Section titled “8. The framework’s own operations”framework-authdeclaresGET /auth/session(getAuthSession) andPOST /auth/logout(logout) as operations, with the fixed component names and shapes in the sessions contract section 4.5, so@flowcatalyst/api-runtimecalls them through a generated client (the platform’s/auth/*surface, hand-typed and outside its spec, is the counter-example). Both are public in the document (nosecurity): they answer without a session./auth/loginand/auth/callbackare browser navigations, never fetched: not in the document.- Health, metrics, receivers, the SPA’s files and Datastar streams are not operations.
- Built (MO): with summaries
Read the browser sessionandSign out of the applicationand the tagauth;logoutdeclares403 CROSS_ORIGIN_REQUESTand415 UNSUPPORTED_MEDIA_TYPE.
9. Dumping the document
Section titled “9. Dumping the document”- Core amendment (core contract section 5): a module may claim a declaration-phase command
(Java:
app.command(DeclarationCommand), a name andint run(Declarations, List<String> args, PrintStream out)).AppBuilder.launch(args)runs it after step 1 (register) only: no configuration is loaded or validated, no service is built, nothing connects anywhere.Declarationsexposes the registered contributions and declared settings, read-only. AProviderorbootis never called. framework-httpclaimsopenapi:java -jar app.jar openapiwrites the document to standard output;openapi --out web/openapi.jsonwrites the file. Every dump problem is collected and printed, exit code 1. Amended by the build (MO):framework-httphas no module, so it provides the command (OpenApi.command) and the HTTP server module (JettyHttpModule, idhttp) claims it: every application that serves HTTP has it. Any other argument prints the usage, exit code 2. Tools and tests get the declarations without a command through core’sAppBuilder.declarations(register only);OpenApi.document(declarations)returnsWritten(json)orRefused(problems). Go: the same command name and output (<app> openapi), run in Go’s declare phase.- Drift in the Maven build (Java): the framework’s test helper
OpenApiTesting.assertCommitted(appBuilder, Path.of("web/openapi.json"))regenerates the document in a unit test and fails with a diff when the committed file differs, so./mvnw verifycatches a stale document without Node. As built (MO): the same test run with-Dopenapi.update=truewrites the file; a missing file fails with the command to write it. The TypeScript side has its own drift check (section 11). - At start-up (amended 2026-11-07, early-adopter fixes item B2; approved): the HTTP server
builds the document from the declarations when it is built (Java:
JettyHttpModule, before it opens the port; Go:httpfw.NewServer, problems under keyopenapi) and fails start-up with every problem of the operations and their types, so a type the document cannot describe fails the first test that starts the server, not only the dump. The two checks of the whole document (noInfo; an operation that requires a context when no security scheme was contributed) stay with the command and the test helpers, because test servers commonly have neither; an application with no declared operation is not checked. Test helpers that apply every check, with no committed file: JavaOpenApiTesting.assertBuilds(appBuilder), Gofwtest.OpenAPI(t, web).
10. One document for Java and Go
Section titled “10. One document for Java and Go”The two emitters must produce comparable documents, so a SPA written against one backend’s document runs against the other’s when the operations are the same:
- the rules of sections 4 to 8 are shared, including the output formatting;
- conformance vector
conformance/openapi/: a fixture API (a handful of operations covering every row of the 5.1 table, a sealed interface, a generic page, each rule of 5.4, each implied status, both security cases) described in itsREADME.md, andfixture.json, the expected document. The Java tests write it (-Dconformance.update=true); Go’s emitter must reproduce it byte for byte.conformance/openapi/auth.jsonholds the two operations of section 8 and their components, which@flowcatalyst/api-runtimeis generated from; added (MO):conformance/openapi/orders-demo.json, a sample application (the Javaexamples/orders-demodocument, byte-equal to its committedweb/openapi.json); - known modelling differences are absorbed by the rules: Java writes
@Nullableabsent, Go omitsomitzerovalues, and both document “may be absent” (5.2); neither emits nullable types.
Out of scope: a test that a running API (this framework’s, or the FlowCatalyst platform’s Java or Go implementation) agrees with a document it did not emit; validating requests or responses against the document at run time; consuming a foreign document to generate server code.
11. The TypeScript client
Section titled “11. The TypeScript client”Generated from the committed document by @hey-api/openapi-ts (pinned exactly: it is 0.x and
its output changes between minors), as the platform SPA does, but generating the whole client,
not types only:
import { fwOpenApiConfig } from "@flowcatalyst/api-runtime/openapi-ts";export default fwOpenApiConfig({ input: "openapi.json", output: "src/api" });fwOpenApiConfig (ui/packages/api-runtime/src/openapi-ts.ts) holds the settings, so every
application generates the same way. Its plugin list:
plugins: [ { name: "@hey-api/typescript", enums: "javascript" }, // literal unions; no TypeScript enums (erasableSyntaxOnly) { name: "@hey-api/client-fetch", baseUrl: false }, // no generated base URL (below) { name: "@hey-api/sdk", validator: false }, // one typed function per operation { name: "zod", compatibilityVersion: 4, // schemas for UForm (Standard Schema) "~resolvers": { number: int64AsNumber } }, // int64 stays a number (below)],Two settings the build found necessary (MU U2, [../ui/u2.mdnull; hey-api 0.99.0):
-
@hey-api/client-fetchwithbaseUrl: false. The document has noservers(section 4: the SPA calls its own origin). Without the setting, hey-api reads a bare input such asopenapi.jsonas a host and writes it as the client’s base URL (createConfig({ baseUrl: 'openapi.json' })), so every call would go toopenapi.json/api/...relative to the page (an input path with a slash in it does not trigger this).@flowcatalyst/api-runtimealso setsbaseUrl: ""when it configures the client at run time. -
int64through the Zod plugin’s number resolver. Forformat: int64(anduint64) hey-api writesz.coerce.bigintwhile the TypeScript type it writes isnumber(section 5’s type table). The schema’s output, whichUFormhands to the submit handler, is then a BigInt, andJSON.stringifyrefuses it (“Do not know how to serialize a BigInt”). The resolver (~resolvers.number, hey-api’s documented hook;int64AsNumberin the same file) writesz.intwith the declared bounds as plain numbers:z.int.gte(0).lte(100000000)instead ofz.coerce.bigint.gte(BigInt(0)).lte(BigInt(100000000)).z.intaccepts safe integers only, which is section 5’s rule (exact only below 2^53; ids are strings). Every other number keeps hey-api’s default. -
Committed:
web/openapi.jsonandweb/src/api/(generated). The SPA imports only the generated SDK for API calls;@flowcatalyst/api-runtimeconfigures itsclient-fetchinstance (same origin,credentials: "same-origin", theErrorenvelope as the typed error,401to sign-in, validation details onto form fields). An ESLint rule forbids otherfetchwrappers. -
Zod: the plugin’s schemas (zod 4) are passed to Nuxt UI’s
UForm; they carry the section 5.4 constraints, so the browser checks what the server will check. The SDK’s run-time response validation stays off, except in the end-to-end tests, where a response that does not match the document fails the test. Zod’s output marks an optional property?: T | undefinedwhile the generated type says?: T, so underexactOptionalPropertyTypesa parsed form value is not assignable to a request type:exactOutput(...)from@flowcatalyst/api-runtime(2026-10-16) removes the undefined-valued properties and types the result exactly, in place of an application cast. -
Drift check in CI: after the Java (or Go) build has checked
openapi.json(section 9), the web build runsopenapi-tsand runs the drift check (fc-api-drift, a bin of@flowcatalyst/api-runtime:git statuson the folder, so added and deleted files count, or, without git,fc-api-drift --run "openapi-ts" src/api, which compares the folder’s file hashes before and after the generator); thenvite buildandvue-tsc --build, so a renamed field, a removed operation or a changed enum is a type error in the pages that use it. -
The toolchain, lint and tsconfig rules are those of [
../go/ui.mdnull sections 2, 3 and 6, which now apply to the shared UI package and to every application’sweb/.
12. Tests (Java)
Section titled “12. Tests (Java)”- descriptors: every start-up problem of sections 2 and 3; permission enforcement (
403 FORBIDDEN);Outcomemapping (Okwith headers,Failedwith aUseCaseError); omission of null components; the WARN for an undocumented status; - the emitter: every row of 5.1 (and every refusal), naming and collisions,
@Nullable, sealed interfaces (and the refusals for missing or mismatched@JsonSubTypes), generics, each rule of 5.4 (and an ECMA-incompatible pattern), the Jackson agreement test of 5.5, implied statuses, security schemes, the deterministic output (two runs and a shuffled declaration order give the same bytes); - the declaration-phase command: runs with no configuration file, no environment and no database reachable; exit code 1 with every problem listed;
OpenApiTesting.assertCommitted: passes, and fails with a diff after a change;- the conformance vectors of section 10;
- an end-to-end check in the example application: the generated client compiles under the UI’s
tsconfigand a Playwright run with response validation on passes against the real server. Not built with MO (it needs the UI package, MU U3). Checked by hand on 2026-10-14 instead:@hey-api/openapi-ts0.93.1 (the platform SPA’s pin) generated types, SDK and Zod 4 schemas fromfixture.json;tsc5.8 understrictandexactOptionalPropertyTypesaccepts the generated types, SDK and Zod files and a discriminated-union switch overShape; hey-api’s own runtime files (client/,core/) do not compile underexactOptionalPropertyTypes(the UI package must exclude them from that flag), and its Zod plugin writesint64asz.coerce.bigintwhile the type isnumber(to configure in the UI package). U0 pinned 0.99.0 and checked a hand-written document to these rules ([../ui/u0.mdnull) with the same findings for the runtime files; the emitted documents have not been run through 0.99.0 yet (U3 does, fromexamples/orders-demo/web/openapi.json). - As built (MO): the documents are validated in the Maven build against the OpenAPI Initiative’s
3.1 schema (
schema/2022-10-07, Apache-2.0, vendored as a test resource) and each component against the JSON Schema 2020-12 meta-schema, withcom.networknt:json-schema-validatoras a test dependency; the Jackson agreement test validates the typed writer’s JSON with the same library.
13. Rulings
Section titled “13. Rulings”Rulings 4, 5 and 6 were confirmed on 2026-10-14; the others were taken here and the may be reversed them.
- The framework’s own emitter, deriving schemas from records, enums and sealed interfaces, not a library (swagger-core’s model resolver or a JSON Schema generator): the house rules (values are records, no annotations for wiring) keep the type walk small, and a library would bring its own annotation vocabulary and defaults. The Go design took the same decision (Go decision 18).
- Declared in
register, bound inboot, and the declaration-phase command in core, so the document is dumped without configuration or a database. Outcome<R>as the handler’s result (a sealed type) instead of returningResponse.@Nullablemeans “may be absent”; typed operations omit null values; no three-state values. Owner, 2026-10-14: keep the split; plain routes andResponse.jsonkeep writing Jackson’snulls (no wire change for existing routes).- Closed schemas (
additionalProperties: false) for request and response records. Owner, 2026-10-14: confirmed. BigDecimalas a string on the wire of typed operations. Owner, 2026-10-14: confirmed.- Constraints only from the Validator; a custom rule documents nothing.
- Security schemes contributed by the resolving module; a context operation without one fails the dump.
- Byte-identical documents across Java and Go for the fixture API, rather than “equivalent after normalisation”.