Я использую Swagger для Ocelot in. Net микросервисный шлюз. Я использую следующий пакет для ocelot swagger:
Install-Package MMLib.SwaggerForOcelot -Version 1.10.1
Я получаю следующую проблему.
Как я уже упоминал на картинке, http реплицируется в URL-адресе запроса шлюза
Моя конфигурация проекта следующая,
<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>
Моя конфигурация Ocelot следующая,
{
"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"
}
}
Моя конфигурация swagger в файле запуска следующая,
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();
}