/** * Component reachability: which `components` entries a document still needs, * and pruning the ones it does not. * * `fastify-type-provider-zod`'s `jsonSchemaTransformObject` writes *every* * schema of the Zod registry into `components.schemas` in a single pass over * the finished document, with no knowledge of which routes the route-level * transform hid. Without pruning, the public document carries the request and * response shapes of internal endpoints, and both `@scalar/fastify-api-reference` * and `@fastify/swagger-ui` render them in their models panel. */ /** * Minimal structural view of an OpenAPI document. Deliberately loose: the * filtering below only needs `paths`, `tags` and `components`, and typing the * rest would force a dependency on `openapi-types`. */ export type OpenApiDocumentLike = { paths?: Record | undefined>; tags?: Array<{ name?: string; } & Record>; components?: { schemas?: Record; } & Record; } & Record; /** * Drop every `components` entry the document no longer references. * * Reachability follows `$ref`s transitively, so an entry referenced only by * another kept entry survives. `components.securitySchemes` is never pruned: * security schemes are referenced by name from `security` requirements rather * than by `$ref`. * * Skip this if the document deliberately publishes a schema catalogue beyond * what its operations reference: pruning is exactly what you do not want then. * * The input document is never mutated. * * The type parameter is deliberately unconstrained. `openapi-types`' `Document` * interfaces have no index signatures, so they do not structurally satisfy * {@link OpenApiDocumentLike} even though they are exactly what this is for, * and constraining it would reject `app.swagger()`, the one argument that * matters. The document is inspected defensively at runtime instead. */ export declare function pruneUnreachableComponents(document: Document): Document;