Docsright arrowBlackbirdright arrowMock Quickstart

3 min • read

Mock Quickstart

In this tutorial, we'll be creating a mock server of an API in our catalog using the Blackbird CLI

Before you get started

This tutorial assumes you have already have the Blackbird CLI installed and have an entry in our API catalog. If not, please download the Blackbird CLI by following the Getting Started guide and follow the API Quickstart Guide. If you haven't done those already, you should do so now.

Once we have the Blackbird CLI downloaded and an entry in our API catalog we can begin mocking our API.

1. Creating a Mocked Instance

Now that we have an entry in our API catalog, we can create a mock server using the mock create command.

This command may take a few seconds while our environment gets set up and the mock instance gets created.

Once the mock instance is ready, we should see an output with a hostname. This mocked hostname will be our new endpoint for this instance.

2. Listing a Mocked Instance

Once our Mock instance is created, we can view it using the mock list or instance list command.

3. Using our Mocked Instance

We can now send a request to our mocked instance to test the behavior. For the purposes of this tutorial we will use curl.

We should be returned with a message. Note that the value of the message is generated with a nonsense string. Similarly, if the value was expected to be an integer, we can expect a random integer.

4. Configuring our Mocked Instance

Your mock instance will have a default configuration that will generate random data based on the schema objects defined in the OpenAPI specification. If you have examples defined throughout your OpenAPI specification, you might want to disable the dynamic data generation.

You can do this by using mock config <mock-name> set command.

To preview the configuration of your mock instance, you can use the mock config <mock-name> get command.

At the moment, dynamic is the only configuration value that can be set.

5. Next Steps

Now that we have a working mocked instance and know what the outputs of our requests look like, the next step would be to generate a project using our API.

The next step in our tutorial should be to generate code. Please follow the Code Quickstart Guide.

6. Deleting our Mocked Instance

Once we are done using our mocked instance, we can spin down the environment and clean up our resources with the mock delete command.