OpenAPI import

Turn an OpenAPI document into mocks in one go: one endpoint per operation, answering with the spec's example.

Import

In a project's Endpoints, press the import button next to + (or "Import an OpenAPI spec" when the list is empty). Then paste the spec, upload a file, or fetch it from a URL. Your browser fetches the URL, so the server hosting the spec must allow cross-origin requests. If it doesn't, download the file and upload it instead.

Preview lists every operation it found. Pick the ones you want and press Import.

  • Supported: OpenAPI 3.0 and 3.1, in JSON or YAML, up to 2 MB and 300 operations. Swagger 2.0 isn't supported; convert it to OpenAPI 3 first.
  • Base path: taken from the path of the first servers URL, so with https://api.example.com/v1, the path /orders becomes /v1/orders. Change it or clear it in the preview, then press Apply.
  • Existing endpoints: an operation whose method and path already exist is marked exists. You can keep yours, or replace the response. Replacing keeps the endpoint's conditional responses, delay and on/off state.

Which response is used

For each operation, Jitterbox picks one response:

  1. The first 2xx response, then 2XX, then default, then the first one listed.
  2. Its first content type, preferring JSON.
  3. For the body: the media type's example, then the first of its examples, then the schema's example.
  4. With no example at all, it builds a sample from the schema: $ref, allOf, oneOf/anyOf (first option), enum, const, default, formats like uuid, date-time and email, and nested objects and arrays. Self-referencing schemas stop instead of looping.

The preview shows where each body came from: example, schema example, generated from schema, or no body.

What's skipped

Operations whose path parameters aren't a whole path segment, like /files/{name}.json, can't be matched and are listed under Can't import. Example bodies larger than 256 KB are skipped too.

After importing

Imported endpoints are ordinary endpoints. Edit them, add conditional responses, or point scenarios at them. Importing the spec again later only adds what's new, unless you choose to replace.