@opendoc/openapi-shaking
Version:
Remove the useless components and paths of openapi document.
22 lines (15 loc) • 1.1 kB
text/typescript
import { OpenAPIV3, OpenAPIV3_1 } from '@scalar/openapi-types';
import { Promisable } from 'type-fest';
interface ShakingOptions {
/**
* 容忍 Swagger 异常结构
*/
tolerant?: boolean;
}
declare function openapiShakingOrphanedComponents<T extends OpenAPIV3.Document | OpenAPIV3_1.Document>(document: T, options?: ShakingOptions): T;
type HttpMethods = OpenAPIV3.HttpMethods | OpenAPIV3_1.HttpMethods;
type ShakingFilter = (path: string, method: HttpMethods, operation: OpenAPIV3.OperationObject | OpenAPIV3_1.OperationObject) => Promisable<boolean>;
type ShakingFilterSync = (path: string, method: HttpMethods, operation: OpenAPIV3.OperationObject | OpenAPIV3_1.OperationObject) => boolean;
declare function openapiShaking<T extends OpenAPIV3.Document>(document: Readonly<T>, filter: ShakingFilter, options?: ShakingOptions): Promise<T>;
declare function openapiShakingSync(document: Readonly<OpenAPIV3.Document>, filter: ShakingFilterSync, options?: ShakingOptions): OpenAPIV3.Document;
export { openapiShaking, openapiShakingOrphanedComponents, openapiShakingSync };