Docs@skmtc/core

OpenAPI document

CLASS

OasLink

@skmtc/core 0.63.4

Represents a Link Object in the OpenAPI Specification.

A link describes a possible design-time relationship from a response to another operation - for example, how the id in a create response can be used as the path parameter of a subsequent fetch. It names the target operation (by operationId or operationRef) and how to populate its parameters and request body from the current response.

Signature

import { OasLink } from '@skmtc/core'

class OasLink

Examples

Example
import { OasLink } from '@skmtc/core';

const getUserByUserId = new OasLink({
  operationId: 'getUser',
  parameters: { userId: '$response.body#/id' },
  description: 'The `id` of the created user is the `userId` of GET /users/{userId}'
});

Constructor

constructor

constructor(fields: LinkFields)

Properties

oasType, 'link'
operationRef, string | undefined

A URI reference to a target operation

operationId, string | undefined

The operationId of a target operation

parameters, Record<string, unknown> | undefined

Parameter values or runtime expressions for the target operation

requestBody, unknown

The request body value or runtime expression for the target operation

description, string | undefined

A description of the link

server, OasServer | undefined

A server to use for the target operation

extensionFields, Record<string, unknown> | undefined

Specification Extension fields

Methods

isRef

isRef(): this is OasRef<'link'>

Returns true if object is a reference

isReadOnly

isReadOnly(): boolean

Always false: readOnly is a schema keyword.

isWriteOnly

isWriteOnly(): boolean

Always false: writeOnly is a schema keyword.

resolve

resolve(): OasLink

Returns itself

resolveOnce

resolveOnce(): OasLink

toJsonSchema

toJsonSchema(options: ToJsonSchemaOptions): OpenAPIV3.LinkObject