Mocking Your API

Mocking your API is your chance to see a working version of the API up and running. SwaggerHub has a built-in API mocking service. It reads your OAS document and uses the definitions (and the example values) in that document to set up a mock API server that you can use to test against. As you may recall from the early part of this chapter in Working Prototypes, the real value of an API prototype is that it allows you to test out the interface, and mocks are an excellent way to do that.

To get the SwaggerHub API mock up and running, you need to make sure you have a server element in your OAS document that points to the SwaggerHub virtserver. We turned it on when we created our OAS file, but you can also add it later by clicking ...

Get Design and Build Great Web APIs now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.