Azure Web App Contract-First

When developing web apps with Microsoft technology, the most easy approach is implementation first. With the introduction of Azure new opportunities arise. In this post I will describe a contract-first approach to develop web apps. Maybe, it’s not entirely correct to speak of contract first. My job was actually to create an OpenAPI definition for the service (aka Swagger file) and create a stub service to have a testable endpoint on short notice.

First off, you will have to create the Swagger file. You can use a Swagger Editor for help. After you have this Swagger file, you can create a new API via API Management by clicking on tile OpenAPI.

As you can see from the above screenprint, you don’t have to specify a backend URL. What we are going to do next, is add a Mock Responses policy to the Inbound Processing section. Here we can specify which response to return.

If you like, you can change the response to return, to get something useful.

That’s it!