UNPKG

oas-normalize

Version:

Tooling for converting, validating, and parsing OpenAPI, Swagger, and Postman API definitions

75 lines (72 loc) 2.33 kB
import { ParserOptions, ValidationResult } from '@readme/openapi-parser'; import { OpenAPI } from 'openapi-types'; import { Options } from './lib/types.js'; import { getType } from './lib/utils.js'; declare class OASNormalize { cache: { bundle?: OpenAPI.Document | false; convert?: OpenAPI.Document | false; deref?: OpenAPI.Document | false; load?: Record<string, unknown> | false; }; file: any; opts: Options; type: ReturnType<typeof getType>; constructor(file: any, opts?: Options); /** * Load and return the API definition that `oas-normalize` was initialized with. * */ load(): Promise<Record<string, unknown>>; private static convertPostmanToOpenAPI; /** * Bundle up the given API definition, resolving any external `$ref` pointers in the process. * */ bundle(): Promise<OpenAPI.Document>; /** * Dereference the given API definition. * */ dereference(): Promise<OpenAPI.Document>; /** * Dereference the given API definition. * * This method is deprecated in favor of `dereference`. It will be removed in a future release. * * @deprecated */ deref(): Promise<OpenAPI.Document>; /** * Convert a given API definition to OpenAPI if it is not already. * */ convert(): Promise<OpenAPI.Document>; /** * Validate a given API definition. * * If supplied a Postman collection it will be converted to OpenAPI first and then run through * standard OpenAPI validation. * */ validate(opts?: { /** * Options to supply to our OpenAPI parser. See `@readme/openapi-parser` for documentation. * This option is deprecated in favor of the `parser` option on the constructor. It will be * removed in a future release. * * @see {@link https://npm.im/@readme/openapi-parser} * @deprecated */ parser?: ParserOptions; }): Promise<ValidationResult>; /** * Retrieve OpenAPI, Swagger, or Postman version information about the supplied API definition. * */ version(): Promise<{ specification: 'openapi' | 'postman' | 'swagger'; version: string | 'unknown'; }>; } export { OASNormalize as default };