Comments (10)
Hi, ist this on the roadmap for a future version or not on the radar at all right now?
Would love to have this feature since more and more services are hosted in some kubernetes cluster with dynamic configuration over a service discovery.
from mmlib.swaggerforocelot.
Unfortunally I can't open a branch and create a pull request, but basically the Scheme that comes back in the SwaggerServiceDiscoveryProvider class is null since K8s works with IPs only internally. So you would have to set this one manually depending on the port - like:
var scheme = service.Scheme;
if (string.IsNullOrEmpty(service.Scheme))
{
switch (service.DownstreamPort)
{
case 80:
scheme = Uri.UriSchemeHttp;
break;
case 443:
scheme = Uri.UriSchemeHttps;
break;
default:
break;
}
}
var builder = new UriBuilder(scheme, service.DownstreamHost, service.DownstreamPort);
builder.Path = endPoint.Service.Path;
However, It only works with the standard kube ocelot serviceDiscovery type - with pollkube I didn't manage to find a fix yet, but for now this would suffice for our use case - would need documentation though.
from mmlib.swaggerforocelot.
Hi,
Yes, I'm planning it for the next major release. But unfortunately I don't have as much time as I would have imagined.
from mmlib.swaggerforocelot.
Thank you for your investigation. I'll implement it tomorrow (and write unit tests).
To the future contribution. If you don't have perrmission for contribution to GitHub repository then:
- Fork GitHub repo
- Create branch
- Write implementation / tests / documentations / ...
- Commit / push to your forked repo
- Create Pull Request
from mmlib.swaggerforocelot.
Hi,
Unfortunately, this package does not currently support this scenario.
from mmlib.swaggerforocelot.
This feature is availabe in preview version 2.0.0-alpha.1
.
from mmlib.swaggerforocelot.
Very cool! Unfortunally it doesn't seem to work with kubernetes - neither with Ocelots PollKube where it doesn't find the service to connect too, nor with the normal "OnRequest" Provider where it can't build the Uri and throws and unhandled exception.
Stack Trace:
[15:54:10 ERR] Connection id "0HLTVH5MUK6FF", Request id "0HLTVH5MUK6FF:00000002": An unhandled exception was thrown by the application.
System.UriFormatException: Invalid URI: The URI scheme is not valid.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString)
at System.UriBuilder.get_Uri()
at MMLib.SwaggerForOcelot.ServiceDiscovery.SwaggerServiceDiscoveryProvider.GetSwaggerUri(SwaggerEndPointConfig endPoint, ReRouteOptions reRoute)
at MMLib.SwaggerForOcelot.ServiceDiscovery.SwaggerServiceDiscoveryProvider.GetSwaggerUriAsync(SwaggerEndPointConfig endPoint, ReRouteOptions reRoute)
at MMLib.SwaggerForOcelot.Middleware.SwaggerForOcelotMiddleware.GetEndPoint(String path, ISwaggerServiceDiscoveryProvider discoveryProvider)
at MMLib.SwaggerForOcelot.Middleware.SwaggerForOcelotMiddleware.Invoke(HttpContext context, ISwaggerServiceDiscoveryProvider discoveryProvider)
.
.
.
from mmlib.swaggerforocelot.
Hi, Thank you for your feedback. I apologize for the trouble.
I'll try to investigate and fix it. But unfortunately I have no experience with kubernetes. It would help me if you could prepare a demo for this problem for me.
from mmlib.swaggerforocelot.
Very good, thanks for the information.
I actually thought of a better possibility for getting the right URI Scheme - since we have to configure the DownstreamScheme in ocelot anyhow, we should just use that for the discovery instead of a switch on the used port.
from mmlib.swaggerforocelot.
It will be fixed in version 2.0.0-alpha.2
. Please check it.
Thanks for cooperation.
from mmlib.swaggerforocelot.
Related Issues (20)
- Swagger for YARP HOT 4
- Documentation -> o.GenerateDocsForGatewayItSelf HOT 1
- Getting 404 when running with KubernetesServiceDiscoveryProvider HOT 1
- Wrong Swagger url generated when using KubernetesServiceDiscoveryProvider HOT 1
- Failed to load API definition issue HOT 17
- OpenApi fails on reading file HOT 2
- Virtual Directory configuration IIS doesn't work UpstreamPathTemplate 404 not found HOT 1
- Request: Api Search across all swagger docs HOT 2
- Added ApiController to Ocelot Gateway, but gets 404 when requesting it HOT 4
- Ocelot Gateway controllers return enum values as integer instead of string.
- A bug when using .NET8-Ocelot[20.*]
- Status code 500 using 8.1.0 with multiple routes HOT 1
- Failed to load API definition - value cannot be null HOT 1
- getting error when use service discovery HOT 7
- Cant send code_challenge when using SwaggerForOcelot
- Error with gateway hosted under https://example.com/internal-gateway instead of https://example.com
- Using the Consul service discovery, it was found that the request path in the gateway swagger document does not have the "KeyToPath" property attached
- Can you still customize your base URL in newer versions
- The swagger is not shown
- MMLib.SwaggerForOcelot failed to generate aggregate document
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mmlib.swaggerforocelot.