Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.InvalidOperationException for XmlCommentsParameterFilter #2747

Open
sgoldberg16 opened this issue Dec 4, 2023 · 5 comments
Open

System.InvalidOperationException for XmlCommentsParameterFilter #2747

sgoldberg16 opened this issue Dec 4, 2023 · 5 comments
Labels
needs-repro A minimal reproducible example is needed

Comments

@sgoldberg16
Copy link

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

@KothariDhrumil
Copy link

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

@KothariDhrumil
Copy link

image

@Havunen
Copy link

Havunen commented Feb 17, 2024

@martincostello
Copy link
Collaborator

martincostello commented Apr 14, 2024

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

The activation call comes from here:

return (TFilter)ActivatorUtilities
.CreateInstance(_serviceProvider, filterDescriptor.Type, filterDescriptor.Arguments);

The constructor receives a single XPathDocument:

Which is provided as the argument here:

swaggerGenOptions.ParameterFilter<XmlCommentsParameterFilter>(xmlDoc);

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

@martincostello
Copy link
Collaborator

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 martincostello added the needs-repro A minimal reproducible example is needed label Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-repro A minimal reproducible example is needed
Projects
None yet
Development

No branches or pull requests

4 participants