# OasHeader

CLASS in `@skmtc/core 0.63.4`

Represents a Header Object in the OpenAPI Specification.

The `OasHeader` class encapsulates the definition of a single HTTP header that
can be sent with responses or expected in requests. Headers provide additional
metadata about the HTTP message and can include authentication tokens, content
information, pagination data, rate limiting details, and more.

This class provides comprehensive support for header definitions with typed
values, validation schemas, examples, and documentation.

## Signature

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

class OasHeader
```

## Examples

Basic authentication header:

```ts
import { OasHeader, OasString } from '@skmtc/core';

const authHeader = new OasHeader({
  description: 'Bearer token for API authentication',
  required: true,
  schema: new OasString({
    pattern: '^Bearer [A-Za-z0-9+/=]+$',
    description: 'JWT bearer token'
  }),
  examples: {
    valid: new OasExample({
      summary: 'Valid bearer token',
      value: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
    })
  }
});
```

## Constructor

### constructor

```ts
constructor(fields: HeaderFields)
```

## Properties

- `oasType` ('header')
- `description` (string | undefined): Brief description of header
- `required` (boolean | undefined): Indicates if header is mandatory. Default value is `false`
- `deprecated` (boolean | undefined): Indicates if header is deprecated and should no longer be used. Default value is false
- `schema` (OasSchema | OasRef<'schema'> | undefined): Schema for the header
- `examples` (Record<string, OasExample | OasRef<'example'>> | undefined): Examples of the header
- `content` (Record<string, OasMediaType> | undefined): Content of the header
- `extensionFields` (Record<string, unknown> | undefined): Specification Extension fields

## Methods

### isRef

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

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(): OasHeader
```

Returns itself

### resolveOnce

```ts
resolveOnce(): OasHeader
```

### toSchema

```ts
toSchema(mediaType?: string): OasSchema | OasRef<'schema'>
```

Returns schema for the header. Either, `schema` property if
defined or value matching `mediaType` from `content` property. When
`content` has exactly one entry (the spec requires one), its schema is
used whatever the media type, as in `OasParameter.toSchema`.

- `mediaType`: Optional media type to get schema for, an exact lookup. Omitted: the JSON media type (`application/json`, else the first JSON-like type, else `*\/*`).

### toJsonSchema

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