Burgyn / MMLib.SwaggerForOcelot

This repo contains swagger extension for ocelot.
MIT License
352 stars 94 forks source link

DownstreamScheme is lost #142

Closed mcslove808 closed 3 years ago

mcslove808 commented 3 years ago

Describe the bug System.UriFormatException: Invalid URI: The URI scheme is not valid.

private string GetScheme(ServiceHostAndPort service, RouteOptions route) => (route != null && !route.DownstreamScheme.IsNullOrEmpty()) ? route.DownstreamScheme : !service.Scheme.IsNullOrEmpty() ? service.Scheme : service.DownstreamPort switch { 443 => Uri.UriSchemeHttps, 80 => Uri.UriSchemeHttp, _ => string.Empty, }; result is empty because DownstreamScheme is lost public static IEnumerable GroupByPaths(this IEnumerable routeOptions) => routeOptions .GroupBy(p => new { p.SwaggerKey, p.UpstreamPathTemplate, p.DownstreamPathTemplate, p.VirtualDirectory}) .Select(p => { RouteOptions route = p.First(); return new RouteOptions( p.Key.SwaggerKey, route.UpstreamPathTemplate, route.DownstreamPathTemplate, p.Key.VirtualDirectory, p.Where(r => r.UpstreamHttpMethod != null).SelectMany(r => r.UpstreamHttpMethod)) { DownstreamHttpVersion = route.DownstreamHttpVersion, //DownstreamScheme = route.DownstreamScheme

            };
        });

Expected behavior A clear and concise description of what you expected to happen.

To Reproduce If it is a possible attache:

  1. Original downstream swagger.json.
  2. Ocelot ReRoutes configuration.
Burgyn commented 3 years ago

Hi,

thank you for your issue. Unfortunately, from this description I do not understand what is wrong. Please try to describe it more clearly. Well thank you.

mcslove808 commented 3 years ago

Hi, I see you've just added it DownstreamScheme = route.DownstreamScheme You can update The SwaggerForOcelot version of NetCoRE3.1 on Nuget.org, which I'm using

thank you

Burgyn commented 3 years ago

Hi,

for you 😉 I fixed it to version 3.1.1. Try it.

https://www.nuget.org/packages/MMLib.SwaggerForOcelot/3.1.1

mcslove808 commented 3 years ago

thank you