azure-functions-openapi-extension
                                
                                 azure-functions-openapi-extension copied to clipboard
                                
                                    azure-functions-openapi-extension copied to clipboard
                            
                            
                            
                        updated cli tool to be used to generate openapi document
Changes proposed in this pull request:
- Updated to working cli to generate openapi document and handle multiple versions
Have not added build to generate console app, but added support for win, linux and mac os Resolves #303, #305 Ready for review @justinyoo
@Nibell Thanks for the PR! I'll take a look and get back to you.
Hi @Nibell! Nice one on the refactor to integrate working CLI tooling to generate swagger file. Currently we use Azure Functions v3 and are searching for a good way to generate the swagger file after building the function-app to incorporate automatic updates to the APIM we also use. I stumbled upon this PR which was opened for issue #303 a while ago.
Now we wait for @justinyoo to get back to you.
Updated pr to .net 6 @justinyoo
@Nibell Here's what I ran:
azfuncopenapi.exe -p "C:\path\to\functionapp" -v v3
But I get the exception:
Could not load file or assembly 'Microsoft.Azure.WebJobs, Version=3.0.23.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Can you reproduce this error on your end? The function app path is completely outside this repo.
@justinyoo I can reproduce the error (Microsoft.Azure.WebJobs version 3.0.31 is missing).
There is a stray package reference in the CLI's csproj (<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.5" />). If I update that to 3.0.31 it fixes that error, but I get
Could not load file or assembly 'Microsoft.Azure.WebJobs.Extensions.Http, Version=3.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
after that. It looks like some dependencies are not loaded into memory. I don't think it is a good idea to add those missing items as package as it tightly couples the CLI tool with the exact versions used by the function app of which the open api docs are generated.
I've done some additional testing on this PR, and found that it currently only supports out-of-process functions. Adding support for in-process functions is quite easy, but this assembly error is quite the challenge. The code loads all the assemblies from the function app it analyzes, but somehow Microsoft.Azure.WebJobs (and a few extension assemblies) cannot be loaded even though the bin folder of the function app has the correct dll. By adding all the missing assemblies as nuget package the problem goes away, but then those assembly versions are pinned.
@ThomasBleijendaal
To fix the out-of-process/in-process coupling would it make sense to make Microsoft.Azure.Functions.Worker.Extensions.OpenApi.Cli for Out-of-process?
As the PR, #489, has been merged, you can generate the OpenAPI doc on-the-fly, within the GitHub Actions workflow.
I think it is really a pitty that this PR has been closed. We would definitly use it, the on the fly generation with the script starting the function app and downloading the swagger.json really feels cumbersome.
@justinyoo could you consider re-opening this and make it only support out-of-proc functions? As with the new azure function roadmap the webjobs functions are not supported in the future anyway.