Closed rabdulatif closed 1 month ago
Hi @rabdulatif,
Please prepare a PR.
Thanks
Hi @Burgyn ,
The PR is ready and has been submitted. Please let me know if you need any further changes or clarifications.
Thanks
Fixed by #308
soon it will be published in version 8.3.1
.
I encountered an issue when using Ocelot's PollConsul service discovery provider with dynamic service registration from code. The ServiceHostAndPort retrieved from the PollConsul provider does not include the URI scheme, causing an exception when attempting to access the Swagger URI. The exception is due to the missing scheme, making the URI invalid.
Problem: When retrieving the ServiceHostAndPort using PollConsul, the scheme is missing. As a result, when trying to get the Swagger URI, an exception is thrown: "URI is not valid" because the scheme is empty. Routes are not defined in the ocelot.json file, as I am dynamically getting them. My ocelot.json configuration:
Fix: To resolve the missing scheme issue, I modified the SwaggerServiceDiscoveryProvider class in the GetSwaggerUri(...) method (after line 109). I added the following code to ensure the scheme is set properly:
With this change, the Swagger URI is now constructed correctly.
Additional Issue: After fixing the URI issue, I encountered another problem where the Swagger content was empty. Upon debugging, I noticed that the _transformer.Transform method clears the content when the ServiceProviderType is not Consul. However, my type is PollConsul.
Second Fix: I added a condition to also check for PollConsul, and it resolved the issue:
if (SwaggerServiceDiscoveryProvider.ServiceProviderType != "Consul" && SwaggerServiceDiscoveryProvider.ServiceProviderType != "PollConsul") { // original logic }
Can I submit a PR? I'd like to contribute this fix via a pull request as I need to deploy my project to the server soon