azure-functions-openapi-extension icon indicating copy to clipboard operation
azure-functions-openapi-extension copied to clipboard

updated cli tool to be used to generate openapi document

Open Nibell opened this issue 3 years ago • 6 comments

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 avatar Dec 16 '21 09:12 Nibell

CLA assistant check
All CLA requirements met.

ghost avatar Dec 16 '21 09:12 ghost

@Nibell Thanks for the PR! I'll take a look and get back to you.

justinyoo avatar Feb 09 '22 09:02 justinyoo

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.

Fazer01 avatar Mar 01 '22 20:03 Fazer01

Updated pr to .net 6 @justinyoo

Nibell avatar Mar 06 '22 10:03 Nibell

@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 avatar Mar 28 '22 03:03 justinyoo

@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 avatar May 03 '22 18:05 ThomasBleijendaal

@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?

coolhome avatar Aug 31 '22 18:08 coolhome

As the PR, #489, has been merged, you can generate the OpenAPI doc on-the-fly, within the GitHub Actions workflow.

justinyoo avatar Sep 20 '22 07:09 justinyoo

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.

JeroenvdBurg avatar Sep 09 '23 11:09 JeroenvdBurg