Empty swagger when using v0.9.0 with solution that includes a test project
See original GitHub issueDocumentation / Feature Proposal The fix in https://github.com/Azure/azure-functions-openapi-extension/pull/217 to detect the root project has definitely resolved some of the issues with the generated swagger document being empty.
However immediately after upgrading to v0.9.0-preview, using .NET 5 isolated functions, our swagger was empty when our function app was built and deployed from Azure Pipelines. The root cause turned out to be that the fix in #217 was treating our test project as the root project. I suppose this is technically correct since the test project referenced all our other projects.
We were able to work around the issue by updating the build task in our Azure Pipelines yaml file to skip building test projects, so there was no .deps.json
produced to be incorrectly detected as the root project.
- task: DotNetCoreCLI@2
displayName: Build project
inputs:
projects: |
**/*.csproj
!**/*Test.csproj
I thought I’d raise this issue in case anyone else was still having problems with empty swagger, and to propose either of the following solutions to help prevent others encountering the same problem:
- A documentation update to explicitly state that test projects should not be built for swagger generation to work
- A feature that the root project detection should ignore test projects
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:7 (1 by maintainers)
Top GitHub Comments
Facing the same issue here, using 3.1 Functions and 0.9.0
Looking over #217, it would be a little slower but I’d suggest to load the discovered runtimes and scan for an assembly attribute e.g.
OpenApiRootAttribute
, to allow developers to override the automatic discovery behaviour.The current situation feels problematic. What about scenarios where you have to build and deploy tests, have anyone found other workarounds?