Guides
Mock APIs
Mock APIs
Introduction
Skyramp saves you time chasing dependencies by making it easy to mock internal and external APIs and services, giving you precise control over the dependencies you need or services you want to isolate. You can define mock responses for specific endpoints and customize individual response values in JSON payloads.
1. Initializing Endpoints
Start by defining endpoint objects, encapsulating details like name, port, and endpoint path. For instance, defining an endpoint for a REST service:
2. Defining Mock Responses
Specify mock responses for each endpoint, creating response values for different methods. Example for a POST method request to /artists
:
3. Applying Mock Responses
Apply mock responses to the running service in Docker or Kubernetes using Skyramp’s DockerClient or KubernetesClient objects. Example with Docker:
4. Overriding Response Values
Override individual response values for fields in JSON payloads. Example:
What's Next
Explore dynamic mock generation with Skyramp’s terminal client mocker generate
command. Automate mock data creation to save time and effort. Learn more about generating mocks here.