首页 > 解决方案 > Autogenerate OpenAPI documentation with Azure Functions

问题描述

is it possible to auto-generate OpenAPI documentation with Azure Functions e.g. like how it's possible with the SwaggerGen when using Swashbuckle with ASP .NET Core? The documentation should contain the different endpoints with their possible input and response models and StatusCodes. It would be awesome if I could view the docs in a web ui.

At the moment, I found two possible packages:

  1. A Swashbuckle Adaption for Azure Functions: https://github.com/vitalybibikov/AzureExtensions.Swashbuckle
  2. An official OpenAPI Extension from Microsoft: https://github.com/Azure/azure-functions-openapi-extension

With the first one, it's only possible to detect my models/DTOs and the different endpoints. But the relation between endpoints and models and the possible response codes have to be manually set by attributes on the several functions.

For the second one, there is no auto-detection at all. Everything only works with attributes. Additionally the package is still in preview.

标签: c#.netazure-functionsswaggeropenapi

解决方案


根据微软官方文档(现在不在预览版中),您可以通过使用在 Azure Functions 上启用 OpenAPI Endpoints

仅限进程内模型进程外模型

通过使用文档中提到的扩展,我们可以生成 OpenAPI 文档。


推荐阅读