.net core Ocelot-like的Swagger请求URL错误http://http://
我在.Net微服务网关中使用Ocelot的Swagger。我在ocelot swagger中使用以下软件包: 我得到以下问题 正如我在图中提到的,http正在网关请求URL中复制 我的项目配置如下:.net core Ocelot-like的Swagger请求URL错误http://http://,.net-core,swagger,gateway,ocelot,.net Core,Swagger,Gateway,Ocelot,我在.Net微服务网关中使用Ocelot的Swagger。我在ocelot swagger中使用以下软件包: 我得到以下问题 正如我在图中提到的,http正在网关请求URL中复制 我的项目配置如下: <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp3.0</TargetFramework> <AspNet
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<UserSecretsId>38efa0b7-845b-41f3-914c-1bfc80defa9b</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..\..\..</DockerfileContext>
<DockerComposeProjectPath>..\..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
<PackageReference Include="MMLib.SwaggerForOcelot" Version="1.10.0" />
<PackageReference Include="Ocelot" Version="13.8.0" />
</ItemGroup>
</Project>
{
"ReRoutes": [
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "customer.api",
"Port": 80
}
],
"UpstreamPathTemplate": "/api/Customer/{everything}",
"UpstreamHttpMethod": [ "POST", "PUT", "GET", "DELETE", "PATCH" ],
"SwaggerKey": "skCustomer"
}
],
"SwaggerEndPoints": [
{
"Key": "skCustomer",
"Config": [
{
"Name": "Customer API",
"Version": "v1",
"Url": "http://customer.api:80/CustomerAPI/Customer/swagger.json"
}
]
}
],
"GlobalConfiguration": {
"RequestIdKey": "OcRequestId",
"AdministrationPath": "/administration"
}
}
public void ConfigureServices(IServiceCollection services)
{
services.AddSwaggerForOcelot(_cfg);
services.AddOcelot(_cfg);
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public async void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseSwaggerForOcelotUI(_cfg, opt =>
{
opt.EndPointBasePath = "/swagger/docs";
});
await app.UseOcelot();
}
启动文件中我的招摇过市配置如下:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<UserSecretsId>38efa0b7-845b-41f3-914c-1bfc80defa9b</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..\..\..</DockerfileContext>
<DockerComposeProjectPath>..\..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
<PackageReference Include="MMLib.SwaggerForOcelot" Version="1.10.0" />
<PackageReference Include="Ocelot" Version="13.8.0" />
</ItemGroup>
</Project>
{
"ReRoutes": [
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "customer.api",
"Port": 80
}
],
"UpstreamPathTemplate": "/api/Customer/{everything}",
"UpstreamHttpMethod": [ "POST", "PUT", "GET", "DELETE", "PATCH" ],
"SwaggerKey": "skCustomer"
}
],
"SwaggerEndPoints": [
{
"Key": "skCustomer",
"Config": [
{
"Name": "Customer API",
"Version": "v1",
"Url": "http://customer.api:80/CustomerAPI/Customer/swagger.json"
}
]
}
],
"GlobalConfiguration": {
"RequestIdKey": "OcRequestId",
"AdministrationPath": "/administration"
}
}
public void ConfigureServices(IServiceCollection services)
{
services.AddSwaggerForOcelot(_cfg);
services.AddOcelot(_cfg);
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public async void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseSwaggerForOcelotUI(_cfg, opt =>
{
opt.EndPointBasePath = "/swagger/docs";
});
await app.UseOcelot();
}
看起来是个问题
不幸的是,它仍然没有被修复
作为一种解决方法,您可以降级到版本1.8,该问题在版本1.10.2中得到修复