Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
When I set up ASP.Versioning v10 like below, and access an OpenAPI version document that doesn't exist (openapi/v10.json for example), an exception is thrown:
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.InvalidOperationException: This service provider doesn't support keyed services.
at Microsoft.Extensions.DependencyInjection.ServiceProviderKeyedServiceExtensions.GetKeyedService(IServiceProvider provider, Type serviceType, Object serviceKey)
at Microsoft.Extensions.DependencyInjection.KeyedServiceContainer.GetKeyedService(Type serviceType, Object serviceKey)
at Microsoft.Extensions.DependencyInjection.ServiceProviderKeyedServiceExtensions.GetKeyedService[T](IServiceProvider provider, Object serviceKey)
at Microsoft.AspNetCore.Builder.OpenApiEndpointRouteBuilderExtensions.<>c__DisplayClass0_0.<<MapOpenApi>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Http.Generated.<GeneratedRouteBuilderExtensions_g>F0399B8B15BE443123F4BECEE84B112C1912EE3F44D9DDD7BFA38E371FB917343__GeneratedRouteBuilderExtensionsCore.<>c__DisplayClass2_0.<<MapGet0>g__RequestHandler|5>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
The code (See https://github.com/sander1095/openapi-versioning/blob/v10/v10/controllers/queryheader-versioning-openapi/Program.cs for more)
using Asp.Versioning;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddApiVersioning(options =>
{
options.ReportApiVersions = true;
options.DefaultApiVersion = new ApiVersion(1, 0);
options.AssumeDefaultVersionWhenUnspecified = false;
options.ApiVersionReader = new QueryStringApiVersionReader("api-version");
})
.AddApiExplorer(options =>
{
options.GroupNameFormat = "'v'VVV";
})
.AddMvc()
.AddOpenApi();
var app = builder.Build();
app.MapOpenApi().WithDocumentPerVersion();
app.MapControllers();
app.Run();
Describe the solution you'd like
When accessing a non-existing real endpoint (like api/scores) it returns a 400 bad request. Similar behavior for the OpenAPI document would be desirable. Otherwise, a clearer exception :)
Additional context
Due to the exception being the same, perhaps this is related to #1176
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
When I set up ASP.Versioning v10 like below, and access an OpenAPI version document that doesn't exist (
openapi/v10.jsonfor example), an exception is thrown:The code (See https://github.com/sander1095/openapi-versioning/blob/v10/v10/controllers/queryheader-versioning-openapi/Program.cs for more)
Describe the solution you'd like
When accessing a non-existing real endpoint (like api/scores) it returns a 400 bad request. Similar behavior for the OpenAPI document would be desirable. Otherwise, a clearer exception :)
Additional context
Due to the exception being the same, perhaps this is related to #1176