OpenAPI document
OasWebhook
Represents an OpenAPI 3.1 webhook - a third OAS subject, peer to OasOperation and the schema/model subjects.
Kept OUT of OasDocument.operations (it lives in OasDocument.webhooks) so existing client/SDK generators never receive one: webhook code generation is a receiver/handler concern, not a client-call concern.
Carries webhook-semantic accessors named for the RECEIVER - toPayload/toPayloadSchema (the received payload), toParams (inbound params), toAckResponse/toAckResponseCode (the ack the handler returns). These deliberately avoid the client-framed OasOperation names (toRequestBody, toSuccessResponse) so the inversion stays explicit in generator code. (Signature-verification helpers still accrue on demand.)
Signature
import { OasWebhook } from '@skmtc/core'
class OasWebhook extends OasBaseConstructor
constructor
constructor(fields: WebhookFields, context?: ParseContextType)Properties
Type identifier for OAS webhook objects
The webhook name (the webhooks map key - NOT a URL path)
The HTTP method for this webhook
The parent path item containing this webhook
Unique identifier for the webhook operation
Brief summary of the webhook
Tags for organizing webhooks in documentation
Detailed description of the webhook
Parameters accepted by this webhook
Payload delivered to the handler for this webhook
Acknowledgement responses mapped by status code
Security requirements for this webhook
Whether this webhook is deprecated
External documentation for this webhook
OpenAPI specification extensions
Servers for this webhook
Methods
toPayload
toPayload(): OasRequestBody | undefinedThe received-payload body - the request body the API delivers TO the consumer's handler. Webhook semantics are inverted: this is what the handler RECEIVES, not what a client sends. A $ref body is resolved.
toPayloadSchema
toPayloadSchema(mediaType?: string): OasSchema | OasRef<'schema'> | undefinedThe schema of the received payload for mediaType, an exact lookup - the inbound body shape a handler generator writes a type for. Without mediaType, the media type OasRequestBody.toJsonContent picks. undefined when there is no body or no schema for that media type.
toEffectiveParameters
toEffectiveParameters(): (OasParameter | OasRef<'parameter'>)[]The inbound parameters that apply to this webhook, path item parameters included, with references unresolved. Mirrors OasOperation.toEffectiveParameters.
the parameters, path item's first
toParams
toParams(filter?: OasParameterLocation[]): OasParameter[]Resolve the inbound parameters (e.g. the signature/headers a handler receives), optionally filtered by location. Mirrors OasOperation.toParams, path item parameters included; the parameters carry the same shape, only their direction is inbound.
when a parameter is a reference that names nothing
toAckResponseCode
toAckResponseCode(): string | undefinedThe status code of the primary acknowledgement response - the lowest 2xx the handler returns to ack the delivery, falling back to default. Named for the receiver: a webhook's responses are what the handler RETURNS, not what a client receives (cf. OasOperation.toSuccessResponseCode).
toAckResponse
toAckResponse(): OasResponse | OasRef<'response'> | undefinedThe primary acknowledgement response definition (the body/headers the handler returns), or undefined when none is declared.
toJSON
toJSON(): objectSerializes the webhook to a plain JavaScript object.