Skip to main content

Class: OASUtils

Defined in: core/src/OASUtils.ts:29

Constructors

Constructor

new OASUtils(): OASUtils

Returns

OASUtils

Methods

clearSpecCache()

static clearSpecCache(): void

Defined in: core/src/OASUtils.ts:265

Clears the spec parse cache. Useful in tests to force re-loading of specs.

Returns

void


getDatastore()

static getDatastore(spec, name): any

Defined in: core/src/OASUtils.ts:37

Gets the datastore definition with the specified name.

Parameters

spec

any

The OpenAPI specification to search.

name

string

The name of the datastore to retrieve.

Returns

any

The definition for the datastore with the given name if found, otherwise undefined.


getObject()

static getObject(spec, path): any

Defined in: core/src/OASUtils.ts:54

Gets the specification object at the specified path.

Parameters

spec

any

The OpenAPI specification to reference.

path

string

The path of the object to retrieve.

Returns

any

The object at the specified path if found, otherwise undefined.


getResponse()

static getResponse(obj): any

Defined in: core/src/OASUtils.ts:81

Returns the first available response object for a 2XX response as defined by the provided Operation schema object.

Parameters

obj

any

The Operation schema object to search.

Returns

any


getResponseContent()

static getResponseContent(obj): any

Defined in: core/src/OASUtils.ts:100

Returns the first available response content object for a 2XX response as defined by the provided Operation schema object.

Parameters

obj

any

The Operation schema object to search.

Returns

any


getSchema()

static getSchema(spec, name): any

Defined in: core/src/OASUtils.ts:112

Retrieves the schema definition with the given name.

Parameters

spec

any

The OpenAPI specification object to reference.

name

string

The name of the schema to retrieve.

Returns

any

The schema definition with the given name.


getTypeInfo()

static getTypeInfo(schemaDef, spec, convertDataType): any

Defined in: core/src/OASUtils.ts:136

Extracts the type information for a given schema Object definition.

Parameters

schemaDef

any

The schema definition object to extract type information from.

spec

any

The entire OpenAPI specification object.

convertDataType

Function

The function that converts OpenAPI Specification types to native types.

Returns

any

A tuple containing the type, subType and subSchemaRef information.


loadSpec()

static loadSpec(file, options?): Promise<any>

Defined in: core/src/OASUtils.ts:196

Attempts to load the Open API specification at the given path or URL.

Security note: file is used directly for local file access and outbound HTTP requests. If file may ever originate from an external or untrusted caller (e.g. a request parameter), pass options.allowedDirs and/or options.allowedHosts to restrict what can be loaded and prevent path traversal or SSRF.

Parameters

file

string

The path or URL of the OpenAPI Specification file to load.

options?

LoadSpecOptions

Optional restrictions on what file is permitted to resolve to.

Returns

Promise<any>

A promise whose result will be the loaded OpenAPI Specification as an object.