Mocking an API Using SwaggerHub
Explore how to create and test API prototypes by mocking APIs in SwaggerHub. Understand using the OpenAPI server element to enable mock services for verifying endpoints and simulating write operations without actual data changes. Gain hands-on experience testing APIs via UI and command-line tools.
We'll cover the following...
Mocking an API
Mocking an API is our chance to see a working version of the API up and running. SwaggerHub has a built-in API mocking service. It reads our OAS document and uses the definitions (and the example values) in that document to set up a mock API server that we can use to test against. As we’ve seen previously, the real value of an API prototype is that it allows us to test out the interface. Mocks are an excellent way to do that.
Adding the server element to an OAS document
To get the SwaggerHub API mock up and running, we need to make sure we have a server element in our OAS document that points to the SwaggerHub virtserver. It is turned ...