

We basically create an Azure Function code that reads Swagger definition and render it as a response. If we only have Swagger definition document, not the actual implementation, what can we do with Azure Functions? Why not directly rendering Swagger document by Azure Function code? Render Swagger Definition via Azure Functions In other words, API design-first approach is not applicable. The Function instance must have at least one function endpoint so that the Swagger definition should be auto-generated. However, there is a critical point we have to bear in mind. Azure Functions instance automatically converts the YAML document to the JSON one. Easy, huh? Also the address specified in the middle of the picture,, allows us to access to the Swagger definition document in JSON format. Once we update the Swagger definition, we can test the API right away by providing function key code and payload. The actual document generated looks like: Now we’ve got the Swagger definition doco. Now, click the Generate API definition template button so that the document is automatically generated. Click the Functions button right next to it.īecause we have never generated the Swagger definition, it spits the error screen. Click the API definition (preview) tab.Īs a default, the External URL button is chosen. If we have at least a Function endpoint in our Function instance, we can automatically generate a Swagger definition in YAML format. Let’s create a Swagger definition document for those Functions. Here are simple requests and responses through Postman: Once we deploy them, we can find it from the Azure Portal like: Sample codes used for this post can be found here.įirst of all, with the sample code provided, we’re creating two HTTP triggers, CreateProduct and GetProduct. In this post, we will have a look how to enable Swagger support on Azure Functions. If we use Azure Functions as APIs, this will be very useful. Azure Functions Team has recently announced the Swagger support as a preview.
