-
Notifications
You must be signed in to change notification settings - Fork 279
Closed
Description
Attempting to use the new copy constructors in the 1.4.0-preview1 release in an ASP.NET Core minimal APIs app and getting a NullReferenceException from the OpenApiExternalDocs constructor.
Stack trace:
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.OpenApi.Models.OpenApiExternalDocs..ctor(OpenApiExternalDocs externalDocs)
at Microsoft.OpenApi.Models.OpenApiOperation..ctor(OpenApiOperation operation)
at Program.<>c.<<Main>$>b__0_4(OpenApiOperation o) in C:\src\local\7.0.0-rc.1\WebApplication6\WebApplication6\Program.cs:line 63
at Microsoft.AspNetCore.Builder.OpenApiEndpointConventionBuilderExtensions.AddAndConfigureOperationForEndpoint(EndpointBuilder endpointBuilder, Func`2 configure)
at Microsoft.AspNetCore.Builder.OpenApiEndpointConventionBuilderExtensions.<>c__DisplayClass1_0`1.<WithOpenApi>b__0(EndpointBuilder endpointBuilder)
at Microsoft.AspNetCore.Routing.RouteEndpointDataSource.CreateRouteEndpointBuilder(RouteEntry entry, RoutePattern groupPrefix, IReadOnlyList`1 groupConventions)
at Microsoft.AspNetCore.Routing.RouteEndpointDataSource.get_Endpoints()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.CreateEndpointsUnsynchronized()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.EnsureEndpointsInitialized()
at Microsoft.AspNetCore.Routing.DataSourceDependentCache`1.Initialize()
at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
at Microsoft.AspNetCore.Routing.Matching.DataSourceDependentMatcher..ctor(EndpointDataSource dataSource, Lifetime lifetime, Func`1 matcherBuilderFactory)
at Microsoft.AspNetCore.Routing.Matching.DfaMatcherFactory.CreateMatcher(EndpointDataSource dataSource)
at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.InitializeCoreAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatcher|8_0(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task`1 matcherTask)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
Repro code, using a nightly build of .NET 7 rc.1 SDK, new project created via dotnet new webapi -minimal:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.MapGet("/testopenapi", () => "Open API")
.WithOpenApi(o => new(o));
app.Run();Metadata
Metadata
Assignees
Labels
type:bugA broken experienceA broken experience