Docs@skmtc/core

OpenAPI document

CLASS

OasWebhook

@skmtc/core 0.63.4

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 OasBase

Constructor

constructor

constructor(fields: WebhookFields, context?: ParseContextType)

Properties

oasType, 'webhook'

Type identifier for OAS webhook objects

name, string

The webhook name (the webhooks map key - NOT a URL path)

method, Method

The HTTP method for this webhook

pathItem, OasPathItem | undefined

The parent path item containing this webhook

operationId, string | undefined

Unique identifier for the webhook operation

summary, string | undefined

Brief summary of the webhook

tags, string[] | undefined

Tags for organizing webhooks in documentation

description, string | undefined

Detailed description of the webhook

parameters, (OasParameter | OasRef<'parameter'>)[] | undefined

Parameters accepted by this webhook

requestBody, OasRequestBody | OasRef<'requestBody'> | undefined

Payload delivered to the handler for this webhook

responses, Record<string, OasResponse | OasRef<'response'>>

Acknowledgement responses mapped by status code

security, OasSecurityRequirement[] | undefined

Security requirements for this webhook

deprecated, boolean | undefined

Whether this webhook is deprecated

externalDocs, OasExternalDocs | undefined

External documentation for this webhook

extensionFields, Record<string, unknown> | undefined

OpenAPI specification extensions

servers, OasServer[] | undefined

Servers for this webhook

Methods

toPayload

toPayload(): OasRequestBody | undefined

The 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'> | undefined

The 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.

Returns

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.

Throws

when a parameter is a reference that names nothing

toAckResponseCode

toAckResponseCode(): string | undefined

The 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'> | undefined

The primary acknowledgement response definition (the body/headers the handler returns), or undefined when none is declared.

toJSON

toJSON(): object

Serializes the webhook to a plain JavaScript object.