Quick Start: Creating a REST/JSON Service

The fastest way to create a REST mock service is to import it from Swagger.

MockMotor has a fairy basic Swagger import functionality. It creates a single response for each path and HTTP method from the provided Swagger, and these responses are configured to return HTTP 500. However, all that remains to do after the import is to provide your own payload and change the HTTP code to 200.

Let's import Swagger's own PetStore API.

On the environment page, click Services tab.

On the Services page, click on “Add Service from Swagger” button:

Import Swagger

In the appeared dialog, click on Browse and select Swagger file to import.

Click on Import.

MockMotor doesn't support loading Swagger from an URL. Download Swagger to a local file before importing.

Review Created Service

Browser will redirect you to the new service description page. MockMotor populates the service name and description from the Swagger.

Note that the full URL of the service is shown under its name.

Review Created Responses

Click on the Responses tab. You'll see that MockMotor created a response for each Swagger path and HTTP method.

The responses are matched by relative URI and HTTP method, and configured to respond with HTTP 500:

Update Responses

If you need to modify a response, click on it and update any property you need.

For instance, update a response for DELETE user/{username}:

Then save it:

Use it

Point your application to the service URL and you should see them work.