Docs@skmtc/core

Schemas

CLASS

OasNumber

@skmtc/core 0.63.4

A number schema: the OasSchema whose type is 'number'. A schema of type: integer is an OasInteger.

  • The parser keeps only the formats float and double. For another one, such as decimal, format is undefined.
  • In each OpenAPI version, an exclusive limit is in maximum or minimum, and exclusiveMaximum or exclusiveMinimum is true.

Signature

import { OasNumber } from '@skmtc/core'

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

Constructor

constructor

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

Properties

oasType, 'schema'

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

type, 'number'

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

title, string | undefined

A short summary of the number.

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

The default value of the number.

description, string | undefined

A description of the number.

nullable, Nullable | undefined

Indicates whether value can be null.

extensionFields, Record<string, unknown> | undefined

Specification Extension fields

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

An example of the number.

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

An array of allowed values for the number.

format, 'float' | 'double' | undefined

The format of the number.

multipleOf, number | undefined

The multiple of the number.

maximum, number | undefined

The maximum value of the number.

exclusiveMaximum, boolean | undefined

Whether the maximum value is exclusive.

minimum, number | undefined

The minimum value of the number.

exclusiveMinimum, boolean | undefined

Whether the minimum value is exclusive.

readOnly, boolean | undefined

Whether the number is read-only.

writeOnly, boolean | undefined

Whether the number is write-only.

deprecated, boolean | undefined

Whether the number 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'>): OasNumber

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

resolveOnce

resolveOnce(): OasNumber<Nullable>

toJsonSchema

toJsonSchema(options?: ToJsonSchemaOptions): OpenAPIV3.NonArraySchemaObject