oas
Version:
Comprehensive tooling for working with OpenAPI definitions
29 lines (26 loc) • 1.05 kB
text/typescript
import { OASDocument } from '../types.cjs';
import 'json-schema';
import 'openapi-types';
interface ReducerOptions {
/** A key-value object of path + method combinations to reduce by. */
paths?: Record<string, string[] | '*'>;
/** An array of tags in the OpenAPI definition to reduce by. */
tags?: string[];
}
/**
* With an array of tags or object of paths+method combinations, reduce an OpenAPI definition to a
* new definition that just contains those tags or path + methods.
*
* @example <caption>Reduce by an array of tags only.</caption>
* reducer(apiDefinition, { tags: ['pet'] })
*
* @example <caption>Reduce by a specific path and methods.</caption>
* reducer(apiDefinition, { paths: { '/pet': ['get', 'post'] } })
*
* @example <caption>Reduce by a specific path and all methods it has.</caption>
* reducer(apiDefinition, { paths: { '/pet': '*' } })
*
* @param definition A valid OpenAPI 3.x definition
*/
declare function reducer(definition: OASDocument, opts?: ReducerOptions): OASDocument;
export = reducer;