Adding Swagger UI Documentation to Azure Function APIs
You can set up Swagger UI in your Azure Function API to allow for providing documentation for your serverless API pretty easily.
Initial Configuration
First, add the SwashBuckle library to your process via the .csproj file:
Next set up the SwashBuckle startup code in SwashBuckleStartup.cs
:
Now create both HTTP Triggers for the Swagger document:
And the Swagger UI document:
Running this locally will provide two endpoints:
The final step for initial configuration is changing the documentation for the API page. Add the following to host.json
:
Which will give you:
Further Reading:
https://medium.com/@yuka1984/open-api-swagger-and-swagger-ui-on-azure-functions-v2-c-a4a460b34b55