Skip to content

OpenAPI bundler: many files to one

Runs in your browser. Nothing is uploaded.

Resolve the $refs of a multi-file OpenAPI description and get one self-contained file to publish, mock or share.

Files

3 files
openapi: 3.0.3
info:
  title: Pet store
  version: 1.0.0
servers:
  - url: https://petstore.example.com/v1
paths:
  /pets:
    get:
      operationId: listPets
      summary: List all pets
      responses:
        "200":
          description: The pets
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: ./schemas/pet.yaml
  /owners/{ownerId}:
    get:
      operationId: showOwner
      summary: Info for one owner
      parameters:
        - name: ownerId
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: The owner
          content:
            application/json:
              schema:
                $ref: ./schemas/owner.yaml

Result

Paste, upload or load a file to start

How it works

Upload the files of a multi-file OpenAPI description, or load the entry file from a URL. The page picks the file with an openapi field as the entry (change it in the toolbar), follows its $refs with the bundler of apigit bundle, and shows the one self-contained file, ready to copy or download.

The sample is a pet store in three files: openapi.yaml, and schemas/pet.yaml and schemas/owner.yaml, which it refers to by relative $ref. The end of the bundled file, where the two schemas now live:

components:
  schemas:
    owner:
      type: object
      required:
        - id
      properties:
        id:
          type: string
        name:
          type: string
    pet:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        owner:
          $ref: "#/components/schemas/owner"

The schemas that were in other files are now under components.schemas, and every reference to them points inside the document.

What it does not do

  • It does not fetch anything for uploaded files: a $ref to a URL is listed as not followed. Upload the file it names, or load the entry from its URL.
  • It does not validate the result; send it to the validator with "Check this".
  • It does not split a file into several, and it does not rename schemas to a convention.
  • It does not keep your files on a server; the last input stays in this browser until you click Clear.

This tool and APIGit

This toolWith APIGit
Files you upload, bundled onceSplit specs kept in a Git repository, with references to other files in the repository resolved for rendering
One output fileapigit bundle openapi.yaml -o dist/openapi.yaml in CI
Copy or downloadA mock server from the split spec: local files it references are collected with it at publish
No preview of the result hereThe same files rendered in the editor's Preview tab and on the published docs site

Questions and answers

What does bundling an OpenAPI file mean?
Following every $ref to another file and putting what it points to into one document, so the result has no references to other files. Tools that take one file (a viewer, a code generator, a gateway) can then read it.
How do I give it several files?
Upload them together (or drop them on the input), then pick the entry file, the one with the openapi field. Relative $refs between the uploaded files are resolved in your browser; nothing is uploaded to APIGit.
Can it bundle a spec from a URL?
Yes. Load the entry file from its URL and the relative $refs are fetched from the same host, up to 100 files, ten levels deep, ten seconds each. A $ref to another host, to localhost or to a private address is not fetched.
Is it the same as apigit bundle?
It runs the bundler of the APIGit CLI in your browser. Shared schemas end up under components, and the references to them become local ones.
Does it change my schemas?
It does not change what they say. It moves what the references point to into the one file, names each moved schema after its file (schemas/pet.yaml becomes pet), and rewrites the references; properties, examples and descriptions stay as written.
What is the size limit?
5 MB for each input. The CLI has no such limit.