- Print
- DarkLight
- PDF
Azure Functions and in code Open API Configuration
- Print
- DarkLight
- PDF
Azure Functions now support the code time open API documentation for the HTTP endpoints through the use of the Azure Functions OpenAPI Extension. You need to install the Microsoft.Azure.WebJobs.Extensions.OpenApi nuget package.
You can then add the general API details using the IOpenApiConfigurationOptions as shown in following screenshots
You can then register the configuration options in the Startup class as shown below
In order to define the APIs represented by the HTTP Triggered Azure Functions, each functions needs to be decorated with several attributes which define the request response bodies, status codes etc.
Once you run/deploy function app, you will see that there some extra functions that are deployed along with the azure functions that you write. Following screenshot illustrates the same
The Open definition can now be accessed using the RenderSwaggerUI endpoint. Sample shown below
You can now configure the OpenAPIConfigurationOptions and functions decorations as required, more details can be found at Azure Functions Open API Extension. It should be noted that when you use this option, you will deploying extra azure functions which will incur some extra billing.