Skip to main content

Version: 3.2.3.x

Mock API Response For Testing

Prerequisite

  1. You will be using Postman to demonstrate API design. Make sure you have Postman ready.

Create APIs in Postman

Once you have logged in to Postman, create or select an existing Workspace. Then, within that workspace, create a API by importing Swagger Petstore

Postman Import API

Select Copy to collections:

Postman Copy to Collection

Mock API Response

Create a Mock Server for the Swagger Petstore - OpenAPI 3.0:

Select Collection

Mock Server Form

After successful creation, click Copy Mock URL button to copy the Mock Server URL. Then navigate to the Swagger Petstore - OpenAPI 3.0 Variables, set the value of baseUrl to the Mock Server URL and Save:

Set Variables

Add Examples

In the Swagger Petstore - OpenAPI 3.0 collection, add examples for the two requests and save.

Find pet by ID

In Path Variables, set the Value for id to 1, then set the response:

{
"name": "Dog",
"photoUrls": [
"https://example.com/dog-1.jpg",
"https://example.com/dog-2.jpg"
],
"id": 1,
"category": {
"id": 1,
"name": "pets"
},
"tags": [
{
"id": 1,
"name": "friendly"
},
{
"id": 2,
"name": "smart"
}
],
"status": "available"
}

Click Save:

Set Example1

Click Try, and the example will correctly return the preset response.

Try Example1

Returns pet inventories by status

Set the response:

{
"available": 5,
"pending": 2,
"sold": 10
}

Click Save:

Set Example2

Click Try, and the example will correctly return the preset response.

Try Example2


API7.ai Logo

API Management for Modern Architectures with Edge, API Gateway, Kubernetes, and Service Mesh.

Product

API7 Cloud

SOC2 Type IIISO 27001HIPAAGDPRRed Herring

Copyright © APISEVEN PTE. LTD 2019 – 2025. Apache, Apache APISIX, APISIX, and associated open source project names are trademarks of the

Apache Software Foundation