Skip to content

ExportSchema

Source: src/AWS/Schemas/ExportSchema.ts

Runtime binding for schemas:ExportSchema.

Exports the bound Schema as a JSONSchema Draft 4 document — useful when a function needs a portable validation schema for an event contract that is registered as OpenAPI 3. The registry and schema names are injected from the binding. Provide the implementation with Effect.provide(AWS.Schemas.ExportSchemaHttp).

Note: AWS only allows exporting discovered or AWS-managed schemas (registries discovered-schemas / aws.events). Calling it on a custom-registry schema fails with a typed ForbiddenException (You cannot export non discovered or non aws managed schemas.).

// init — bind the operation to the schema
const exportSchema = yield* AWS.Schemas.ExportSchema(schema);
// runtime
const { Content } = yield* exportSchema({ Type: "JSONSchemaDraft4" });
const jsonSchema = JSON.parse(Content!);