Skip to content

MinimalApi MapMethods with muti methods use WithOpenApi() throw Error! #50965

@vipwan

Description

@vipwan

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

image

image

both .net7 & .net8 error

System.Linq.ThrowHelper.ThrowMoreThanOneElementException()
System.Linq.Enumerable.TryGetSingle(IEnumerable source, out bool found)
System.Linq.Enumerable.SingleOrDefault(IEnumerable source)
Microsoft.AspNetCore.OpenApi.OpenApiGenerator.GetOpenApiOperation(MethodInfo methodInfo, EndpointMetadataCollection metadata, RoutePattern pattern)
Microsoft.AspNetCore.Builder.OpenApiEndpointConventionBuilderExtensions.AddAndConfigureOperationForEndpoint(EndpointBuilder endpointBuilder, Func<OpenApiOperation, OpenApiOperation> configure)
Microsoft.AspNetCore.Builder.OpenApiEndpointConventionBuilderExtensions+<>c__DisplayClass1_0.b__0(EndpointBuilder endpointBuilder)
Microsoft.AspNetCore.Routing.RouteEndpointDataSource.CreateRouteEndpointBuilder(RouteEntry entry, RoutePattern groupPrefix, IReadOnlyList<Action> groupConventions, IReadOnlyList<Action> groupFinallyConventions)
Microsoft.AspNetCore.Routing.RouteEndpointDataSource.get_Endpoints()
Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.CreateEndpointsUnsynchronized()
Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.EnsureEndpointsInitialized()
Microsoft.AspNetCore.Routing.DataSourceDependentCache.Initialize()
System.Threading.LazyInitializer.EnsureInitializedCore(ref T target, ref bool initialized, ref object syncLock, Func valueFactory)
Microsoft.AspNetCore.Routing.Matching.DataSourceDependentMatcher..ctor(EndpointDataSource dataSource, Lifetime lifetime, Func matcherBuilderFactory)
Microsoft.AspNetCore.Routing.Matching.DfaMatcherFactory.CreateMatcher(EndpointDataSource dataSource)
Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.InitializeCoreAsync()
Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.g__AwaitMatcher|8_0(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matcherTask)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

7.0.11

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions