Comments (4)
Hi @sandyrepo
thanks for your report. It's look like problem with transformation by Ocelot config. You use {url}
as wild card in your configuration. Unfortunately now this project support only {everything}
as wildcard. (see #68)
Please try use {everything}
.
from mmlib.swaggerforocelot.
{
"ReRoutes": [
{
"DownstreamPathTemplate": "/{url}",
"DownstreamScheme": "http",
"UpstreamPathTemplate": "/abc/{url}",
"UpstreamHttpMethod": [ "Get", "POST", "PUT" ],
"ServiceName": "ani.abc.api",
"LoadBalancerOptions": {
"Type": "LeastConnection"
},
"RateLimitOptions": {
"ClientWhitelist": [],
"EnableRateLimiting": true,
"Period": "1s",
"PeriodTimespan": 1,
"Limit": 1
},
"SwaggerKey": "swaggerabc"
}
],
"SwaggerEndPoints": [
{
"Key": "swaggerabc",
"Config": [
{
"Name": "abc API",
"Version": "v1",
"Url": "http://ani.abc.api:80/swagger/v1/swagger.json"
}
]
}
],
"GlobalConfiguration": {
"ServiceDiscoveryProvider": {
"Host": "consul",
"Port": 8500,
"Type": "Consul"
},
"RequestIdKey": "OcRequestId"
}
}
--------------Gateway startup file--------------
public void ConfigureServices(IServiceCollection services)
{
services.AddOcelot().AddConsul();
services.AddSwaggerForOcelot(Configuration);
services.AddControllers();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
// app.UseHttpsRedirection();
app.UseRouting();
//app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
//app.UseSwaggerForOcelotUI(Configuration).UseOcelot().Wait();
app.UseSwaggerForOcelotUI(Configuration, opt =>
{
opt.ReConfigureUpstreamSwaggerJson = AlterUpstreamSwaggerJson;
}).UseOcelot().Wait();
//app.UseSwaggerForOcelotUI(Configuration, opt =>
//{
// opt.PathToSwaggerGenerator = "/swagger/docs";
//});
//app.UseSwaggerForOcelotUI(Configuration, opt =>
//{
// opt.ReConfigureUpstreamSwaggerJson = AlterUpstreamSwaggerJson;
// //opt.DownstreamSwaggerEndPointBasePath = "/swagger/docs";
// //opt.PathToSwaggerGenerator = "/swagger/docs";
//}).UseOcelot().Wait();
}
public string AlterUpstreamSwaggerJson(HttpContext context, string swaggerJson)
{
var swagger = JObject.Parse(swaggerJson);
return swagger.ToString(Formatting.Indented);
}
-------------------------------------Microservice startup file
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "abc API", Version = "v1" });
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
}
from mmlib.swaggerforocelot.
I tried with setting swaggerkey as service name but got http error "cannot assign address"
from mmlib.swaggerforocelot.
Thanks for your quick reply. this resolved my issue
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.