SwaggerEndPoints configuration section is missing or empty for merged ocelot jsons
See original GitHub issueHi,
When I’m using per service ocelot.json configuration and file merging, I get System.InvalidOperationException: “SwaggerEndPoints configuration section is missing or empty.” Approach is described here: https://ocelot.readthedocs.io/en/latest/features/configuration.html#merging-configuration-files
When I put whole configuration in standalone ocelot.json, everything works fine.
I would like to use both configurations merging and swagger on api gateway.
My configuration below:
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddOcelot();
services.AddSwaggerForOcelot(Configuration);
...
}
public async void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...
app.UseStaticFiles();
await app.UseSwaggerForOcelotUI(Configuration, opt =>
{
opt.PathToSwaggerGenerator = "/swagger/docs";
}).UseOcelot();
...
}
Program.cs
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureAppConfiguration((hostingContext, config) =>
{
config
.AddOcelot("./Ocelot", hostingContext.HostingEnvironment)
.AddEnvironmentVariables();
});
webBuilder.UseStartup<Startup>();
});
ocelot.service1.json
{
"ReRoutes": [
{
"SwaggerKey": "service1",
"UpstreamPathTemplate": "/service1/{everything}",
"UpstreamHttpMethod": [ "GET", "PUT" ],
"DownstreamPathTemplate": "/service1/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5010
}
]
}
]
}
ocelot.global.json
{
"SwaggerEndPoints": [
{
"Key": "service1",
"Config": [
{
"Name": "Service1 API V1",
"Version": "v1",
"Url": "http://localhost:5010/swagger/v1/swagger.json"
}
]
}
],
"GlobalConfiguration": {
"BaseUrl": "http://localhost:5014"
}
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Why SwaggerForOcelot not load services swagge ...
I trying some solutions but nothing seem to work. My first solution is to add the SwaggerEndPoints key in the ocelot.authentication.json but ...
Read more >MMLib.SwaggerForOcelot 7.0.0
SwaggerEndPoint is configuration for downstream service swagger generator endpoint. Property Key is used to pair with the Route configuration. Name is displayed ...
Read more >Using Swagger with Ocelot API Gateway | by Sanchit
I was recently trying to configure Swagger on the Ocelot API gateway for one of ... Add the “SwaggerEndPoints” section in the ocelot.json....
Read more >Ocelot Documentation
At the moment there is no validation at this stage it only happens when Ocelot validates the final merged configuration.
Read more >Swagger for Ocelot API Gateway - Burgyn's blog
Configure SwaggerForOcelot in ocelot.json . ... The SwaggerEndPoints section contains the configurations needed to obtain documentation for ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
when you use
.AddOcelot("./Ocelot", hostingContext.HostingEnvironment)
extension, then Ocelot merge configuration by own way and remove unknown elements.As workaround you can move
SwaggerEndPoints
section into yourappsettings.json
file. I hope, that help you.You can config teh Program.cs to read ocelot.json or ocelot.dev.json like this: