Azure / azure-functions-openapi-extension

This extension provides an Azure Functions app with Open API capability for better discoverability to consuming parties
https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.OpenApi/
MIT License
375 stars 196 forks source link

Generate OpenApi swagger at build time. #650

Open davidpetric opened 9 months ago

davidpetric commented 9 months ago

Description

I am wondering if there is a way to generate the swagger file at BUILD time from OpenApi attributes.

We are working on a project that involves a lot of Azure Functions and we use NSwag to generate HttpClients for them. However, we have to do this manually every time because we need to run the functions and get the OpenAPI document first.

Is there a better solution for this? I would appreciate any suggestions or tips. Thank you very much.

tomkuijsten commented 9 months ago

I'm searching for the exact same thing. I did not find anything yet, there is pipeline support which does something related:

https://github.com/Azure/azure-functions-openapi-extension/blob/main/docs/generic-cicd-pipeline-support.md

Another thing I've tried is the nswag aspnetcore2openapi command, but that is barely documented and used. Couldn't get it to work properly on my function project.

https://github.com/RicoSuter/NSwag/wiki/AspNetCoreToOpenApiCommand

Another option seems to be OpenApiReference, but after a few tries, this doesn't seem to be the answer here as well.

https://learn.microsoft.com/en-us/aspnet/core/web-api/microsoft.dotnet-openapi?view=aspnetcore-6.0