Comments (8)
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 your appsettings.json
file.
I hope, that help you.
from mmlib.swaggerforocelot.
Hi,
thanks for your issue. I never test this scenario.
I'll look into it in the near future.
from mmlib.swaggerforocelot.
Hi,
Thanks for the quick reply!
Moving SwaggerEndPoints
to appsettings.json
of gateway indeed helped with SwaggerEndPoints configuration section is missing or empty
but now i'm getting
IndexOutOfRangeException: Index was outside the bounds of the array.
MMLib.SwaggerForOcelot.Middleware.SwaggerForOcelotMiddleware.GetEndPointInfo(string path)
Also, I'm wondering how to move "SwaggerKey": "service1"
from ReRoutes of service. From what I saw .AddOcelot()
is also removing it from merged ocelot.json
.
UPDATE:
IndexOutOfRangeException
was caused by accidentally removed /docs
suffix from .PathToSwaggerGenerator
.
Now swagger page is loaded but with "No operations defined in spec!" info. I guess that's because of missing SwaggerKey
in ReRoutes.
from mmlib.swaggerforocelot.
Hi,
yes you are right SwaggerKey
is removed. Unfortunately now I don't have any workaround for this. I apologize.
from mmlib.swaggerforocelot.
Hi,
No problem ;)
Thanks for the help anyway ;)
from mmlib.swaggerforocelot.
Hi,
On such case if we can take ServiceName from route and map it to SwaggerKey.it will work
from mmlib.swaggerforocelot.
You can config teh Program.cs to read ocelot.json or ocelot.dev.json like this:
from mmlib.swaggerforocelot.
Hi,
sorry for the 3 years delay,
i was making a gateway 2 weeks ago with ocelot and MMLib.SwaggerForOcelot and i have faced the same problem when using ocelot merging the swagger properties and swagger endpoints are missing then i read the ocelot implementation
and i found that they are using specific properties so i have added more my self
in the last image the FileRoute is the for ocelot i have just inherited from it the same as SwaggerEndPointOptions it is for MMLib.SwaggerForOcelot,
and for the implementation with the help of this awesome guy i got the idea from him to add my own swagger end point the link
so as ocelot said in the documentation they use the ocelot.json as the entry point so we made our own extension and put all the files content in the ocelot.json with our extra properties as you can see in the previous images
and for the extension implementation
extension implementation
`
public static class ConfigurationBuilderExtensions
{
public static IConfigurationBuilder AddOcelotConfigFiles(this IConfigurationBuilder builder, string folder, string[] appNames, IWebHostEnvironment env)
{
const string primaryConfigFile = "ocelot.json";
var files = new DirectoryInfo(folder)
.EnumerateFiles()
.Where(fi => fi.Name.Contains($"ocelot.{env.EnvironmentName}.json") && appNames.Any(e => fi.Name.Contains(e)))
.ToList();
var fileConfiguration = new MyFileConfiguration();
foreach (var file in files)
{
if (files.Count > 1 && file.Name.Equals(primaryConfigFile, StringComparison.OrdinalIgnoreCase))
{
continue;
}
var lines = File.ReadAllText(file.FullName);
var config = JsonConvert.DeserializeObject<MyFileConfiguration>(lines);
fileConfiguration.Aggregates.AddRange(config.Aggregates);
fileConfiguration.Routes.AddRange(config.Routes);
fileConfiguration.SwaggerEndPoints.AddRange(config.SwaggerEndPoints);
}
var json = JsonConvert.SerializeObject(fileConfiguration);
File.WriteAllText(primaryConfigFile, json);
builder.AddJsonFile(primaryConfigFile, true, true);
return builder;
}
}
`
and that's it.
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.