Mock API is a tool that allows you to easily and quickly create REST API(s), or in other words, mock the API, without the need for technical knowledge or software development.

You can instantly create an API with default CRUD operations via API Documentation and open it to users as an API Proxy.

Another important point is; Thanks to the conditions added to the response, Apinizer provides different responses depending on the condition, based on the header, body or parameter values of the request.

The API definition documents of the created Mock APIs, of type Swagger and OpenAPI, can be accessed on the fly in JSON and YAML format.

Creating a Mock API 

The Development → API Creator → Mock API  path is followed through the main menu.

Click the Create button at the top right of the interface that opens.

The API creation work begins by filling in the fields below for the newly created API and clicking the Save and Next button at the top right

Creating Mock API with Blank Type

Creating this type of API means that API endpoints will be designed by the user.

If the Generate CRUD Operations option is enabled, GET, POST, PUT, DELETE enpoints will be added to the API automatically.

The picture below shows the blank type API creation settings:

Generating Mock API from Open API or Swagger

Creating this type of API means that the API will be created through the API Spec File.

The type of API document to be imported or linked should be Swagger or Open API.

The picture below shows the API creation with Import Spec type settings:


The fields used for the definition of the Mock API are shown in the table below.

Field

Description

Type

It is the creating type of the Mock API. It is done by uploading Blank and Spec file.

Name

It is the name given to the API by the user. This name appears in interfaces.

Description

It is the optional definition of the API.

Generate CRUD OperationsIt is selected if it is desired to create ready-made methods/endpoints in GET, POST, PUT and DELETE types for Mock API.

API Spec Type

Type information of the spec file to be loaded.

Supported types: OpenAPI 3.0.x, Swagger 2.x

Import Type

Type information of the API spec file to be loaded.
Supported types:URL, Upload File

URLThe address of the API spec file to load.

Creating a Endpoint

If the Generate CRUD Operations option is selected, the method/endpoints of GET, POST, PUT, DELETE types will be ready by default. A new method/endpoint is added by clicking the Add button as follows.


Filling the fields on the Method/Endpoint definition screen, click the Save button.


Adding or Editing a Response

The responses of the method/point are managed in the Response Information section.

Response definitions are created by grouping them according to Status Code information. More than one sample response based on condition can be created within each response definition.

The image of the dialog containing the response settings is given below:


The fields used for the Create/Edit a Response configuration are shown in the table below.

Field

Description

Status Code

HTTP status code information.

Description

It is the definition information of the method/endpoint.

Headers

HTTP Headers information is entered.

Response Examples

Examples of responses that will be sent to the user.

Adding or Editing a Response Example

Examples can be added to a response definition by creating multiple body and condition definitions. Thus, when the request comes to the same method, different responses can be sent to the client under different situations.

The image of the dialog containing the example settings is given below:


The fields used for the Create/Edit a Response Example configuration are shown in the table below.

Field

Description

Content Type

It is the response content type that will return as a response.

Condition

It is used to define under which condition the defined response will be returned.

Response Body

The body of the response to the user is written.

Creating API Proxy from Mock API

An API Proxy is created for the Mock API by clicking the Create API Proxy button.

To create API Proxy from Mock API, there must be at least one method/endpoint.

API Proxy is created by entering the required fields for API Proxy on the screen and clicking the Save button.


What can be done after this step is exactly the same as the API Proxy document. Click to go to the details.

Deploy/Redeploy

To view and manage API Proxies in Mock API, click the Manage API Proxies link, and they are viewed and managed from the window that opens.

In the window that opens, Deploy/Undeploy and Redeploy API Proxies created with Mock API are done in this section. Revisions, Deploying, Redeploying, Undeploying

To deploy the API Proxy, click on the Manage API Proxies link and click on the deploy icon.


Confirmation is required after the above process. The information about the installation process is created and the Deploy button is clicked.


When a new endpoint is added to the Mock API or changes are made in the Mock API, all API Proxies created from this API must be redeployed in order for the change to take effect.

When you add a new Method/Endpoint or update an existing Method/Endpoint the following information will appear.


By clicking Reload, the changes are applied to the API Proxies.


Confirmation is required after the above process. Click the Redeploy button after creating the information about the reinstallation process.


From the Mock API page, click on the name of the API Proxy to go to API Proxy.


Similarly, to go to the Mock API page from the API Proxy page, click on the Mock API name in the API Proxy as follows.

Deleting Mock API

When a Mock API is deleted, all API Proxies that depend on it are deleted first by Undeploy and then deleted.