# OasLink

CLASS in `@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

```ts
import { OasLink } from '@skmtc/core'

class OasLink
```

## Examples

Example:

```ts
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

```ts
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

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

Returns true if object is a reference

### isReadOnly

```ts
isReadOnly(): boolean
```

Always `false`: `readOnly` is a schema keyword.

### isWriteOnly

```ts
isWriteOnly(): boolean
```

Always `false`: `writeOnly` is a schema keyword.

### resolve

```ts
resolve(): OasLink
```

Returns itself

### resolveOnce

```ts
resolveOnce(): OasLink
```

### toJsonSchema

```ts
toJsonSchema(options: ToJsonSchemaOptions): OpenAPIV3.LinkObject
```
