Azure / Azure/azure-functions-openapi-extension
Missing dependencies in *.deps.json leads to Object reference not set to an instance of an object
- Dominant language
- C#
- Stars
- 388
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
I receive an `object reference` error if my function app references a project that has no dependencies.
**To reproduce**
1. `git clone https://github.com/justinyoo/azfunc-openapi-dotnet.git`
2. `cd azfunc-openapi-dotnet`
3. `dotnet new classlib -o domain`
4. `cd Net60.FunctionApp.OutOfProc.Static`
5. `dotnet add reference .\..\domain`
6. `dotnet add package Microsoft.Azure.Functions.Worker`
7. `dotnet add package Microsoft.Azure.Functions.Worker.Sdk`
8. `dotnet add package Microsoft.Azure.Functions.Worker.Extensions.Http`
9. `dotnet add package Microsoft.Azure.Functions.Worker.Extensions.OpenApi --prerelease`
10. `dotnet build` (you will need to fix some missing reference errors)
11. `func start`
12. go to [http://localhost:7071/api/swagger/ui](http://localhost:7071/api/swagger/ui)
**Error**
```
Object reference not set to an instance of an object.
at Microsoft.Azure.Functions.Worker.Extensions.OpenApi.OpenApiHttpTriggerContext.<>c.b__42_1(KeyValuePair`2 target)
at System.Linq.Utilities.<>c__DisplayClass2_0`3.b__0(TSource x)
at System.Linq.Enumerable.SelectListIterator`2.MoveNext()
at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
at Microsoft.Azure.Functions.Worker.Extensions.OpenApi.OpenApiHttpTriggerContext.GetRuntimeFilenameAsync(String functionAppDirectory)
at Microsoft.Azure.Functions.Worker.Extensions.OpenApi.OpenApiHttpTriggerContext.SetApplicationAssemblyAsync(String functionAppDirectory, Boolean appendBin)
at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions.OpenApiHttpTriggerContextExtensions.AuthorizeAsync(Task`1 context, IHttpRequestDataObject req)
at Microsoft.Azure.Functions.Worker.Extensions.OpenApi.Functions.OpenApiTriggerFunction.RenderSwaggerUI(HttpRequestData req, FunctionContext ctx)
```
**Environment**
- started from this repo https://github.com/justinyoo/azfunc-openapi-dotnet.git
- Microsoft.Azure.Functions.Worker.Extensions.OpenApi: 0.9.0-preview
**Additional context**
It seems to be related with #172 and fails if referenced project has no dependency in the `*.deps.json` file
Contributor guide
Assessment
This issue has not been assessed yet.