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 ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.