Generated Swagger is Empty
See original GitHub issueI have an existing .NET 6 Project I’ve been working on, and I decided to add the OpenAPI Extension and generate a swagger, however the swagger generated is empty. I have cleaned and rebuilt, I have deleted obj and bin, I have tried everything, but my same functions copied to another project work just fine, but for some reason in this project, which has no build errors whatsoever (with all trace logs on), continues to generate an empty swagger.json.
CSPROJ:
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<AssemblyName>myname.Functions</AssemblyName>
<RootNamespace>myname.Functions</RootNamespace>
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
<DocumentationFile>myname.Functions.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.OpenApi" Version="0.7.2-preview" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.12.2" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" />
<PackageReference Include="Microsoft.OpenApi.CSharpAnnotations.DocumentGeneration" Version="2.0.0-beta02" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.12.2" />
</ItemGroup>
One of my test functions:
{
[FunctionName("OpenAPI")]
[OpenApiOperation(operationId: "Run", tags: new[] { "name" })]
[OpenApiParameter(name: "name", In = ParameterLocation.Query, Required = true, Type = typeof(string), Description = "The Name parameter")]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "text/plain", bodyType: typeof(string), Description = "The OK response")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;
string responseMessage = string.IsNullOrEmpty(name)
? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
: $"Hello, {name}. This HTTP triggered function executed successfully.";
return new OkObjectResult(responseMessage);
}
}
Generated Swagger.Json:
{
"swagger": "2.0",
"info": {
"title": "Azure Functions OpenAPI Extension",
"version": "1.0.0"
},
"host": "localhost:7071",
"basePath": "/api",
"schemes": [
"http"
],
"paths": { }
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Swagger api listing is empty
My assumption is swagger couldn't scan my api list from Resource package. But could not figure out which configuration or which code snippet...
Read more >Generating empty spec · Issue #1350 · go-swagger/ ...
Problem statement When I call swagger on a package, foo it does not do anything. I have annotations like: // Package main Mytitle....
Read more >parameter still generated even if empty in openapi: 3.0.1
Hello, i have an issues with is with generating an empty parameter when using openapi: 3.0.1. so here are 2 snipets (you can...
Read more >Get started with Swashbuckle and ASP.NET Core
SwaggerGen : a Swagger generator that builds SwaggerDocument objects directly from your routes, controllers, and models.
Read more >A blank path prevents Swagger from working in the API ...
... Editor to be empty but the Swagger specification does not allow the corresponding property to be empty, so the generated Swagger document...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think this issue similar https://github.com/Azure/azure-functions-openapi-extension/pull/217 There is a bug and fixed recently but not deployed now.
@VTR-AReed How many
*.deps.json
files does yourDebug/net6.0/
orDebug/net6.0/bin
directory have? If there are multiple*.deps.json
files, it’s causing the issue.Could you confirm that on your end?