import { type OpenAPIObject, type OperationObject, type PathItemObject, type ReferenceObject, type SchemaObject, } from "openapi3-ts"; import { type TaggedSchema } from "../schemas.js"; import { isNotReferenceObject, isTruthy } from "../util.js"; export type TaggedSchemaObject = SchemaObject & TaggedSchema; export type MaybeSchemaHolder = { schema?: SchemaObject | ReferenceObject }; export type SchemaHolder = { schema: SchemaObject | ReferenceObject }; export function operations(path: PathItemObject): Array { return [ path.get, path.put, path.post, path.delete, path.options, path.head, path.patch, path.trace, ].filter(isTruthy); } export function mapPathItems( oas: OpenAPIObject, fn: (path: PathItemObject) => T ): Array { return Object.values(oas.paths || {}) .filter(isNotReferenceObject) .flatMap(fn); }