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

System.InvalidOperationException for XmlCommentsParameterFilter

Open sgoldberg16 opened this issue 1 year ago • 5 comments

I am having the following exception throw after upgrading to .Net8: System.InvalidOperationException: A suitable constructor for type 'Swashbuckle.AspNetCore.SwaggerGen.XmlCommentsParameterFilter' could not be located. Ensure the type is concrete and all parameters of a public constructor are either registered as services or passed as arguments. Also ensure no extraneous arguments are provided.

Any initial thoughts or suggested fixes would be appreciated! Using Swashbuckle.AspNetCore 6.5.0 Using Swashbuckle.AspNetCore.SwaggerUI 6.5.0 Using Swashbuckle.AspNetCore.SwaggerGen 6.5.0 Using Swashbuckle.AspNetCore.Swagger 6.5.0

sgoldberg16 avatar Dec 04 '23 21:12 sgoldberg16

I am also facing the same when I am publishing this on IIS. in local its working fine.

KothariDhrumil avatar Dec 11 '23 14:12 KothariDhrumil

image

KothariDhrumil avatar Dec 11 '23 14:12 KothariDhrumil

Have you tested with https://github.com/Havunen/DotSwashbuckle https://www.nuget.org/packages/DotSwashbuckle.AspNetCore

Havunen avatar Feb 17 '24 15:02 Havunen

It's not obvious to me at first glance why this wouldn't be working.

The activation call comes from here:

https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/830c5a6f7468bce6b716d84c034a258dbbcbfe98/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/ConfigureSwaggerGeneratorOptions.cs#L76-L77

The constructor receives a single XPathDocument:

https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/830c5a6f7468bce6b716d84c034a258dbbcbfe98/src/Swashbuckle.AspNetCore.SwaggerGen/XmlComments/XmlCommentsParameterFilter.cs#L11

Which is provided as the argument here:

https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/830c5a6f7468bce6b716d84c034a258dbbcbfe98/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenOptionsExtensions.cs#L433

It might be related to this breaking change in .NET 8.

martincostello avatar Apr 14 '24 08:04 martincostello

Having updated Swashbuckle to target net8.0, I can't replicate this with our test suite.

Please provide a minimal reproducible example as a GitHub repository that demonstrates the issue you're experiencing so we can look into this further.

martincostello avatar Apr 14 '24 13:04 martincostello

This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.

github-actions[bot] avatar Jun 20 '24 01:06 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Jul 12 '24 01:07 github-actions[bot]