Skip to content

Commit 08b1377

Browse files
Clean up examples and add .http files to non-OpenAPI examples. Resolves #1146. Supplants #1147
1 parent fc455c3 commit 08b1377

File tree

75 files changed

+879
-71
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+879
-71
lines changed

asp.slnx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<Folder Name="/examples/">
5050
<File Path="examples/.editorconfig" />
5151
<File Path="examples/Directory.Build.props" />
52+
<File Path="examples/Directory.Packages.props" />
5253
</Folder>
5354
<Folder Name="/examples/AspNet/">
5455
<File Path="examples/AspNet/Directory.Build.props" />
@@ -69,7 +70,6 @@
6970
</Folder>
7071
<Folder Name="/examples/AspNetCore/" />
7172
<Folder Name="/examples/AspNetCore/OData/">
72-
<File Path="examples/AspNetCore/OData/Directory.Build.props" />
7373
<Project Path="examples/AspNetCore/OData/ODataAdvancedExample/ODataAdvancedExample.csproj" />
7474
<Project Path="examples/AspNetCore/OData/ODataBasicExample/ODataBasicExample.csproj" />
7575
<Project Path="examples/AspNetCore/OData/ODataConventionsExample/ODataConventionsExample.csproj" />

examples/AspNet/Directory.Build.props

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,6 @@
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33

44
<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)','$(MSBuildThisFileDirectory)../'))" />
5-
6-
<PropertyGroup>
7-
<OutputType>Exe</OutputType>
8-
</PropertyGroup>
9-
10-
<ItemGroup>
11-
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" Version="5.3.*" />
12-
</ItemGroup>
13-
14-
<ItemGroup>
15-
<AssemblyAttribute Include="Microsoft.Owin.OwinStartupAttribute">
16-
<_Parameter1>ApiVersioning.Examples.Startup</_Parameter1>
17-
<_Parameter1_TypeName>System.Type</_Parameter1_TypeName>
18-
</AssemblyAttribute>
19-
</ItemGroup>
205

216
<ItemGroup>
227
<Compile Include="$(MSBuildThisFileDirectory)Startup.Newtonsoft.cs" DependentUpon="Startup.cs" />

examples/AspNet/OData/AdvancedODataWebApiExample/AdvancedODataWebApiExample.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
<PropertyGroup>
44
<TargetFramework>net48</TargetFramework>
5+
<OutputType>Exe</OutputType>
56
</PropertyGroup>
67

78
<ItemGroup>
89
<Reference Include="System.ComponentModel.DataAnnotations" />
910
</ItemGroup>
1011

12+
<ItemGroup>
13+
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" />
14+
</ItemGroup>
15+
1116
<ItemGroup>
1217
<ProjectReference Include="..\..\..\..\src\AspNet\OData\src\Asp.Versioning.WebApi.OData\Asp.Versioning.WebApi.OData.csproj" />
1318
</ItemGroup>

examples/AspNet/OData/AdvancedODataWebApiExample/Configuration/OrderModelConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ private EntityTypeConfiguration<Order> ConfigureCurrent( ODataModelBuilder build
1313
{
1414
var order = builder.EntitySet<Order>( "Orders" ).EntityType;
1515

16-
order.HasKey( p => p.Id );
16+
order.HasKey( p => p.Id ).Select();
1717

1818
return order;
1919
}

examples/AspNet/OData/AdvancedODataWebApiExample/Configuration/PersonModelConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private EntityTypeConfiguration<Person> ConfigureCurrent( ODataModelBuilder buil
2020
{
2121
var person = builder.EntitySet<Person>( "People" ).EntityType;
2222

23-
person.HasKey( p => p.Id );
23+
person.HasKey( p => p.Id ).Select();
2424

2525
return person;
2626
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# For more info on HTTP files go to https://aka.ms/vs/httpfile
2+
3+
@baseUrl = http://localhost:9006
4+
5+
### VERSION 1.0
6+
7+
### People - Get All (OData)
8+
# Note: assumes the version when AssumeDefaultVersionWhenUnspecified = true,
9+
# which is meant for existing, unversioned apis
10+
GET {{baseUrl}}/api/people
11+
12+
### People - Get All (OData)
13+
GET {{baseUrl}}/api/people?api-version=1.0
14+
15+
### People - Get All with $select (OData)
16+
GET {{baseUrl}}/api/people?api-version=1.0&$select=firstName,lastName
17+
18+
### People - Get by Key (OData)
19+
GET {{baseUrl}}/api/people/1?api-version=1.0
20+
21+
### Orders - Get All (Standard)
22+
# Note: assumes the version when AssumeDefaultVersionWhenUnspecified = true,
23+
# which is meant for existing, unversioned apis
24+
GET {{baseUrl}}/api/orders
25+
26+
### Orders - Get All (Standard)
27+
GET {{baseUrl}}/api/orders?api-version=1.0
28+
29+
### Orders - Get by Key (Standard)
30+
GET {{baseUrl}}/api/orders/1?api-version=1.0
31+
32+
### VERSION 2.0
33+
34+
### People - Get All (OData)
35+
GET {{baseUrl}}/api/people?api-version=2.0
36+
37+
### People - Get All with $select (OData)
38+
GET {{baseUrl}}/api/people?api-version=2.0&$select=firstName,lastName,email
39+
40+
### People - Get by Key (OData)
41+
GET {{baseUrl}}/api/people/1?api-version=2.0
42+
43+
### People - Partial Update (OData)
44+
PATCH {{baseUrl}}/api/people/1?api-version=2.0
45+
content-type: application/json
46+
prefer: return=representation
47+
48+
{"firstName":"John","lastName":"Doe"}
49+
50+
### Orders - Get All (OData)
51+
GET {{baseUrl}}/api/orders?api-version=2.0
52+
53+
### Orders - Get All with $select (OData)
54+
GET {{baseUrl}}/api/orders?api-version=2.0&$select=id,customer
55+
56+
### Orders - Get by Key (OData)
57+
GET {{baseUrl}}/api/orders/1?api-version=2.0
58+
59+
### VERSION 3.0
60+
61+
### People - Get All (OData)
62+
GET {{baseUrl}}/api/people?api-version=3.0
63+
64+
### People - Get All with $select (OData)
65+
GET {{baseUrl}}/api/people?api-version=3.0&$select=firstName,lastName,email
66+
67+
### People - Get by Key (OData)
68+
GET {{baseUrl}}/api/people/1?api-version=3.0
69+
70+
### Orders - Get All (Standard)
71+
GET {{baseUrl}}/api/orders?api-version=3.0
72+
73+
### Orders - Get by Key (Standard)
74+
GET {{baseUrl}}/api/orders/1?api-version=3.0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# ASP.NET Web API with OData Advanced Example
2+
3+
This example project illustrates advanced scenarios that mixes and matches between standard ASP.NET Web API controllers
4+
and OData controllers. Services can transition to or from OData across API versions. Launch the project and try the
5+
[example requests](Examples.http) to view an API in action.

examples/AspNet/OData/BasicODataWebApiExample/BasicODataWebApiExample.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
<PropertyGroup>
44
<TargetFramework>net48</TargetFramework>
5+
<OutputType>Exe</OutputType>
56
</PropertyGroup>
67

78
<ItemGroup>
89
<Reference Include="System.ComponentModel.DataAnnotations" />
910
</ItemGroup>
1011

12+
<ItemGroup>
13+
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" />
14+
</ItemGroup>
15+
1116
<ItemGroup>
1217
<ProjectReference Include="..\..\..\..\src\AspNet\OData\src\Asp.Versioning.WebApi.OData\Asp.Versioning.WebApi.OData.csproj" />
1318
</ItemGroup>

examples/AspNet/OData/BasicODataWebApiExample/Configuration/OrderModelConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ private EntityTypeConfiguration<Order> ConfigureCurrent( ODataModelBuilder build
1313
{
1414
var order = builder.EntitySet<Order>( "Orders" ).EntityType;
1515

16-
order.HasKey( p => p.Id );
16+
order.HasKey( p => p.Id ).Select();
1717

1818
return order;
1919
}

examples/AspNet/OData/BasicODataWebApiExample/Configuration/PersonModelConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private EntityTypeConfiguration<Person> ConfigureCurrent( ODataModelBuilder buil
2020
{
2121
var person = builder.EntitySet<Person>( "People" ).EntityType;
2222

23-
person.HasKey( p => p.Id );
23+
person.HasKey( p => p.Id ).Select();
2424

2525
return person;
2626
}

0 commit comments

Comments
 (0)