File tree Expand file tree Collapse file tree 5 files changed +48
-1
lines changed
Microsoft.AspNet.OData.Versioning.ApiExplorer
System.Web.Http/Description
Microsoft.AspNetCore.OData.Versioning.ApiExplorer/AspNetCore.Mvc.ApiExplorer
Microsoft.AspNetCore.OData.Versioning/AspNet.OData/Routing Expand file tree Collapse file tree 5 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -72,5 +72,22 @@ public static IEdmEntityType EntityType( this ApiDescription apiDescription )
7272 Arg . NotNull ( apiDescription , nameof ( apiDescription ) ) ;
7373 return apiDescription . EntitySet ( ) ? . EntityType ( ) ;
7474 }
75+
76+ /// <summary>
77+ /// Gets the operation associated with the API description.
78+ /// </summary>
79+ /// <param name="apiDescription">The <see cref="ApiDescription">API description</see> to get the operation for.</param>
80+ /// <returns>The associated <see cref="IEdmOperation">EDM operation</see> or <c>null</c> if there is no associated operation.</returns>
81+ public static IEdmOperation Operation ( this ApiDescription apiDescription )
82+ {
83+ Arg . NotNull ( apiDescription , nameof ( apiDescription ) ) ;
84+
85+ if ( apiDescription is VersionedApiDescription description )
86+ {
87+ return description . GetProperty < IEdmOperation > ( ) ;
88+ }
89+
90+ return default ;
91+ }
7592 }
7693}
Original file line number Diff line number Diff line change @@ -461,6 +461,16 @@ void PopulateActionDescriptions(
461461 Properties = { [ typeof ( IEdmModel ) ] = routeBuilderContext . EdmModel } ,
462462 } ;
463463
464+ if ( routeBuilderContext . EntitySet != null )
465+ {
466+ apiDescription . Properties [ typeof ( IEdmEntitySet ) ] = routeBuilderContext . EntitySet ;
467+ }
468+
469+ if ( routeBuilderContext . Operation != null )
470+ {
471+ apiDescription . Properties [ typeof ( IEdmOperation ) ] = routeBuilderContext . Operation ;
472+ }
473+
464474 apiDescription . ParameterDescriptions . AddRange ( routeBuilderContext . ParameterDescriptions ) ;
465475 apiDescription . SupportedRequestBodyFormatters . AddRange ( requestFormatters ) ;
466476 apiDescription . SupportedResponseFormatters . AddRange ( responseFormatters ) ;
Original file line number Diff line number Diff line change @@ -63,5 +63,16 @@ public static IEdmEntityType EntityType( this ApiDescription apiDescription )
6363 Arg . NotNull ( apiDescription , nameof ( apiDescription ) ) ;
6464 return apiDescription . EntitySet ( ) ? . EntityType ( ) ;
6565 }
66+
67+ /// <summary>
68+ /// Gets the operation associated with the API description.
69+ /// </summary>
70+ /// <param name="apiDescription">The <see cref="ApiDescription">API description</see> to get the operation for.</param>
71+ /// <returns>The associated <see cref="IEdmOperation">EDM operation</see> or <c>null</c> if there is no associated operation.</returns>
72+ public static IEdmOperation Operation ( this ApiDescription apiDescription )
73+ {
74+ Arg . NotNull ( apiDescription , nameof ( apiDescription ) ) ;
75+ return apiDescription . GetProperty < IEdmOperation > ( ) ;
76+ }
6677 }
6778}
Original file line number Diff line number Diff line change @@ -412,6 +412,16 @@ IEnumerable<ApiDescription> NewODataApiDescriptions( ControllerActionDescriptor
412412 Properties = { [ typeof ( IEdmModel ) ] = routeContext . EdmModel } ,
413413 } ;
414414
415+ if ( routeContext . EntitySet != null )
416+ {
417+ apiDescription . Properties [ typeof ( IEdmEntitySet ) ] = routeContext . EntitySet ;
418+ }
419+
420+ if ( routeContext . Operation != null )
421+ {
422+ apiDescription . Properties [ typeof ( IEdmOperation ) ] = routeContext . Operation ;
423+ }
424+
415425 foreach ( var parameter in parameters )
416426 {
417427 apiDescription . ParameterDescriptions . Add ( parameter ) ;
Original file line number Diff line number Diff line change 66 using Microsoft . OData ;
77 using Microsoft . OData . Edm ;
88 using System ;
9- using System . Collections . Generic ;
109 using System . Diagnostics . Contracts ;
1110 using System . Reflection ;
1211 using static Microsoft . OData . ODataUrlKeyDelimiter ;
You can’t perform that action at this time.
0 commit comments