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
370 stars 194 forks source link

Not supporting Microsoft.Azure.Functions.Worker.Sdk version 1.16.0 #625

Closed Strandfelt closed 1 week ago

Strandfelt commented 11 months ago

Describe the issue When upgrading the Microsoft.Azure.Functions.Worker.Sdk package to 1.16.0 which was released on November 7, the Open API is not able to generate if there are HTTP triggers.

It is worth to note that in a vanilla function project with NO triggers, the documents will actually be rendered, but when you add an HTTP triggered function to the project, the Open API endpoints will vanish.

To Reproduce Steps to reproduce the behavior:

  1. Create vanilla dotnet-isolated Azure Function referencing Microsoft.Azure.Functions.Worker.Sdk 1.15.1 without any Functions
    • E.g. func init MyOpenApiFunctionApp --worker-runtime dotnetIsolated --target-framework net7.0
  2. Add Microsoft.Azure.Functions.Worker.Extensions.OpenApi 1.5.1
  3. See that Open API documents are generated (with no Function routes)
  4. Upgrade Microsoft.Azure.Functions.Worker.Sdk to 1.16.0
  5. See that Open API documents are generated (with no Function routes)
  6. Add an HTTP triggered function with Open API attributes
  7. See that Open API documents are no longer generated
  8. Downgrade Microsoft.Azure.Functions.Worker.Sdk to 1.15.1
  9. See that Open API documents are generated again (now with Function routes)

Expected behavior Open API documents are generated for a Functions project referencing Microsoft.Azure.Functions.Worker.Sdk package to 1.16.0 when there are triggers in the project

Environment (please complete the following information, if applicable):

nserpen commented 11 months ago

This issue also exists in net6.0. Spend couple of hours to fix and find out what I did wrong. It happens exactly as in the above description.

Bitguru72 commented 11 months ago

I can confirm the same issue in 1.16.0, and as well in 1.16.1. Rolling back to 1.15.1 solves the issue and the http trigger endpoints for OpenAPI reappears. On .net7 and v4 and Windows. All other nugets on latest versions.

Bitguru72 commented 11 months ago

So, I've discovered more details about the issue. Since the referenced assembly, that holds the OpenAPI, contains the function http triggers and the old behaviour of the Microsoft.Azure.Functions.Worker.Sdk was to scan ALL assemblies for functions, internal or public, and register them it worked fine. I have my own set of nugets, that contain internal function triggers (timers). They also dissappear with the 1.16.0 SDK. So, the issue has nothing to do with the http or OpenAPI, but seems to be a change in scanning/discovery of triggers in other assemblies than the "main assembly".

NFMynster commented 11 months ago

Can also confirm the issue with Microsoft.Azure.Functions.Worker.Sdk 1.16.x where 1.15.1 works.

Revnixcad commented 10 months ago

irm the issue with Microsoft.Azure.Functions.Worker.Sdk 1.16.x where 1.15.1 works.

For me this is also the case

LukeMcHaleJones-Jacobs commented 10 months ago

Just ran into this. Can confirm also - have had to downgrade to 1.15.1. Well done for opening this @Strandfelt.

kshyju commented 10 months ago

Please see https://github.com/Azure/azure-functions-dotnet-worker/issues/2052#issuecomment-1808913371

Revnixcad commented 10 months ago

Please see Azure/azure-functions-dotnet-worker#2052 (comment)

Yes this release works for me, thank you for the fast implementation of the solution.

nserpen commented 10 months ago

Yes, 1.16.2 release solves the problem. Thank you.

verdantburrito commented 10 months ago

This issue should be closed, since it's a problem that doesn't originate in this repo's code.