Self Documentation/Gateway Documentation
See original GitHub issueHi,
I’ve followed the instruction to try and enable Gateway documentation but I am having issues.
Note: It is otherwise working perfectly except these steps - also note that /administration api is working perfectly.
One step of the instructions is to add;
app.UseSwagger();
This however causes exception at Startup. Please see below stack. Removing the above line removes the exception.
[02:31:34 ERR] HTTP GET / responded 500 in 3.8379 ms
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.<>c__DisplayClass0_0.<AddSwaggerForOcelot>b__3(SwaggerGenOptions c)
at Microsoft.Extensions.Options.ConfigureNamedOptions`1.Configure(String name, TOptions options)
at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
at Microsoft.Extensions.Options.OptionsManager`1.<>c__DisplayClass5_0.<Get>b__0()
...
...
...
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.GetService(IServiceProvider sp, Type type, Type middleware)
at lambda_method(Closure , Object , HttpContext , IServiceProvider )
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass4_1.<UseMiddleware>b__2(HttpContext context)
at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext)
at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext)
[02:31:34 ERR] An unhandled exception has occurred while executing the request.
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.<>c__DisplayClass0_0.<AddSwaggerForOcelot>b__3(SwaggerGenOptions c)
Subsequently, everything seems to work perfectly except when I select “gateway” from the drop down.
Fetch error undefined /swagger/docs/gateway/gateway
ConfigureServices Method
Action<IdentityServerAuthenticationOptions> opts = o => {
o.Authority = config["ApiResourceBaseUrls:AuthServer"];
o.RequireHttpsMetadata = false;
o.SupportedTokens = SupportedTokens.Both;
o.SaveToken = true;
o.ApiSecret = config["self:Secret"];
o.ApiName = config["self:Id"];
};
services.AddOcelot(config).AddAdministration(config["GlobalConfiguration:AdministrationPath"], opts);
services.AddSwaggerForOcelot(config,options =>
{
options.GenerateDocsForGatewayItSelf = true;
//options.GenerateDocsForAggregates = true;
});
Configure Method
//https://github.com/Burgyn/MMLib.SwaggerForOcelot
app.UseSwaggerForOcelotUI(opt =>
{
opt.PathToSwaggerGenerator = "/swagger/docs";
});
app.UseSwagger();
Expected behavior No Exception at startup and also the gateway documentation works.
To Reproduce Attached Ocelots file routes.txt
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Documenting REST APIs
Learn how to provide documentation support for an API Gateway REST API. ... To help customers understand and use your API, you should...
Read more >Document an API using the API Gateway console
In this section, we describe how to create and maintain documentation parts of an API using the API Gateway console. A prerequisite for...
Read more >Host your API Gateway documentation in API Gateway
Host your OpenAPI documentation in a Lambda in API Gateway without any additional infrastructure.
Read more >Self-hosted gateway overview
The self-hosted gateway is an optional, containerized version of the default managed gateway included in every API Management service.
Read more >Sample repo for self hosted API Gateway documentation
API Gateway Self -Hosted Documentation. Sample repo to show an API Gateway hosting its own OpenAPI documentation in a Lambda.
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
Hello, Burgyn
I’ve updated the package to 3.2.1 version and problem no longer persists.
Thank You for making it work in
.net core 3.1
.Hi @aarondglover, thanks for reporting this issue.
Unfortunately I can’t reproduce it. I need your help. Please can you write which version of this package you use? If you use the
Swashbuckle.AspNetCore
package directly, its version as well.Please also write me how you call
AddSwaggerForOcelot
method inConfigureServices
.Ideal if you can isolate this issue into the demo app.
Thanks for your cooperation.