edit-icon download-icon

Configure Mock

Last Updated: Feb 01, 2018

A project is usually developed by multiple partners working together. The interdependency among them may in turn restrict each of them during the process, and mutual misunderstanding may influence the development progress or even delay the project schedule. Therefore, Mock is generally used to simulate the return results established early in the project development cycle, so as to reduce understanding deviation and improve the development efficiency.

API Gateway supports simple configuration in Mock mode.

Configure a Mock

Click API Edition > Basic Backend Definitions to configure the Mock.

Select the Mock mode

  1. Select the Mock mode

    You can select Use Mock or Do not Use Mock. If you select Use Mock, the system will prompt you to confirm the selection.Mock prompt

  2. Enter the Mock return result

    You can enter the actual return result in the Mock return result field. Currently, the system supports Mock return results in JSON, XML or file format. For example:

    1. {
    2. "result": {
    3. "title": " Mock test for API Gateway",
    4. }
    5. }

    Save the Mock configuration and release it to the test or online environment for test or to the API debugging page for debugging based on your actual needs.

  3. Debugging

    You can initiate an API call on the API debugging page to test the setting result:

    Debug an API

    It means the Mock is successfully set.

Remove a Mock

To remove a Mock, change the selection to Do not Use Mock in the first image. The value of the Mock return result is not removed and you can use the value for the next Mock setting. You need to release the change. A change takes effect only after being released.

Thank you! We've received your feedback.