OpenAPI Metadata
The openapi target generates openapi_{filename}.json for HTTP-style interfaces.
Minimum Generation Command
Section titled “Minimum Generation Command”xidlc gen --out-dir generated openapi api.idlDocument Version
Section titled “Document Version”The openapi target accepts a --version option that selects the OpenAPI
specification version of the generated document:
xidlc gen --out-dir generated openapi --version 3.1 api.idl| Value | Behavior |
|---|---|
auto (default) |
Emits OpenAPI 3.1, upgrading the whole document to 3.2.0 when the contract contains any streaming operation. |
3.1 |
Always emits 3.1.0. Streaming operations are rendered best-effort: the stream item type stays in the media type schema, without the OpenAPI 3.2 itemSchema field. |
Streaming operations need OpenAPI 3.2 for itemSchema, which describes the
structure of a single streamed message. Many documentation tools still only
read 3.1, and an unsupported version makes the whole document unusable,
including its non-streaming operations. Use --version 3.1 when the document
must stay readable by those tools; the streamed message structure is then left
approximate.
--version is not the document’s info.version; that comes from the
version pragma below. It is also unrelated to --api-version, which selects
which API version of a versioned contract to generate.
Webhook Publication
Section titled “Webhook Publication”Add the argument-free @webhooks marker to an interface or operation to publish
its HTTP contract under OpenAPI webhooks. Other operations remain in paths.
The webhook key is the operation’s existing operationId.
interface Receiver { @get(path="/events") boolean ready(); @webhooks @post(path="/events") string receive(@header(name="X-Delivery-ID") string delivery_id, @body string event);};The marked operation keeps the same request, response, exceptions, security and version semantics. Ordinary client and server targets still generate the same HTTP operation. The application supplies the destination URL, event envelope, signing, delivery and replay policy; the marker does not add a runtime dependency.
OpenAPI generation rejects duplicate webhook operation identifiers and webhook operations with path parameters: a webhook key is an identifier, not a path template. Ordinary client and server generation retains its existing path parameters. Equivalent route aliases publish one webhook per operation.
The earlier draft form @webhooks(signature=..., envelope=...) is rejected.
Declare bodies and headers with ordinary HTTP annotations and implement signing
in the application or a separate library. See the
Webhook FRD
for the design boundary.
Metadata Pragmas
Section titled “Metadata Pragmas”The generator reads the following pragmas to populate the document metadata:
package->info.titleversion->info.version
#pragma xidlc package "Smart City Public APIs"#pragma xidlc version "v2.0.0"If omitted, the generator falls back to default metadata. See
Compiler Pragmas for the full pragma reference,
including service endpoint declarations.