Skip to content

Commit 7c978b8

Browse files
Chris Martinezcommonsensesoftware
authored andcommitted
Add model bound settings to partial OData examples
1 parent 3f65e5b commit 7c978b8

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

examples/AspNet/OData/SomeOpenApiODataWebApiExample/Book.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
namespace ApiVersioning.Examples;
22

3+
using Microsoft.AspNet.OData.Query;
4+
5+
// TODO: Model Bound settings can be performed via attributes if the
6+
// return type is known to the API Explorer or can be explicitly done
7+
// via one or more IModelConfiguration implementations
8+
39
/// <summary>
410
/// Represents a book.
511
/// </summary>
12+
[Filter( "author", "published" )]
613
public class Book
714
{
815
/// <summary>

examples/AspNet/OData/SomeOpenApiODataWebApiExample/Startup.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public void Configuration( IAppBuilder builder )
6868
.Allow( Skip | Count )
6969
.AllowTop( 100 )
7070
.AllowOrderBy( "title", "published" );
71+
72+
// applies model bound settings implicitly using an ad hoc EDM. alternatively, you can create your own
73+
// IModelConfiguration + IODataQueryOptionsConvention for full control over what goes in the ad hoc EDM.
74+
options.AdHocModelBuilder.ModelConfigurations.Add( new ImplicitModelBoundSettingsConvention() );
7175
} );
7276

7377
configuration.EnableSwagger(

examples/AspNetCore/OData/SomeODataOpenApiExample/Book.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
namespace ApiVersioning.Examples;
22

3+
using Microsoft.OData.ModelBuilder;
4+
5+
// TODO: Model Bound settings can be performed via attributes if the
6+
// return type is known to the API Explorer or can be explicitly done
7+
// via one or more IModelConfiguration implementations
8+
39
/// <summary>
410
/// Represents a book.
511
/// </summary>
12+
[Filter( "author", "published" )]
613
public class Book
714
{
815
/// <summary>

0 commit comments

Comments
 (0)