Mock collections provide a structured way to manage your mocks. Each collection can optionally include a static “path” that is automatically prepended to the mock endpoints within that collection. This feature is particularly useful for versioning your mocks, ensuring consistency and clarity across different versions of your API.
Key benefits
-
Efficient Organization:
- Group related mocks together, making it easier to manage and locate them.
-
Better Versioning:
-
Utilize the static "path" feature to prepend a version identifier or other relevant prefixes to your mock endpoints.
-
Simplify the process of updating and managing multiple versions of your API.
-
Example
Consider a collection for API version 1.0:
- Collection path:
/api/v1
-
Mock Endpoints:
-
/users
-
/products
-
With the collection path, the actual mock endpoints become:
/api/v1/users
/api/v1/products
This approach ensures that all endpoints within the collection are easily versioned, improving maintainability and clarity.
Creating a New Collection:
Go to the Mocks Dashboard
From the Requestly dashboard, click on "Mock" in the left menu bar.
Click on "New Collection"
On the top right side of the table, click on new collection
Enter the details of the Mock Collection.
-
Name: Give the collection a name.
-
Collection Path: A path which gets prepended to all the mocks inside this collection. For example, if the collection path is "/api/v1", then all the child mocks’ endpoints will start with this path.
-
Description: Provide a brief description of the collection.
Click on "Save" to finalize the collection.
Moving Mocks into a Collection:
Once the collection is created, you can move mocks into it: