Mock the API
The desktop app and the VS Code extension start apigenie-server on the spec you are editing,
and keep it in step with your edits. A client, or Try it out, gets the responses the spec
describes while the real server is still being written.
Start the mock
Install apigenie-server, 0.11.0 or later, and select an OpenAPI
spec. Mock server in the toolbar starts it on 127.0.0.1, on a free port. The toolbar then
says Mock of apigenie.serverPath
setting names the executable when it is not on the PATH.
The server gets the current text, saved or not, with the files the spec refers to inlined, shortly after you stop typing. When the server refuses a version, it keeps the previous one, and the status bar says so.
In the web editor the button is disabled, because a page cannot start a program; its tooltip says where the mock server runs.
Example or generated responses
The mock answers with the examples of each response. Tick Generated to get responses made
from the schemas instead, as apigenie-server --dynamic does, which exercises a client against
values it did not see in the examples. A running server starts again with the new choice.
The log
Log (n) opens the server’s log under the toolbar: each request with its method and path, what the server answered or found wrong with it, and each reload that failed. The panel keeps the last two hundred entries; Clear empties it and Close hides it. No requests yet. Send one to the URL above, or use Try it out in the preview is what an idle server shows.
Send Try it out to the mock
While the mock serves the spec, the preview of each operation says The mock server serves this
spec at
Responses you save
Save as mock response under a response of Try it out writes a scenario to the
configuration of apigenie-server, as
Try it out describes. The configuration is
read by apigenie-server when you run it yourself in the spec’s folder; the toolbar’s mock
server does not read it, and answers from the spec alone.
Next
Use Git commits the spec from the editor.
apigenie-server in the reference has every option of the mock.