Docs@skmtc/core

Schemas

CLASS

OasArray

@skmtc/core 0.63.4

An array schema: the OasSchema whose type is 'array'. Its items are a schema or a reference to one.

  • The default value is in defaultValue. The string, number, integer and boolean schemas have it in default.
  • When the document gives no items, they are an OasUnknown.
  • The parser does not read prefixItems, so a tuple has only its items.
  • The parser cannot read items: true or items: false. It logs an error and leaves out the component, operation or response that has the schema.

Signature

import { OasArray } from '@skmtc/core'

class OasArray<Nullable extends boolean | undefined = boolean | undefined> extends OasBase

Constructor

constructor

constructor(fields: ArrayFields<Nullable>, context?: ParseContextType)

Properties

oasType, 'schema'

Object is part the 'schema' set which is used to define data types in an OpenAPI document.

type, 'array'

Constant value 'array' useful for type narrowing and tagged unions.

items, OasSchema | OasRef<'schema'>

Defines the type of items in the array.

title, string | undefined

A short summary of the array.

description, string | undefined

A description of the array.

nullable, Nullable | undefined

Indicates whether value can be null.

uniqueItems, boolean | undefined

Indicates whether the array items must be unique.

extensionFields, Record<string, unknown> | undefined

Specification Extension fields

example, Nullable extends true ? unknown[] | null | undefined : unknown[] | undefined

An example of the array.

maxItems, number | undefined

The maximum number of items in the array.

minItems, number | undefined

The minimum number of items in the array.

enums, Nullable extends true ? (unknown | null)[] | undefined : unknown[] | undefined

The enum values for the array.

defaultValue, Nullable extends true ? unknown[] | null | undefined : unknown[] | undefined

The default value for the array.

readOnly, boolean | undefined

Whether the array is read-only.

writeOnly, boolean | undefined

Whether the array is write-only.

deprecated, boolean | undefined

Whether the array is deprecated.

not, OasUnknown | undefined

The schema's not, kept as an OasUnknown under skmtc.config.json parse.not: unknown: the document says "not something", and core does not read what. undefined otherwise.

Methods

isRef

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

Determines if this array is a reference object.

Returns

Always returns false since this is a concrete array instance, not a reference

isReadOnly

isReadOnly(): boolean

Whether the value is readOnly: sent by the API only, never in a request.

isWriteOnly

isWriteOnly(): boolean

Whether the value is writeOnly: sent in a request only, never by the API.

clone

clone(ref?: OasRef<'schema'>): OasArray

A copy of this schema with what ref adds at its site applied: its nullable, readOnly, writeOnly and the keywords next to it (SiblingKeywords) that this type takes, a sibling's value winning. A value that does not fit this type is left out (the parser reports it). For OasRef.resolve(). This schema does not change, and the copy shares its child schemas.

traverse

traverse(path: SchemaPath): OasSchema | OasRef<'schema'>

resolve

resolve(): OasArray<Nullable>

Resolves this array object.

Returns

The array instance itself since it's already a concrete object, not a reference

resolveOnce

resolveOnce(): OasArray<Nullable>

Resolves this array object one level.

Returns

The array instance itself since it's already a concrete object, not a reference

toJsonSchema

toJsonSchema(options: ToJsonSchemaOptions): OpenAPIV3.ArraySchemaObject

Converts this OAS array to an OpenAPI v3 JSON schema representation.

options

Conversion options including reference handling and formatting preferences

Returns

OpenAPI v3 array schema object with type, items schema, and all validation constraints