Skip to content

Commit 2d49909

Browse files
author
Chris Martinez
committed
Minor updates to existing examples and adds new examples.
1 parent 595d56b commit 2d49909

40 files changed

+1144
-15
lines changed

ApiVersioningWithSamples.sln

+14
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebApi.Ver
102102
EndProject
103103
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.OData.Versioning.Tests", "test\Microsoft.AspNet.OData.Versioning.Tests\Microsoft.AspNet.OData.Versioning.Tests.xproj", "{D87E54CC-C2D6-4AE5-806D-AE825B051C66}"
104104
EndProject
105+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedODataWebApiSample", "samples\webapi\AdvancedODataWebApiSample\AdvancedODataWebApiSample.csproj", "{E496EED0-F8C9-4FE9-83E6-75E47A3C41A1}"
106+
EndProject
107+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ByNamespaceWebApiSample", "samples\webapi\ByNamespaceWebApiSample\ByNamespaceWebApiSample.csproj", "{A02A4245-3AEB-4549-9037-D89DFDC7E74D}"
108+
EndProject
105109
Global
106110
GlobalSection(SolutionConfigurationPlatforms) = preSolution
107111
Debug|Any CPU = Debug|Any CPU
@@ -144,6 +148,14 @@ Global
144148
{D87E54CC-C2D6-4AE5-806D-AE825B051C66}.Debug|Any CPU.Build.0 = Debug|Any CPU
145149
{D87E54CC-C2D6-4AE5-806D-AE825B051C66}.Release|Any CPU.ActiveCfg = Release|Any CPU
146150
{D87E54CC-C2D6-4AE5-806D-AE825B051C66}.Release|Any CPU.Build.0 = Release|Any CPU
151+
{E496EED0-F8C9-4FE9-83E6-75E47A3C41A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
152+
{E496EED0-F8C9-4FE9-83E6-75E47A3C41A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
153+
{E496EED0-F8C9-4FE9-83E6-75E47A3C41A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
154+
{E496EED0-F8C9-4FE9-83E6-75E47A3C41A1}.Release|Any CPU.Build.0 = Release|Any CPU
155+
{A02A4245-3AEB-4549-9037-D89DFDC7E74D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
156+
{A02A4245-3AEB-4549-9037-D89DFDC7E74D}.Debug|Any CPU.Build.0 = Debug|Any CPU
157+
{A02A4245-3AEB-4549-9037-D89DFDC7E74D}.Release|Any CPU.ActiveCfg = Release|Any CPU
158+
{A02A4245-3AEB-4549-9037-D89DFDC7E74D}.Release|Any CPU.Build.0 = Release|Any CPU
147159
EndGlobalSection
148160
GlobalSection(SolutionProperties) = preSolution
149161
HideSolutionNode = FALSE
@@ -165,5 +177,7 @@ Global
165177
{69C59656-53D1-4ACB-92B5-8B34C8E62175} = {0987757E-4D09-4523-B9C9-65B1E8832AA1}
166178
{AEB074E1-E57A-4DD3-A972-3625B367CE5D} = {0987757E-4D09-4523-B9C9-65B1E8832AA1}
167179
{D87E54CC-C2D6-4AE5-806D-AE825B051C66} = {0987757E-4D09-4523-B9C9-65B1E8832AA1}
180+
{E496EED0-F8C9-4FE9-83E6-75E47A3C41A1} = {F446ED94-368F-4F67-913B-16E82CA80DFC}
181+
{A02A4245-3AEB-4549-9037-D89DFDC7E74D} = {F446ED94-368F-4F67-913B-16E82CA80DFC}
168182
EndGlobalSection
169183
EndGlobal

samples/aspnetcore/BasicSample/Controllers/ValuesController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[Route( "api/[controller]" )]
1111
public class ValuesController : Controller
1212
{
13-
// GET api/values?api-version-1.0
13+
// GET api/values?api-version=1.0
1414
[HttpGet]
1515
public string Get() => $"Controller = {GetType().Name}\nVersion = {HttpContext.GetRequestedApiVersion()}";
1616
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
4+
<Import Project="..\..\..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\..\..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />
5+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
6+
<PropertyGroup>
7+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9+
<ProductVersion>
10+
</ProductVersion>
11+
<SchemaVersion>2.0</SchemaVersion>
12+
<ProjectGuid>{E496EED0-F8C9-4FE9-83E6-75E47A3C41A1}</ProjectGuid>
13+
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
14+
<OutputType>Library</OutputType>
15+
<AppDesignerFolder>Properties</AppDesignerFolder>
16+
<RootNamespace>Microsoft.Examples</RootNamespace>
17+
<AssemblyName>AdvancedODataWebApiSample</AssemblyName>
18+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
19+
<UseIISExpress>true</UseIISExpress>
20+
<IISExpressSSLPort />
21+
<IISExpressAnonymousAuthentication />
22+
<IISExpressWindowsAuthentication />
23+
<IISExpressUseClassicPipelineMode />
24+
<UseGlobalApplicationHostFile />
25+
<NuGetPackageImportStamp>
26+
</NuGetPackageImportStamp>
27+
</PropertyGroup>
28+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
29+
<DebugSymbols>true</DebugSymbols>
30+
<DebugType>full</DebugType>
31+
<Optimize>false</Optimize>
32+
<OutputPath>bin\</OutputPath>
33+
<DefineConstants>DEBUG;TRACE</DefineConstants>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
</PropertyGroup>
37+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
38+
<DebugType>pdbonly</DebugType>
39+
<Optimize>true</Optimize>
40+
<OutputPath>bin\</OutputPath>
41+
<DefineConstants>TRACE</DefineConstants>
42+
<ErrorReport>prompt</ErrorReport>
43+
<WarningLevel>4</WarningLevel>
44+
</PropertyGroup>
45+
<ItemGroup>
46+
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
47+
<HintPath>..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
48+
<Private>True</Private>
49+
</Reference>
50+
<Reference Include="Microsoft.CSharp" />
51+
<Reference Include="Microsoft.OData.Core, Version=6.15.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
52+
<HintPath>..\..\..\packages\Microsoft.OData.Core.6.15.0\lib\portable-net45+win+wpa81\Microsoft.OData.Core.dll</HintPath>
53+
<Private>True</Private>
54+
</Reference>
55+
<Reference Include="Microsoft.OData.Edm, Version=6.15.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
56+
<HintPath>..\..\..\packages\Microsoft.OData.Edm.6.15.0\lib\portable-net45+win+wpa81\Microsoft.OData.Edm.dll</HintPath>
57+
<Private>True</Private>
58+
</Reference>
59+
<Reference Include="Microsoft.Owin, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
60+
<HintPath>..\..\..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
61+
<Private>True</Private>
62+
</Reference>
63+
<Reference Include="Microsoft.Owin.Host.SystemWeb, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
64+
<HintPath>..\..\..\packages\Microsoft.Owin.Host.SystemWeb.3.0.1\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
65+
<Private>True</Private>
66+
</Reference>
67+
<Reference Include="Microsoft.Spatial, Version=6.15.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
68+
<HintPath>..\..\..\packages\Microsoft.Spatial.6.15.0\lib\portable-net45+win+wpa81\Microsoft.Spatial.dll</HintPath>
69+
<Private>True</Private>
70+
</Reference>
71+
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
72+
<HintPath>..\..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
73+
<Private>True</Private>
74+
</Reference>
75+
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
76+
<HintPath>..\..\..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
77+
<Private>True</Private>
78+
</Reference>
79+
<Reference Include="System.Net.Http" />
80+
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
81+
<HintPath>..\..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
82+
<Private>True</Private>
83+
</Reference>
84+
<Reference Include="System.Web.DynamicData" />
85+
<Reference Include="System.Web.Entity" />
86+
<Reference Include="System.Web.ApplicationServices" />
87+
<Reference Include="System.ComponentModel.DataAnnotations" />
88+
<Reference Include="System" />
89+
<Reference Include="System.Data" />
90+
<Reference Include="System.Core" />
91+
<Reference Include="System.Data.DataSetExtensions" />
92+
<Reference Include="System.Web.Extensions" />
93+
<Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
94+
<HintPath>..\..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
95+
<Private>True</Private>
96+
</Reference>
97+
<Reference Include="System.Web.Http.Owin, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
98+
<HintPath>..\..\..\packages\Microsoft.AspNet.WebApi.Owin.5.2.3\lib\net45\System.Web.Http.Owin.dll</HintPath>
99+
<Private>True</Private>
100+
</Reference>
101+
<Reference Include="System.Web.OData, Version=5.9.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
102+
<HintPath>..\..\..\packages\Microsoft.AspNet.OData.5.9.1\lib\net45\System.Web.OData.dll</HintPath>
103+
<Private>True</Private>
104+
</Reference>
105+
<Reference Include="System.Xml.Linq" />
106+
<Reference Include="System.Drawing" />
107+
<Reference Include="System.Web" />
108+
<Reference Include="System.Xml" />
109+
<Reference Include="System.Configuration" />
110+
<Reference Include="System.Web.Services" />
111+
<Reference Include="System.EnterpriseServices" />
112+
<Reference Include="..\..\..\src\Microsoft.AspNet.WebApi.Versioning\bin\$(Configuration)\net45\Microsoft.AspNet.WebApi.Versioning.dll">
113+
<Name>WebApi</Name>
114+
</Reference>
115+
<Reference Include="..\..\..\src\Microsoft.AspNet.OData.Versioning\bin\$(Configuration)\net45\Microsoft.AspNet.OData.Versioning.dll">
116+
<Name>WebApi.OData</Name>
117+
</Reference>
118+
</ItemGroup>
119+
<ItemGroup>
120+
<Content Include="packages.config" />
121+
<None Include="Web.Debug.config">
122+
<DependentUpon>Web.config</DependentUpon>
123+
</None>
124+
<None Include="Web.Release.config">
125+
<DependentUpon>Web.config</DependentUpon>
126+
</None>
127+
</ItemGroup>
128+
<ItemGroup>
129+
<Content Include="Web.config" />
130+
</ItemGroup>
131+
<ItemGroup>
132+
<Compile Include="Configuration\OrderModelConfiguration.cs" />
133+
<Compile Include="Configuration\PersonModelConfiguration.cs" />
134+
<Compile Include="Controllers\Orders2Controller.cs" />
135+
<Compile Include="Controllers\Orders3Controller.cs" />
136+
<Compile Include="Controllers\OrdersController.cs" />
137+
<Compile Include="Controllers\People2Controller.cs" />
138+
<Compile Include="Controllers\PeopleController.cs" />
139+
<Compile Include="Models\Order.cs" />
140+
<Compile Include="Models\Person.cs" />
141+
<Compile Include="Properties\AssemblyInfo.cs" />
142+
<Compile Include="Startup.cs" />
143+
</ItemGroup>
144+
<PropertyGroup>
145+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
146+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
147+
</PropertyGroup>
148+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
149+
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
150+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
151+
<ProjectExtensions>
152+
<VisualStudio>
153+
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
154+
<WebProjectProperties>
155+
<UseIIS>True</UseIIS>
156+
<AutoAssignPort>True</AutoAssignPort>
157+
<DevelopmentServerPort>1044</DevelopmentServerPort>
158+
<DevelopmentServerVPath>/</DevelopmentServerVPath>
159+
<IISUrl>http://localhost:1044/</IISUrl>
160+
<NTLMAuthentication>False</NTLMAuthentication>
161+
<UseCustomServer>False</UseCustomServer>
162+
<CustomServerUrl>
163+
</CustomServerUrl>
164+
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
165+
</WebProjectProperties>
166+
</FlavorProperties>
167+
</VisualStudio>
168+
</ProjectExtensions>
169+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
170+
<PropertyGroup>
171+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
172+
</PropertyGroup>
173+
<Error Condition="!Exists('..\..\..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
174+
<Error Condition="!Exists('..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
175+
</Target>
176+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
177+
Other similar extension points exist, see Microsoft.Common.targets.
178+
<Target Name="BeforeBuild">
179+
</Target>
180+
<Target Name="AfterBuild">
181+
</Target>
182+
-->
183+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace Microsoft.Examples.Configuration
2+
{
3+
using Microsoft.Web.Http;
4+
using Microsoft.Web.OData.Builder;
5+
using Models;
6+
using System.Web.OData.Builder;
7+
8+
public class OrderModelConfiguration : IModelConfiguration
9+
{
10+
private static readonly ApiVersion V2 = new ApiVersion( 2, 0 );
11+
12+
private EntityTypeConfiguration<Order> ConfigureCurrent( ODataModelBuilder builder )
13+
{
14+
var order = builder.EntitySet<Order>( "Orders" ).EntityType;
15+
16+
order.HasKey( p => p.Id );
17+
18+
return order;
19+
}
20+
21+
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion )
22+
{
23+
// note: the EDM for orders is only available in version 2.0
24+
if ( apiVersion == V2 )
25+
{
26+
ConfigureCurrent( builder );
27+
}
28+
}
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
namespace Microsoft.Examples.Configuration
2+
{
3+
using Microsoft.Web.Http;
4+
using Microsoft.Web.OData.Builder;
5+
using Models;
6+
using System.Web.OData.Builder;
7+
8+
public class PersonModelConfiguration : IModelConfiguration
9+
{
10+
private void ConfigureV1( ODataModelBuilder builder )
11+
{
12+
var person = ConfigureCurrent( builder );
13+
person.Ignore( p => p.Email );
14+
person.Ignore( p => p.Phone );
15+
}
16+
17+
private void ConfigureV2( ODataModelBuilder builder ) => ConfigureCurrent( builder ).Ignore( p => p.Phone );
18+
19+
private EntityTypeConfiguration<Person> ConfigureCurrent( ODataModelBuilder builder )
20+
{
21+
var person = builder.EntitySet<Person>( "People" ).EntityType;
22+
23+
person.HasKey( p => p.Id );
24+
25+
return person;
26+
}
27+
28+
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion )
29+
{
30+
switch ( apiVersion.MajorVersion )
31+
{
32+
case 1:
33+
ConfigureV1( builder );
34+
break;
35+
case 2:
36+
ConfigureV2( builder );
37+
break;
38+
default:
39+
ConfigureCurrent( builder );
40+
break;
41+
}
42+
}
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
namespace Microsoft.Examples.Controllers
2+
{
3+
using Microsoft.Web.Http;
4+
using Models;
5+
using System.Threading.Tasks;
6+
using System.Web.Http;
7+
using System.Web.OData;
8+
using System.Web.OData.Query;
9+
using System.Web.OData.Routing;
10+
11+
[ApiVersion( "2.0" )]
12+
[ControllerName( "Orders" )]
13+
[ODataRoutePrefix( "Orders" )]
14+
public class Orders2Controller : ODataController
15+
{
16+
// GET ~/orders?api-version=2.0
17+
[ODataRoute]
18+
public IHttpActionResult Get( ODataQueryOptions<Person> options ) =>
19+
Ok( new[] { new Order() { Id = 1, Customer = $"Customer v{Request.GetRequestedApiVersion()}" } } );
20+
21+
// GET ~/orders({id})?api-version=2.0
22+
[ODataRoute( "({id})" )]
23+
public IHttpActionResult Get( [FromODataUri] int id, ODataQueryOptions<Person> options ) =>
24+
Ok( new Order() { Id = id, Customer = $"Customer v{Request.GetRequestedApiVersion()}" } );
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace Microsoft.Examples.Controllers
2+
{
3+
using Microsoft.Web.Http;
4+
using Models;
5+
using System.Threading.Tasks;
6+
using System.Web.Http;
7+
using System.Web.OData;
8+
using System.Web.OData.Query;
9+
using System.Web.OData.Routing;
10+
11+
// note: even though this version of the controller uses attribute routing, other controllers use convention-based
12+
// routing. if we don't apply the ControllerName attribute, then the "controller" route parameter is not populated,
13+
// which will cause version 1.0 and 2.0 to not be discovered since they are convention-based.
14+
[ApiVersion( "3.0" )]
15+
[ControllerName( "Orders" )]
16+
[RoutePrefix( "api/orders" )]
17+
public class Orders3Controller : ApiController
18+
{
19+
// GET ~/orders?api-version=3.0
20+
[Route]
21+
public IHttpActionResult Get() => Ok( new[] { new Order() { Id = 1, Customer = $"Customer v{Request.GetRequestedApiVersion()}" } } );
22+
23+
// GET ~/orders/{id}?api-version=3.0
24+
[Route( "{id}" )]
25+
public IHttpActionResult Get( int id ) => Ok( new Order() { Id = id, Customer = $"Customer v{Request.GetRequestedApiVersion()}" } );
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace Microsoft.Examples.Controllers
2+
{
3+
using Microsoft.Web.Http;
4+
using Models;
5+
using System.Threading.Tasks;
6+
using System.Web.Http;
7+
using System.Web.OData;
8+
using System.Web.OData.Query;
9+
using System.Web.OData.Routing;
10+
11+
// note: since the application is configured with AssumeDefaultVersionWhenUnspecifed, this controller
12+
// is implicitly versioned to the DefaultApiVersion, which has the default value 1.0.
13+
public class OrdersController : ApiController
14+
{
15+
// GET ~/orders
16+
// GET ~/orders?api-version=1.0
17+
public IHttpActionResult Get() => Ok( new[] { new Order() { Id = 1, Customer = $"Customer v{Request.GetRequestedApiVersion()}" } } );
18+
19+
// GET ~/orders/{id}
20+
// GET ~/orders/{id}?api-version=1.0
21+
public IHttpActionResult Get( int id ) => Ok( new Order() { Id = id, Customer = $"Customer v{Request.GetRequestedApiVersion()}" } );
22+
}
23+
}

0 commit comments

Comments
 (0)