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

Fix hot reload for Swagger documentation #230

Merged
merged 1 commit into from
May 18, 2022
Merged

Conversation

catalingoran
Copy link
Contributor

Issue #224 - Fix Swagger documentation hot reload.

Issue details:
Hi @Burgyn , it seems that we still have an issue here. The hot reload is working now, the ocelot.json is reloaded and all the endpoints are accessible trough the Ocelot gateway. But the swagger documentation for all "hot reloaded" endpoints is not accessible. We can see it in the endpoint list in swagger but after selecting it the page is not loading and we receive a 500 response.

PS. If we restart the Ocelot service, swagger is accessible for hot reloaded endpoints.

Do you have any ideas? Thank you!

Later edit:
We observed that SwaggerEndpointRepository contains _swaggerEndPoints and _swaggerEndpointsOptions. It seems that _swaggerEndPoints it's not updated and contains 12 endpoints (old value before hot reload) and swaggerEndpointsOptions contains the correct number of endpoints after hot reload (13).
image

Info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/2 GET https://localhost:33555/swagger/docs/v4.0/batches - -
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HMHNT5C1AJVQ", Request id "0HMHNT5C1AJVQ:0000000B": An unhandled exception was thrown by the application.
System.Collections.Generic.KeyNotFoundException: The given key '/batches' was not present in the dictionary.
at System.Collections.Generic.Dictionary2.get_Item(TKey key) at MMLib.SwaggerForOcelot.Repositories.SwaggerEndPointProvider.GetByKey(String key) at MMLib.SwaggerForOcelot.Middleware.SwaggerForOcelotMiddleware.GetEndPoint(String path, ISwaggerEndPointProvider swaggerEndPointRepository) at MMLib.SwaggerForOcelot.Middleware.SwaggerForOcelotMiddleware.Invoke(HttpContext context, ISwaggerEndPointProvider swaggerEndPointRepository, IDownstreamSwaggerDocsRepository downstreamSwaggerDocs) at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication1 application)
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]

Issue Burgyn#224 - Fix Swagger documentation hot reload.
@update-docs
Copy link

update-docs bot commented May 17, 2022

Thanks for opening this pull request! If you have implemented new functions, write about them in the readme file.

@Burgyn Burgyn merged commit cff9687 into Burgyn:master May 18, 2022
@Burgyn
Copy link
Owner

Burgyn commented May 18, 2022

Thanks. This change will be released in a few minutes in version 5.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants