DEV Community

Jeff
Jeff

Posted on Originally published at powerduck.com

Mockoon OpenAPI Environment Import: What It Builds and What It Does Not

Quick answer: Importing an OpenAPI file in Mockoon builds a local mock environment saved as a data file, not a running service or a backend. It maps the server, paths, methods, status codes, headers and descriptions into routes and generates sample bodies from schemas and examples, while behavior such as auth, parameter validation and conditional responses stays out of the import and has to be added by hand.

What the import actually builds

The converter reads a Swagger v2 or OpenAPI v3 document in JSON or YAML and writes one Mockoon environment. The result is a skeleton you can start and edit locally. Nothing is deployed, and no server process is started for you.

OpenAPI element Result in the environment
API title Environment name
Server URL, port, base path, protocol Host, port, prefix and TLS setting
Paths and methods Routes, with path parameters rewritten as :param
Responses with status codes Responses keyed by the same code
Headers and descriptions Route and response headers and text
Schemas and examples Generated sample JSON bodies, import only

References are handled in a specific way. URL references are resolved automatically during import, but file references are not. If your definition is split across several files on disk, bundle it into one document first or the local references will fail.

How to run the import

  1. Open the environment creation menu and choose New local environment from OpenAPI/Swagger.
  2. Pick a local file, enter a URL, or paste the specification content into the dialog.
  3. Review the preview, then import. The new environment appears in the list and can be started on the port and prefix the converter mapped.
  4. If the preview shows unresolved references, cancel, bundle the spec, and run the import again rather than editing routes that were never created.

What does not come across

The supported list is closed, so anything outside it has no Mockoon equivalent or is not implemented yet. Security schemes do not become auth checks. To reject requests that carry no token, you build a wildcard route plus a response rule that returns 401 yourself. Query constraints and enum limits do not become validation either, so the mock will not reject a bad payload on its own. The rules system has no specification equivalent, which means a round trip through OpenAPI drops it, and bodies authored in Mockoon are not converted back into schemas. That is why Mockoon recommends sharing and running mocks from its own data files instead of an OpenAPI export.

Importing a spec never stands up the real backend. The generated routes return canned bodies in the local process; they do not run business logic or persist data. If you need to check the real contract, Powerduck uses the same definition to drive ordered scenario requests against a live target, with assertions on status, headers and fields at each step.

Reimport adds, never overwrites

Starting with v9.6.0, reimport lets you point an existing environment at a newer document. It compares the two and only adds routes that are missing by method and path, plus responses that are missing by status code. A summary appears first, and you apply or discard it. Existing routes and responses are never modified or deleted.

This protects your manual work, but it is not a two-way sync. Endpoints removed from the spec stay in the environment, responses you edited are not reconciled, and any drift between the document and the mock is yours to track. Reimport is a safe way to grow a mock as the API grows, not a way to keep the two identical. If you are weighing this file-based approach against other tools, the comparison hub lays out how the two models differ.

Frequently asked questions

Does importing start the mock? No. It creates the environment file, and you press start to serve it on the mapped port.

Can I use a multi-file specification? URL references are resolved, but file references are not, so bundle the definition into one document first.

Will my security schemes enforce login? No. Auth is not generated. Add a wildcard route and a response rule that returns 401 when the expected header is missing.

Does reimport overwrite my edits? No. It only adds missing routes and responses and never changes or deletes existing ones.

The bottom line

Treat the import as a fast structural starting point, not a faithful conversion. It removes the mechanical work of recreating routes and status codes, then hands you a mock that still needs real behavior, auth and validation added and maintained. Keep the Mockoon data file as the source of truth for sharing and CLI runs, and verify the live contract separately instead of trusting the generated skeleton.

Top comments (0)