Skip to Content

Publish a Mock Server

Publishing takes one commit of your repository and puts a live mock server on APIGit Cloud at a URL of its own, https://<name>.mockserver.apigit.com.

  • A spec-based publish collects the chosen OpenAPI documents and every local file they $ref.
  • A code-based publish packages the apigit-mock/ folder.

From a terminal or CI, apigit mock publish does the same, and apigit mock logs reads the request log.

Publish as many mock servers as your plan allows. They are identified by name, so any number of them, of either type, can come from one repository and even from one commit.

Where to publish

From a branch

Open the repository, switch to the branch, click Publish, and choose Publish MockServer. Only a publish from a branch can follow that branch.

Publish Mock Server from a branch

From a specific commit

Open the commit list and publish from any commit in the history. This is useful for a mock of an earlier release. A publish from a commit is always pinned.

Publish Mock Server from a commit

While editing

In editing mode, click Publish and choose a commit, without leaving the editor.

Publish Mock Server while editing

The publish dialog

Publish dialog of a spec-based mock server

OptionWhat it sets
Publish TargetThe branch and commit being published
Update StrategyPin to commit, the default, or Follow branch (paid plans). See Pin or follow a branch.
Publish ModeShown when the repository already has a mock server: Overwrite existing server or Publish a new server
Server TypeSpec-based, the default, or Code-based (paid plans)
Mock Server URLThe mock server’s name. A name is generated for you; on the Enterprise plan you can choose your own.
Documents & Base PathsSpec-based only: the documents to serve, each under a base path. See Documents and base paths.
DescriptionA note shown in the mock server list
Access ControlPublic Access or API Token Required. See Access, logs, settings.

A chosen name may use lowercase letters, digits and hyphens, must start and end with a letter or digit, and can be up to 63 characters.

Publish a code-based mock server

Select Code-based under Server Type. The dialog then has no documents to choose: the mock runs whatever apigit-mock/main.js defines at this commit. The folder must contain main.js, and it can be at most 2 MiB once zipped.

Publish dialog of a code-based mock server

Overwrite a mock server

To move a mock server to a new commit, choose Overwrite existing server, pick the mock, and click Overwrite existing deploy. An overwrite keeps the URL, the access token, the settings, the logs and, for a code-based mock, its state, so your clients need no change.

A mock server keeps its type when overwritten. To change the type, revoke the mock server (Setting > Danger Zone) and publish a new one.

If you publish to the same mock often, follow a branch instead (paid plans). Every update of the branch then overwrites the mock for you.

View published mock servers

Open the repository’s Publish Center for its mock servers, with each one’s type, commit, access and URL:

Mock servers of a repository

To see the mock servers of all your repositories, click Publishes Center in the top navigation.

All published mock servers

Last updated on