Closed gabrielbaptista closed 7 months ago
Hi @gabrielbaptista
There are no details for this one, please provide a repo or something more.
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.
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?
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 That worked. Swashbuckle.Annotations was in another package. Thank you!
@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.
So we just ran into this now, for us we had 2 packages installed.
Removing Swashbuckle.AspNetCore solved the issue for us.
Closing this, as not relevant, please reopen if needed
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 ...