Skip to main content

Function: mergeOpenApiSpecs()

mergeOpenApiSpecs(args): OpenApiSpec

Defined in: mergeOpenApiSpecs.ts:290

Merges every .yaml/.yml OpenAPI spec file in specsDir into a single OpenAPI document: paths are combined, components are combined (first-file-wins on name collisions), the first non-empty servers array found is kept, and cross-file $refs are rewritten to local refs.

A $ref into a file that is not in specsDir — a shared components file — pulls the component it names into the merged document, along with whatever that component refs in turn, so the rewritten local ref has something to point at.

Files are read in sorted filename order, so merge order — and therefore which file wins a naming collision — is deterministic.

Parameters​

ParameterType
argsMergeOpenApiSpecsArgs

Returns​

OpenApiSpec