oas
Version:
Comprehensive tooling for working with OpenAPI definitions
55 lines (49 loc) • 2.63 kB
text/typescript
import { OASDocument, SchemaObject } from './types.cjs';
export { t as jsonSchemaTypes } from './get-parameters-as-json-schema-Cbp85O99.cjs';
import 'json-schema';
import 'openapi-types';
/**
* Selects a content type from an array of content type keys, prioritizing `application/json`
* and other JSON-like content types over other content types.
*
* When multiple content types are present:
* - If there's exactly one content type, it's returned
* - If there are multiple content types, JSON-like content types (e.g., `application/json`,
* `application/vnd.api+json`) are prioritized
* - If no JSON-like content types are present, the first content type is returned
*
* @param contentKeys - Array of content type keys (e.g., ['application/json', 'application/xml'])
* @returns The selected content type, or undefined if the array is empty
*/
declare function getParameterContentType(contentKeys: string[]): string | undefined;
declare const _default: {
formUrlEncoded: (mimeType: string) => boolean;
json: (contentType: string) => boolean;
multipart: (contentType: string) => boolean;
wildcard: (contentType: string) => boolean;
xml: (contentType: string) => boolean;
};
/**
* Dereference a `$ref` pointer if present, otherwise return the value as-is.
*
* This function handles `$ref` pointers on-the-fly without requiring full dereferencing and
* prevents infinite loops by tracking seen `$ref` pointers and not re-processing circular
* references.
*
* @param value The value that may contain a `$ref` pointer.
* @param definition OpenAPI definition to look for the `$ref` pointer in.
* @param seenRefs Optional Set to track `$ref` pointers that have already been processed to prevent circular references.
* @returns The dereferenced value if it was a `$ref`, otherwise the original value. Returns the original `$ref` if it's circular.
*/
declare function dereferenceRef<T>(value: T, definition?: OASDocument | SchemaObject, seenRefs?: Set<string>): T;
/**
* Recursively resolve `$ref` pointers inside a given schema.
*
* Uses the same `seenRefs` logic as `dereferenceRef` for protection against circular references.
*
* @see {@link dereferenceRef}
*/
declare function dereferenceRefDeep<T>(value: T, definition?: OASDocument | SchemaObject, seenRefs?: Set<string>): T;
declare const supportedMethods: readonly ["get", "put", "post", "delete", "options", "head", "patch", "trace"];
declare const SERVER_VARIABLE_REGEX: RegExp;
export { SERVER_VARIABLE_REGEX, dereferenceRef, dereferenceRefDeep, getParameterContentType, _default as matchesMimeType, supportedMethods };