Azure / Azure/azure-functions-openapi-extension

Error Generating swagger.json running functions locally. Missing Microsoft.Azure.WebJobs

Open
#216 2 comments 0 reactions 0 assignees View on GitHub
Needs: Triage (Functions)
Dominant language
C#
Stars
388
Forks
202
PR merge metrics
No merged PRs in 30d

Description

Hi,

using package `Include="Microsoft.Azure.WebJobs.Extensions.OpenApi" Version="0.8.1-preview"`
I tried to create a basebones setup defining openapi config (to force v3) and one operation.

No errors are thrown when building and starting the local function, however when i try to load the swagger.json i get a message `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.`
I checked the folder containing the dlls (bin\Debug\netcoreapp3.1\) and this file is present.

*setup.cs*
``` c#
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums;
using Microsoft.OpenApi.Models;
...
public class OpenApiConfigurationOptions : IOpenApiConfigurationOptions
{
public OpenApiVersionType OpenApiVersion { get; set; } = OpenApiVersionType.V3;
public OpenApiInfo Info { get; set; } = new OpenApiInfo()
{
Version = "1.0.0",
Title = "My API",
Description = "API for getting, setting and invoking actions",
Contact = new OpenApiContact()
{
Name = "me",
Email = "me@company.com"
// Url = new Uri("https://github.com/Azure/azure-functions-openapi-extension/issues"),
},
};
public bool IncludeRequestingHostName { get;set;}
public List Servers { get;set;} = new List();
}
```

*some.api.cs*
``` c#
using Microsoft.Azure.WebJobs.Extensions.OpenApi;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums;
...
[FunctionName(nameof(invokeApi.invoke_getById))]
[OpenApiOperation(
operationId: "getById",
tags: new[] { "name" },
Summary = "Gets action by id",
Description = "This gets the name.",
Visibility = OpenApiVisibilityType.Important
)]
.... function code...
```

local.settings.json
``` json
{
"OpenApi__HideSwaggerUI": false,
"OpenApi__ApiKey": "",
"OpenApi__AuthLevel__Document": "Anonymous",
"OpenApi__AuthLevel__UI": "Anonymous"
}
```

LOG:
```
Executing HTTP request: {
requestId: "4ecf1571-9796-4b28-9eb2-c0c9e871b207",
method: "GET",
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36",
uri: "/api/swagger.json"
}
Request successfully matched the route with name 'RenderSwaggerDocument' and template 'api/swagger.{extension}'
Executing 'Functions.RenderSwaggerDocument' (Reason='This function was programmatically called via the host APIs.', Id=e8de6a65-512d-47b1-bd1d-675c7ebeeacf)
swagger.json was requested.
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.
Executed 'Functions.RenderSwaggerDocument' (Succeeded, Id=e8de6a65-512d-47b1-bd1d-675c7ebeeacf, Duration=754ms)
Executed HTTP request: {
requestId: "4ecf1571-9796-4b28-9eb2-c0c9e871b207",
identities: "",
status: "500",
duration: "864"
}
```

Contributor guide

Open the contributing guide

Research direction

Start with setup.cs, some.api.cs, and local.settings.json, then reproduce the GET request to /api/swagger.json using Microsoft.Azure.WebJobs.Extensions.OpenApi 0.8.1-preview. Check the local function runtime and assembly loading for Microsoft.Azure.WebJobs, including the netcoreapp3.1 output folder. Done means the Swagger endpoint returns its document without the missing-assembly error.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp, openapi
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.