Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion asp.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<Folder Name="/examples/">
<File Path="examples/.editorconfig" />
<File Path="examples/Directory.Build.props" />
<File Path="examples/Directory.Packages.props" />
</Folder>
<Folder Name="/examples/AspNet/">
<File Path="examples/AspNet/Directory.Build.props" />
Expand All @@ -69,7 +70,6 @@
</Folder>
<Folder Name="/examples/AspNetCore/" />
<Folder Name="/examples/AspNetCore/OData/">
<File Path="examples/AspNetCore/OData/Directory.Build.props" />
<Project Path="examples/AspNetCore/OData/ODataAdvancedExample/ODataAdvancedExample.csproj" />
<Project Path="examples/AspNetCore/OData/ODataBasicExample/ODataBasicExample.csproj" />
<Project Path="examples/AspNetCore/OData/ODataConventionsExample/ODataConventionsExample.csproj" />
Expand Down
15 changes: 0 additions & 15 deletions examples/AspNet/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)','$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" Version="5.3.*" />
</ItemGroup>

<ItemGroup>
<AssemblyAttribute Include="Microsoft.Owin.OwinStartupAttribute">
<_Parameter1>ApiVersioning.Examples.Startup</_Parameter1>
<_Parameter1_TypeName>System.Type</_Parameter1_TypeName>
</AssemblyAttribute>
</ItemGroup>

<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Startup.Newtonsoft.cs" DependentUpon="Startup.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<Reference Include="System.ComponentModel.DataAnnotations" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\src\AspNet\OData\src\Asp.Versioning.WebApi.OData\Asp.Versioning.WebApi.OData.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private EntityTypeConfiguration<Order> ConfigureCurrent( ODataModelBuilder build
{
var order = builder.EntitySet<Order>( "Orders" ).EntityType;

order.HasKey( p => p.Id );
order.HasKey( p => p.Id ).Select();

return order;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private EntityTypeConfiguration<Person> ConfigureCurrent( ODataModelBuilder buil
{
var person = builder.EntitySet<Person>( "People" ).EntityType;

person.HasKey( p => p.Id );
person.HasKey( p => p.Id ).Select();

return person;
}
Expand Down
74 changes: 74 additions & 0 deletions examples/AspNet/OData/AdvancedODataWebApiExample/Examples.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# For more info on HTTP files go to https://aka.ms/vs/httpfile

@baseUrl = http://localhost:9006

### VERSION 1.0

### People - Get All (OData)
# Note: assumes the version when AssumeDefaultVersionWhenUnspecified = true,
# which is meant for existing, unversioned apis
GET {{baseUrl}}/api/people

### People - Get All (OData)
GET {{baseUrl}}/api/people?api-version=1.0

### People - Get All with $select (OData)
GET {{baseUrl}}/api/people?api-version=1.0&$select=firstName,lastName

### People - Get by Key (OData)
GET {{baseUrl}}/api/people/1?api-version=1.0

### Orders - Get All (Standard)
# Note: assumes the version when AssumeDefaultVersionWhenUnspecified = true,
# which is meant for existing, unversioned apis
GET {{baseUrl}}/api/orders

### Orders - Get All (Standard)
GET {{baseUrl}}/api/orders?api-version=1.0

### Orders - Get by Key (Standard)
GET {{baseUrl}}/api/orders/1?api-version=1.0

### VERSION 2.0

### People - Get All (OData)
GET {{baseUrl}}/api/people?api-version=2.0

### People - Get All with $select (OData)
GET {{baseUrl}}/api/people?api-version=2.0&$select=firstName,lastName,email

### People - Get by Key (OData)
GET {{baseUrl}}/api/people/1?api-version=2.0

### People - Partial Update (OData)
PATCH {{baseUrl}}/api/people/1?api-version=2.0
content-type: application/json
prefer: return=representation

{"firstName":"John","lastName":"Doe"}

### Orders - Get All (OData)
GET {{baseUrl}}/api/orders?api-version=2.0

### Orders - Get All with $select (OData)
GET {{baseUrl}}/api/orders?api-version=2.0&$select=id,customer

### Orders - Get by Key (OData)
GET {{baseUrl}}/api/orders/1?api-version=2.0

### VERSION 3.0

### People - Get All (OData)
GET {{baseUrl}}/api/people?api-version=3.0

### People - Get All with $select (OData)
GET {{baseUrl}}/api/people?api-version=3.0&$select=firstName,lastName,email

### People - Get by Key (OData)
GET {{baseUrl}}/api/people/1?api-version=3.0

### Orders - Get All (Standard)
GET {{baseUrl}}/api/orders?api-version=3.0

### Orders - Get by Key (Standard)
GET {{baseUrl}}/api/orders/1?api-version=3.0
5 changes: 5 additions & 0 deletions examples/AspNet/OData/AdvancedODataWebApiExample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ASP.NET Web API with OData Advanced Example

This example project illustrates advanced scenarios that mixes and matches between standard ASP.NET Web API controllers
and OData controllers. Services can transition to or from OData across API versions. Launch the project and try the
[example requests](Examples.http) to view an API in action.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<Reference Include="System.ComponentModel.DataAnnotations" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\src\AspNet\OData\src\Asp.Versioning.WebApi.OData\Asp.Versioning.WebApi.OData.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private EntityTypeConfiguration<Order> ConfigureCurrent( ODataModelBuilder build
{
var order = builder.EntitySet<Order>( "Orders" ).EntityType;

order.HasKey( p => p.Id );
order.HasKey( p => p.Id ).Select();

return order;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private EntityTypeConfiguration<Person> ConfigureCurrent( ODataModelBuilder buil
{
var person = builder.EntitySet<Person>( "People" ).EntityType;

person.HasKey( p => p.Id );
person.HasKey( p => p.Id ).Select();

return person;
}
Expand Down
55 changes: 55 additions & 0 deletions examples/AspNet/OData/BasicODataWebApiExample/Examples.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# For more info on HTTP files go to https://aka.ms/vs/httpfile

@baseUrl = http://localhost:9004

### ------------------------------ BY QUERY STRING ------------------------------

### VERSION 1.0

### People - Get All
GET {{baseUrl}}/api/people?api-version=1.0

### People - Get All with $select
GET {{baseUrl}}/api/people?api-version=1.0&$select=firstName,lastName

### People - Get by Key
GET {{baseUrl}}/api/people/1?api-version=1.0

### VERSION 2.0

### People - Get All
GET {{baseUrl}}/api/people?api-version=2.0

### People - Get All with $select
GET {{baseUrl}}/api/people?api-version=2.0&$select=firstName,lastName,email

### People - Get by Key
GET {{baseUrl}}/api/people/1?api-version=2.0

### People - Partial Update
PATCH {{baseUrl}}/api/people/1?api-version=2.0
content-type: application/json
prefer: return=representation

{"firstName":"John","lastName":"Doe"}

### VERSION 3.0

### People - Get All
GET {{baseUrl}}/api/people?api-version=3.0

### People - Get All with $select
GET {{baseUrl}}/api/people?api-version=3.0&$select=firstName,lastName,email

### People - Get by Key
GET {{baseUrl}}/api/people/1?api-version=3.0

### ------------------------------ BY URL SEGMENT ------------------------------

### VERSION 1.0

### Orders - Get All
GET {{baseUrl}}/api/v1/orders

### Orders - Get by Key
GET {{baseUrl}}/api/v1/orders/1
4 changes: 4 additions & 0 deletions examples/AspNet/OData/BasicODataWebApiExample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# ASP.NET Web API with OData Basic Example

This example project illustrates a bare bones, basic setup using OData endpoints. Launch the project and try the
[example requests](Examples.http) to view an API in action.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private EntityTypeConfiguration<Order> ConfigureCurrent( ODataModelBuilder build
{
var order = builder.EntitySet<Order>( "Orders" ).EntityType;

order.HasKey( p => p.Id );
order.HasKey( p => p.Id ).Select();

return order;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private EntityTypeConfiguration<Person> ConfigureCurrent( ODataModelBuilder buil
{
var person = builder.EntitySet<Person>( "People" ).EntityType;

person.HasKey( p => p.Id );
person.HasKey( p => p.Id ).Select();

return person;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<Reference Include="System.ComponentModel.DataAnnotations" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\src\AspNet\OData\src\Asp.Versioning.WebApi.OData\Asp.Versioning.WebApi.OData.csproj" />
</ItemGroup>
Expand Down
55 changes: 55 additions & 0 deletions examples/AspNet/OData/ConventionsODataWebApiExample/Examples.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# For more info on HTTP files go to https://aka.ms/vs/httpfile

@baseUrl = http://localhost:9005

### ------------------------------ BY QUERY STRING ------------------------------

### VERSION 1.0

### People - Get All
GET {{baseUrl}}/api/people?api-version=1.0

### People - Get All with $select
GET {{baseUrl}}/api/people?api-version=1.0&$select=firstName,lastName

### People - Get by Key
GET {{baseUrl}}/api/people/1?api-version=1.0

### VERSION 2.0

### People - Get All
GET {{baseUrl}}/api/people?api-version=2.0

### People - Get All with $select
GET {{baseUrl}}/api/people?api-version=2.0&$select=firstName,lastName,email

### People - Get by Key
GET {{baseUrl}}/api/people/1?api-version=2.0

### People - Partial Update
PATCH {{baseUrl}}/api/people/1?api-version=2.0
content-type: application/json
prefer: return=representation

{"firstName":"John","lastName":"Doe"}

### VERSION 3.0

### People - Get All
GET {{baseUrl}}/api/people?api-version=3.0

### People - Get All with $select
GET {{baseUrl}}/api/people?api-version=3.0&$select=firstName,lastName,email

### People - Get by Key
GET {{baseUrl}}/api/people/1?api-version=3.0

### ------------------------------ BY URL SEGMENT ------------------------------

### VERSION 1.0

### Orders - Get All
GET {{baseUrl}}/api/v1/orders

### Orders - Get by Key
GET {{baseUrl}}/api/v1/orders/1
6 changes: 6 additions & 0 deletions examples/AspNet/OData/ConventionsODataWebApiExample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ASP.NET Web API with OData Conventions Example

This example project illustrates using ASP.NET Core with OData by applying API version metadata with conventions
instead of attributes. This approach is useful if you prefer not to decorate controllers with API versions or in a
scenario where you might not have the ability to apply attributes yourself, such as in a plug-in model. Launch the
project and try the [example requests](Examples.http) to view an API in action.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>Exe</OutputType>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(MSBuildThisFileName).xml</DocumentationFile>
</PropertyGroup>

Expand All @@ -10,7 +11,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Swashbuckle.Core" Version="5.6.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" />
<PackageReference Include="Swashbuckle.Core" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions examples/AspNet/OData/OpenApiODataWebApiExample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ASP.NET Web API OData OpenAPI Example

This example project illustrates using OData endpoints with [OpenAPI] and [Swashbuckle]. Launch the project and try the
example requests to view an API in action.

[OpenAPI]: https://www.openapis.org/
[Swashbuckle]: https://github.com/domaindrivendev/Swashbuckle.WebApi
8 changes: 8 additions & 0 deletions examples/AspNet/OData/SomeOpenApiODataWebApiExample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ASP.NET Web API with Some OData OpenAPI Example

This example project illustrates using standard ASP.NET Core controllers and OData query capabilities without fully
adhering to the OData protocol while also integrating with [OpenAPI] and [Swashbuckle]. Launch the project and try the
example requests to view an API in action.

[OpenAPI]: https://www.openapis.org/
[Swashbuckle]: https://github.com/domaindrivendev/Swashbuckle.WebApi
Loading