Skip to main content

Module api_document

Module api_document 

Source
Expand description

Shared plumbing for emitting API description documents (OpenAPI 3.1, AsyncAPI 3.0) from the endpoint model.

This module deliberately contains no OpenAPI- or AsyncAPI-specific shapes. It provides the three things both emitters need and neither should reimplement:

  1. SchemaComponents — every referenced struct/enum collected once, at document scope rather than per-endpoint.
  2. relocate_refs — moving #/$defs/X to wherever a given document format wants its shared definitions.
  3. apply_meta — the meta passthrough, which is the sanctioned way to get per-field and per-endpoint annotations into a document without growing the model.

It lives in endpoint-libs rather than endpointgen because a server needs the same registry walk at startup to answer MCP requests, and a future OpenRPC emitter would need it a third time.

The RON definitions are the source of truth. Nothing here parses a document; these are outputs only.

Structs§

SchemaComponents
Every struct and enum referenced by a set of endpoints, emitted once.

Constants§

COMPONENTS_SCHEMAS_PREFIX
Where a document format keeps its shared schema definitions.

Functions§

apply_meta
Copies meta onto target, which must be a JSON object.
collect_refs
Collects every $ref target string in value.
json_object
Builds a JSON object from (key, value) pairs, skipping None values.
object_schema_for_fields
Object schema over a Vec<Field> with refs already relocated.
relocate_refs
Rewrites #/$defs/X to {prefix}X throughout value, in place.