Azure / Azure/azure-functions-openapi-extension

Empty swagger when using v0.9.0 with solution that includes a test project

Open
#306 8 comments 2 reactions 0 assignees View on GitHub
documentation
Dominant language
C#
Stars
388
Forks
202
PR merge metrics
No merged PRs in 30d

Description

**Documentation / 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

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the root-project detection change in PR #217 and the issue's .NET 5 isolated-function deployment scenario, including the Azure Pipelines build configuration. Reproduce generation with a solution containing a test project, then determine whether the accepted outcome is documentation about excluding test builds or changed root-project detection.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp, openapi
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.