Skip to content

ExportApi

Source: src/AWS/ApiGatewayV2/ExportApi.ts

Runtime binding for exporting an HTTP API’s OpenAPI 3.0 definition (apigateway:GET on /apis/{apiId}/exports/{specification}).

Bind an Api inside a function runtime to serve or snapshot the live API definition — e.g. publishing your own /openapi.json route or diffing deployed routes against the source of truth. The response body is a byte Stream of the JSON (or YAML) document. Provide ApiGatewayV2.ExportApiHttp on the Function effect to implement the binding.

// init
const exportApi = yield* ApiGatewayV2.ExportApi(api);
// runtime
const exported = yield* exportApi({ OutputType: "JSON" });
const document = yield* Stream.mkString(Stream.decodeText(exported.body!));