Docs@skmtc/core

Schemas

CLASS

OasString

@skmtc/core 0.63.4

A string schema: the OasSchema whose type is 'string'. A string enum is also one, with its values in enums.

format can be any text, because the parser keeps what the document has. nullable does not add null to enums.

Signature

import { OasString } from '@skmtc/core'

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

Constructor

constructor

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

Properties

oasType, 'schema'

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

type, 'string'

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

title, string | undefined

A short summary of the string.

description, string | undefined

A description of the string.

format, string | undefined

The format of the string.

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

An array of allowed values for the string.

maxLength, number | undefined

The maximum length of the string.

minLength, number | undefined

The minimum length of the string.

nullable, Nullable | undefined

Indicates whether value can be null.

extensionFields, Record<string, unknown> | undefined

Specification Extension fields

example, Nullable extends true ? string | null | undefined : string | undefined

An example of the string.

pattern, string | undefined

The pattern of the string.

default, Nullable extends true ? string | null | undefined : string | undefined

The default value of the string.

readOnly, boolean | undefined

Whether the string is read-only.

writeOnly, boolean | undefined

Whether the string is write-only.

deprecated, boolean | undefined

Whether the string 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'>

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'>): OasString

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(): OasString<Nullable>

resolveOnce

resolveOnce(): OasString<Nullable>

toJsonSchema

toJsonSchema(options?: ToJsonSchemaOptions): OpenAPIV3.NonArraySchemaObject