Skip to content

updated cli tool to be used to generate openapi document #337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed

updated cli tool to be used to generate openapi document #337

wants to merge 9 commits into from

Conversation

Nibell
Copy link

@Nibell Nibell commented Dec 16, 2021

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

@ghost
Copy link

ghost commented Dec 16, 2021

CLA assistant check
All CLA requirements met.

@Nibell Nibell marked this pull request as draft December 26, 2021 11:59
@Nibell Nibell marked this pull request as ready for review December 26, 2021 12:00
@justinyoo
Copy link
Contributor

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

@Fazer01
Copy link

Fazer01 commented Mar 1, 2022

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.

@Nibell
Copy link
Author

Nibell commented Mar 6, 2022

Updated pr to .net 6 @justinyoo

Copy link
Contributor

@justinyoo justinyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nibell Thanks for the long wait! It looks awesome! I left several comments for structuring.

As it's completely re-written, I need to take further look. Can you also make sure that it doesn't throw an error but shows the help message when it is run by itself, meaning azfuncopenapi.exe with no arguments?

Comment on lines +6 to +12
public class ApiMock
{
public string CompiledPath { set; get; }
public string CompiledDllPath { set; get; }
public HttpSettings HttpSettings { set; get; }
public OpenApiInfo OpenApiInfo { set; get; }
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put XML comments on the class and each property?

Copy link
Contributor

@justinyoo justinyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nibell I'm still experiencing the exception when I run this app with NO argument.

azfuncopenapi.exe

Could you double check for this?

@justinyoo
Copy link
Contributor

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

@ThomasBleijendaal
Copy link
Contributor

ThomasBleijendaal commented May 3, 2022

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

@coolhome
Copy link

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

@justinyoo
Copy link
Contributor

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

@justinyoo justinyoo closed this Sep 20, 2022
@justinyoo justinyoo added this to the Release 202209 - v1.5.0 milestone Sep 20, 2022
@Nibell Nibell deleted the cli-refactor branch September 20, 2022 08:25
@JeroenvdBurg
Copy link

JeroenvdBurg commented Sep 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI not working due to an unconfigured mock
6 participants