Swagger not working in 4.2.0
See original GitHub issueGreetings:
Today I noticed there was a new version of this awesome library and installed it right away. Just after that my API refused to start, giving me this trace error:
System.ArgumentNullException: Value cannot be null. (Parameter 'provider')
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.CreateScope(IServiceProvider provider)
at FastEndpoints.Swagger.ValidationSchemaProcessor..ctor()
at FastEndpoints.Swagger.Extensions.EnableFastEndpoints(AspNetCoreOpenApiDocumentGeneratorSettings settings, Int32 tagIndex, Int32 maxEndpointVersion, Boolean shortSchemaNames)
at FastEndpoints.Swagger.Extensions.<>c__DisplayClass2_0.<AddSwaggerDoc>b__0(AspNetCoreOpenApiDocumentGeneratorSettings s)
at Microsoft.Extensions.DependencyInjection.NSwagServiceCollectionExtensions.<>c__DisplayClass0_0.<AddOpenApiDocument>b__0(AspNetCoreOpenApiDocumentGeneratorSettings settings, IServiceProvider services)
at Microsoft.Extensions.DependencyInjection.NSwagServiceCollectionExtensions.<>c__DisplayClass1_0.<AddOpenApiDocument>b__0(AspNetCoreOpenApiDocumentGeneratorSettings settings, IServiceProvider services)
at Microsoft.Extensions.DependencyInjection.NSwagServiceCollectionExtensions.<>c__DisplayClass3_0.<AddSwaggerDocument>b__0(IServiceProvider services)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite enumerableCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.AspNetCore.Builder.NSwagApplicationBuilderExtensions.UseOpenApiWithApiExplorerCore(IApplicationBuilder app, Action`1 configure)
at Microsoft.AspNetCore.Builder.NSwagApplicationBuilderExtensions.UseOpenApi(IApplicationBuilder app, Action`1 configure)
at Program.<Main>$(String[] args)
The execution stops at: app.UseOpenApi();
If I remove:
app.UseOpenApi();
app.UseSwaggerUi3();
the api starts and works just fine, this is swagger related only, I think.
Maybe the fault is in my end? Going back to 4.1.0 fixes the problem without changing any code.
Best Regards.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Swagger is not compatible with Spring 4.2.3 · Issue #1055
I've just updated my spring-boot 1.3.0.RC1 ( also 1.3.0.RELEASE ) app to Spring 4.2.3, and having io.springfox springfox-swagger2 2.2.2.
Read more >Added Springfox Swagger-UI and it's not working, what am ...
Adding / at the end of url for swagger-ui worked for me. – Abhishek. Dec 10, 2020 at 17:21.
Read more >Setting Up Swagger 2 with a Spring REST API
In this tutorial, we'll look at Swagger 2 for a Spring REST web service, using the Springfox implementation of the Swagger 2 specification....
Read more >Swagger causing conflicts with other JS libraries
While Swagger and the Swagger UI are working without issue, it has somehow caused conflicts with the node UI application, causing many JS ......
Read more >Swagger RESTful API Documentation Specification
A flag to note whether the container allows duplicate values or not. If the value is set to true , then the array...
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 FreeTop 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
Top GitHub Comments
Yeah, I think is there
@desarrollo-ctme & @wjax i believe i’ve figured out what’s happening. most likely you’re calling
app.UseOpenApi()
before callingapp.UseFastEndpoints()
like so:i will add better checks against this and throw a proper error message when the pipeline is configured incorrectly like this.
if that doesn’t solve it for you, please do a repo that has the problem so we can clone it and debug.
thanks!