@kubb/oas
Version:
Oas helpers
63 lines (58 loc) • 2.48 kB
TypeScript
import * as OasTypes from 'oas/types';
import { OASDocument, User, SchemaObject as SchemaObject$1, ParameterObject } from 'oas/types';
export { OasTypes };
export { HttpMethods as HttpMethod } from 'oas/types';
export { findSchemaDefinition, matchesMimeType } from 'oas/utils';
import { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
export { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
import BaseOas from 'oas';
import { Operation } from 'oas/operation';
export { Operation } from 'oas/operation';
export { Infer, Model, RequestParams, Response } from './infer.js';
import 'hotscript';
import 'ts-toolbelt';
import 'json-schema-to-ts';
type contentType = 'application/json' | (string & {});
type SchemaObject = OasTypes.SchemaObject & {
'x-nullable'?: boolean;
$ref?: string;
};
declare const HttpMethods: {
GET: "get";
POST: "post";
PUT: "put";
PATCH: "patch";
DELETE: "delete";
HEAD: "head";
OPTIONS: "options";
TRACE: "trace";
};
type Options = {
contentType?: contentType;
};
declare class Oas<const TOAS = unknown> extends BaseOas {
#private;
document: TOAS;
constructor({ oas, user }: {
oas: TOAS | OASDocument | string;
user?: User;
}, options?: Options);
get($ref: string): any;
set($ref: string, value: unknown): false | undefined;
resolveDiscriminators(): void;
dereferenceWithRef(schema?: unknown): any;
getResponseSchema(operation: Operation, statusCode: string | number): SchemaObject$1;
getRequestSchema(operation: Operation): SchemaObject$1 | undefined;
getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
valdiate(): Promise<void>;
}
declare function isOpenApiV3_1Document(doc: any): doc is OpenAPIV3_1.Document;
declare function isParameterObject(obj: ParameterObject | SchemaObject$1): obj is ParameterObject;
declare function isNullable(schema?: SchemaObject$1 & {
'x-nullable'?: boolean;
}): boolean;
declare function isReference(obj?: unknown): obj is OpenAPIV3.ReferenceObject | OpenAPIV3_1.ReferenceObject;
declare function isRequired(schema?: SchemaObject$1): boolean;
declare function isOptional(schema?: SchemaObject$1): boolean;
declare function parse(pathOrApi: string | OASDocument, oasClass?: typeof Oas): Promise<Oas>;
export { HttpMethods, Oas, type SchemaObject, type contentType, isNullable, isOpenApiV3_1Document, isOptional, isParameterObject, isReference, isRequired, parse };