AzureExtensions.Swashbuckle icon indicating copy to clipboard operation
AzureExtensions.Swashbuckle copied to clipboard

Update from 3.1.6 to 3.3.2 caused a crash at CreateSwaggerJsonDocumentResponse method

Open gabrielbaptista opened this issue 3 years ago • 7 comments

We are currently using the extension AzureExtensions.Swashbuckle for Azure Function API and, as soon as we update to the new 3.3.2 version we have an Exception thrown indicating the Azure Function Method cannot be found. The only change we have made is substituting old CreateSwaggerDocumentResponse method to the new on.

Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: 'Failed to generate Operation for action ...

image

gabrielbaptista avatar Jun 04 '21 17:06 gabrielbaptista

Hi @gabrielbaptista

There are no details for this one, please provide a repo or something more.

vitalybibikov avatar Jun 22 '21 14:06 vitalybibikov

i think what is missing from this is that when calling the function [FunctionName("Swagger")] public static Task<HttpResponseMessage> Swagger( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "swagger/json")] HttpRequestMessage req, [SwashBuckleClient] ISwashBuckleClient swashBuckleClient) { return Task.FromResult(swashBuckleClient.CreateSwaggerJsonDocumentResponse(req)); }

It creates an exception like this: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: 'Failed to generate Operation for action - MyApiNameHere. See inner exception' Inner Exception MissingMethodException: Method not found: 'Void Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository..ctor()'.

($exception).InnerException.StackTrace:

at AzureFunctions.Extensions.Swashbuckle.SwashBuckle.Filters.QueryStringParameterAttributeFilter.Apply(OpenApiOperation operation, OperationFilterContext context) at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperation(ApiDescription apiDescription, SchemaRepository schemaRepository)

TargetSite: {Void Apply(Microsoft.OpenApi.Models.OpenApiOperation, Swashbuckle.AspNetCore.SwaggerGen.OperationFilterContext)}

nuget package version: Microsoft.OpenApi 1.2.3 AzureExtensions.Swashbuckle 3.3.2 Swashbuckle.AspNetCore.SwaggerGen 6.1.4 Microsoft.NET.Sdk.Functions 3.0.13

So I played around with this cause I was getting the same sort of error after upgrading to 3.3.2 from any version. I started a fresh project and installed 3.3.2 and it worked out of the box. so the upgrade process leaves behind some bad artifacts that causes some issues in the bin folder. I did a clean solution followed by a rebuild solution and basically nuked all the local packages and forced it to redownload all. Still didnt work. Then I took a look at the dependencies of the 3.3.2 package and noticed that I had one of its dependencies actually installed as a nuget package. I removed the nuget package for Swashbuckle.AspNetCore.SwaggerGen 6.1.4 out of my csproj file and rebuilt the solution again and poof! it magically worked.

you cannot have AzureExtensions.Swashbuckle 3.3.2 and Swashbuckle.AspNetCore.SwaggerGen 6.1.* installed side by side in the same project.

tavish-sullivan avatar Jul 14 '21 20:07 tavish-sullivan

I'm encountering the exact error mentioned by @tavish-sullivan, but Swashbuckle.AspNetCore.SwaggerGen 6.1.* isn't installed. I installed AzureExtensions.Swashbuckle 3.3.2 into an existing Function App project. I cleaned the project and rebuilt it to no avail. Anyone have any suggestions how to resolve this?

ScorpDiesel avatar Oct 15 '21 00:10 ScorpDiesel

I would look at your packages. Compare that with the dependencies for AzureExtensions.Swashbuckle 3.3.2. If you have any of these explicitly installed as a package you will run into issues cause it puts the assembly in different folders in the same project but you are using reflection to traverse the file system and you will get conflicts. If you do have the same assemblies in the bin folder your gonna have a bad time.

darrsull avatar Oct 15 '21 01:10 darrsull

@darrsull That worked. Swashbuckle.Annotations was in another package. Thank you!

ScorpDiesel avatar Oct 15 '21 12:10 ScorpDiesel

@vitalybibikov is there any plan to update to Swashbuckle 6.xx? It looks like a PR to do this (#81) was merged to dev 7 months ago.

royston-c-oa avatar Jan 24 '22 13:01 royston-c-oa

So we just ran into this now, for us we had 2 packages installed.

  • Swashbuckle.AspNetCore
  • We tried both 5.6.3 and 6.5.0 neither worked.
  • AzureExtensions.Swashbuckle

Removing Swashbuckle.AspNetCore solved the issue for us.

imrandyk avatar Jul 14 '23 15:07 imrandyk

Closing this, as not relevant, please reopen if needed

vitalybibikov avatar May 01 '24 21:05 vitalybibikov