From 2545acc05196072cafe6e334f7db60200d76e4e7 Mon Sep 17 00:00:00 2001 From: Clint Good Date: Thu, 21 Jul 2016 23:01:45 +1000 Subject: [PATCH 1/4] Add Master and Child test entities that use integer keys Add failing test retrieving children related to a master --- .../Data/Child.csv | 7 + .../Data/Master.csv | 5 + .../FetchingResourcesTests.cs | 13 + ..._related_to_many_integer_key_response.json | 34 ++ ...sts.EntityFrameworkTestWebApp.Tests.csproj | 7 + ...anceTests.EntityFrameworkTestWebApp.csproj | 412 +++++++++--------- .../Models/Child.cs | 21 + .../Models/Master.cs | 16 + .../Models/TestDbContext.cs | 2 + .../Startup.cs | 7 +- 10 files changed, 318 insertions(+), 206 deletions(-) create mode 100644 JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Child.csv create mode 100644 JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Master.csv create mode 100644 JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_integer_key_response.json create mode 100644 JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Child.cs create mode 100644 JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Master.cs diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Child.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Child.csv new file mode 100644 index 00000000..b529aab6 --- /dev/null +++ b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Child.csv @@ -0,0 +1,7 @@ +Id,ChildDescription,MasterId +7500,"Child 1 Description",1500 +7501,"Child 2 Description",1501 +7502,"Child 3 Description",1501 +7503,"Child 4 Description",1503 +7504,"Child 5 Description",1503 +7505,"Child 6 Description",1503 \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Master.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Master.csv new file mode 100644 index 00000000..2a582cc4 --- /dev/null +++ b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Master.csv @@ -0,0 +1,5 @@ +Id,Description +1500,"Master 1 Description" +1501,"Master 2 Description" +1502,"Master 3 Description" +1503,"Master 4 Description" diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/FetchingResourcesTests.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/FetchingResourcesTests.cs index 5ec6cc98..36321862 100644 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/FetchingResourcesTests.cs +++ b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/FetchingResourcesTests.cs @@ -183,5 +183,18 @@ await AssertResponseContent(response, HttpStatusCode.OK); } } + + [TestMethod] + [DeploymentItem(@"Data\Master.csv", @"Data")] + [DeploymentItem(@"Data\Child.csv", @"Data")] + public async Task Get_related_to_many_integer_key() + { + using (var effortConnection = GetEffortConnection()) + { + var response = await SubmitGet(effortConnection, "masters/1501/children"); + + await AssertResponseContent(response, @"Fixtures\FetchingResources\Get_related_to_many_integer_key_response.json", HttpStatusCode.OK); + } + } } } diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_integer_key_response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_integer_key_response.json new file mode 100644 index 00000000..f99bab69 --- /dev/null +++ b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_integer_key_response.json @@ -0,0 +1,34 @@ +{ + "data": [ + { + "type": "children", + "id": "7501", + "attributes": { + "child-description": "Child 2 Description" + }, + "relationships": { + "master": { + "links": { + "self": "https://www.example.com/children/7501/relationships/master", + "related": "https://www.example.com/children/7501/master" + } + } + } + }, + { + "type": "children", + "id": "7502", + "attributes": { + "child-description": "Child 3 Description" + }, + "relationships": { + "master": { + "links": { + "self": "https://www.example.com/children/7502/relationships/master", + "related": "https://www.example.com/children/7502/master" + } + } + } + } + ] +} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests.csproj b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests.csproj index 7f2a1699..f0cfb3c7 100644 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests.csproj +++ b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests.csproj @@ -123,6 +123,12 @@ + + Always + + + Always + Always @@ -233,6 +239,7 @@ + diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.csproj b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.csproj index 26e9df66..d7b1469b 100644 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.csproj +++ b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.csproj @@ -1,212 +1,214 @@ - - - - - Debug - AnyCPU - - - 2.0 - {76DEE472-723B-4BE6-8B97-428AC326E30F} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp - JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp - v4.5 - true - - - - - ..\ - true - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\ - TRACE - prompt - 4 - - - - False - ..\packages\Autofac.3.5.2\lib\net40\Autofac.dll - - - False - ..\packages\Autofac.Owin.3.1.0\lib\net45\Autofac.Integration.Owin.dll - - - False - ..\packages\Autofac.WebApi2.3.4.0\lib\net45\Autofac.Integration.WebApi.dll - - - False - ..\packages\Autofac.WebApi2.Owin.3.2.0\lib\net45\Autofac.Integration.WebApi.Owin.dll - - - False - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll - - - False - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll - - - - ..\packages\Microsoft.Owin.3.0.0\lib\net45\Microsoft.Owin.dll - - - ..\packages\Microsoft.Owin.Host.SystemWeb.3.0.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll - - - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - - - ..\packages\Owin.1.0\lib\net40\Owin.dll - - - - False - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll - - - - - - - - - - - - False - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll - - - ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.2\lib\net45\System.Web.Http.Owin.dll - - - - - - - - - - - - - Web.config - - - Web.config - - - - - Designer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {64abe648-efcb-46ee-9e1a-e163f52bf372} - JSONAPI.Autofac.EntityFramework - - - {af7861f3-550b-4f70-a33e-1e5f48d39333} - JSONAPI.Autofac - - - {e906356c-93f6-41f6-9a0d-73b8a99aa53c} - JSONAPI.EntityFramework - - - {52b19fd6-efaa-45b5-9c3e-a652e27608d1} - JSONAPI - - - - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - - - - - True - True - 9283 - / - http://localhost:9283/ - False - False - - - False - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + + + + + Debug + AnyCPU + + + 2.0 + {76DEE472-723B-4BE6-8B97-428AC326E30F} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp + JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp + v4.5 + true + + + + + ..\ + true + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + False + ..\packages\Autofac.3.5.2\lib\net40\Autofac.dll + + + False + ..\packages\Autofac.Owin.3.1.0\lib\net45\Autofac.Integration.Owin.dll + + + False + ..\packages\Autofac.WebApi2.3.4.0\lib\net45\Autofac.Integration.WebApi.dll + + + False + ..\packages\Autofac.WebApi2.Owin.3.2.0\lib\net45\Autofac.Integration.WebApi.Owin.dll + + + False + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll + + + False + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll + + + + ..\packages\Microsoft.Owin.3.0.0\lib\net45\Microsoft.Owin.dll + + + ..\packages\Microsoft.Owin.Host.SystemWeb.3.0.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll + + + False + ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Owin.1.0\lib\net40\Owin.dll + + + + False + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll + + + + + + + + + + + + False + ..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll + + + ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.2\lib\net45\System.Web.Http.Owin.dll + + + + + + + + + + + + + Web.config + + + Web.config + + + + + Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {64abe648-efcb-46ee-9e1a-e163f52bf372} + JSONAPI.Autofac.EntityFramework + + + {af7861f3-550b-4f70-a33e-1e5f48d39333} + JSONAPI.Autofac + + + {e906356c-93f6-41f6-9a0d-73b8a99aa53c} + JSONAPI.EntityFramework + + + {52b19fd6-efaa-45b5-9c3e-a652e27608d1} + JSONAPI + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 9283 + / + http://localhost:9283/ + False + False + + + False + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + --> \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Child.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Child.cs new file mode 100644 index 00000000..b3aefcc7 --- /dev/null +++ b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Child.cs @@ -0,0 +1,21 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Newtonsoft.Json; + +namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models +{ + public class Child + { + public int Id { get; set; } + + public string ChildDescription { get; set; } + + [Required] + [JsonIgnore] + public int MasterId { get; set; } + + [ForeignKey("MasterId")] + public Master Master { get; set; } + } +} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Master.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Master.cs new file mode 100644 index 00000000..5ad2015c --- /dev/null +++ b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Master.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models +{ + public class Master + { + public int Id { get; set; } + + public string Description { get; set; } + + public virtual ICollection Children { get; set; } + } +} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/TestDbContext.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/TestDbContext.cs index 7efbb549..d0d8aec8 100644 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/TestDbContext.cs +++ b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/TestDbContext.cs @@ -47,5 +47,7 @@ protected override void OnModelCreating(DbModelBuilder modelBuilder) public DbSet StarshipClasses { get; set; } public DbSet Officers { get; set; } public DbSet StarshipOfficerLinks { get; set; } + public DbSet Masters { get; set; } + public DbSet Children { get; set; } } } \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Startup.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Startup.cs index ae14df36..b4fee0ec 100644 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Startup.cs +++ b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Startup.cs @@ -13,6 +13,7 @@ using JSONAPI.EntityFramework; using JSONAPI.EntityFramework.Configuration; using Owin; +using System.Collections.Generic; namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp { @@ -33,7 +34,9 @@ public Startup(Func dbContextFactory) public void Configuration(IAppBuilder app) { - var configuration = new JsonApiConfiguration(); + var configuration = new JsonApiConfiguration( + new Core.PluralizationService( + new Dictionary { { "Child", "Children" } })); configuration.RegisterEntityFrameworkResourceType(); configuration.RegisterEntityFrameworkResourceType(); configuration.RegisterEntityFrameworkResourceType(); @@ -58,6 +61,8 @@ public void Configuration(IAppBuilder app) rc => rc.UseMaterializer()); }); // Example of a resource that is mapped from a DB entity configuration.RegisterResourceType(); + configuration.RegisterEntityFrameworkResourceType(); + configuration.RegisterEntityFrameworkResourceType(); var configurator = new JsonApiHttpAutofacConfigurator(); configurator.OnApplicationLifetimeScopeCreating(builder => From 81f368c91966e34c89e99f2ec9a9067973d59705 Mon Sep 17 00:00:00 2001 From: Clint Good Date: Thu, 21 Jul 2016 23:04:20 +1000 Subject: [PATCH 2/4] Fix to allow Get_related_to_many_integer_key to pass --- JSONAPI/Core/ResourceTypeRegistrar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JSONAPI/Core/ResourceTypeRegistrar.cs b/JSONAPI/Core/ResourceTypeRegistrar.cs index 742e025c..5b960a91 100644 --- a/JSONAPI/Core/ResourceTypeRegistrar.cs +++ b/JSONAPI/Core/ResourceTypeRegistrar.cs @@ -77,7 +77,7 @@ public IResourceTypeRegistration BuildRegistration(Type type, string resourceTyp filterByIdFactory = (param, id) => { var propertyExpr = Expression.Property(param, idProperty); - var idExpr = Expression.Constant(id); + var idExpr = Expression.Constant(Convert.ChangeType(id, idProperty.PropertyType)); return Expression.Equal(propertyExpr, idExpr); }; } From 3795948aaab9698e3e2445abe143f6a072bc6fad Mon Sep 17 00:00:00 2001 From: Clint Good Date: Sat, 6 Aug 2016 11:48:59 +1000 Subject: [PATCH 3/4] Revert "Add Master and Child test entities that use integer keys" This reverts commit 2545acc05196072cafe6e334f7db60200d76e4e7. --- .../Data/Child.csv | 7 - .../Data/Master.csv | 5 - .../FetchingResourcesTests.cs | 13 - ..._related_to_many_integer_key_response.json | 34 -- ...sts.EntityFrameworkTestWebApp.Tests.csproj | 7 - ...anceTests.EntityFrameworkTestWebApp.csproj | 412 +++++++++--------- .../Models/Child.cs | 21 - .../Models/Master.cs | 16 - .../Models/TestDbContext.cs | 2 - .../Startup.cs | 7 +- JSONAPI/Core/ResourceTypeRegistrar.cs | 2 +- 11 files changed, 207 insertions(+), 319 deletions(-) delete mode 100644 JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Child.csv delete mode 100644 JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Master.csv delete mode 100644 JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_integer_key_response.json delete mode 100644 JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Child.cs delete mode 100644 JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Master.cs diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Child.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Child.csv deleted file mode 100644 index b529aab6..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Child.csv +++ /dev/null @@ -1,7 +0,0 @@ -Id,ChildDescription,MasterId -7500,"Child 1 Description",1500 -7501,"Child 2 Description",1501 -7502,"Child 3 Description",1501 -7503,"Child 4 Description",1503 -7504,"Child 5 Description",1503 -7505,"Child 6 Description",1503 \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Master.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Master.csv deleted file mode 100644 index 2a582cc4..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Master.csv +++ /dev/null @@ -1,5 +0,0 @@ -Id,Description -1500,"Master 1 Description" -1501,"Master 2 Description" -1502,"Master 3 Description" -1503,"Master 4 Description" diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/FetchingResourcesTests.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/FetchingResourcesTests.cs index 36321862..5ec6cc98 100644 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/FetchingResourcesTests.cs +++ b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/FetchingResourcesTests.cs @@ -183,18 +183,5 @@ await AssertResponseContent(response, HttpStatusCode.OK); } } - - [TestMethod] - [DeploymentItem(@"Data\Master.csv", @"Data")] - [DeploymentItem(@"Data\Child.csv", @"Data")] - public async Task Get_related_to_many_integer_key() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "masters/1501/children"); - - await AssertResponseContent(response, @"Fixtures\FetchingResources\Get_related_to_many_integer_key_response.json", HttpStatusCode.OK); - } - } } } diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_integer_key_response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_integer_key_response.json deleted file mode 100644 index f99bab69..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_integer_key_response.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "data": [ - { - "type": "children", - "id": "7501", - "attributes": { - "child-description": "Child 2 Description" - }, - "relationships": { - "master": { - "links": { - "self": "https://www.example.com/children/7501/relationships/master", - "related": "https://www.example.com/children/7501/master" - } - } - } - }, - { - "type": "children", - "id": "7502", - "attributes": { - "child-description": "Child 3 Description" - }, - "relationships": { - "master": { - "links": { - "self": "https://www.example.com/children/7502/relationships/master", - "related": "https://www.example.com/children/7502/master" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests.csproj b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests.csproj index f0cfb3c7..7f2a1699 100644 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests.csproj +++ b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests.csproj @@ -123,12 +123,6 @@ - - Always - - - Always - Always @@ -239,7 +233,6 @@ - diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.csproj b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.csproj index d7b1469b..26e9df66 100644 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.csproj +++ b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.csproj @@ -1,214 +1,212 @@ - - - - - Debug - AnyCPU - - - 2.0 - {76DEE472-723B-4BE6-8B97-428AC326E30F} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp - JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp - v4.5 - true - - - - - ..\ - true - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\ - TRACE - prompt - 4 - - - - False - ..\packages\Autofac.3.5.2\lib\net40\Autofac.dll - - - False - ..\packages\Autofac.Owin.3.1.0\lib\net45\Autofac.Integration.Owin.dll - - - False - ..\packages\Autofac.WebApi2.3.4.0\lib\net45\Autofac.Integration.WebApi.dll - - - False - ..\packages\Autofac.WebApi2.Owin.3.2.0\lib\net45\Autofac.Integration.WebApi.Owin.dll - - - False - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll - - - False - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll - - - - ..\packages\Microsoft.Owin.3.0.0\lib\net45\Microsoft.Owin.dll - - - ..\packages\Microsoft.Owin.Host.SystemWeb.3.0.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll - - - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - - - ..\packages\Owin.1.0\lib\net40\Owin.dll - - - - False - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll - - - - - - - - - - - - False - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll - - - ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.2\lib\net45\System.Web.Http.Owin.dll - - - - - - - - - - - - - Web.config - - - Web.config - - - - - Designer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {64abe648-efcb-46ee-9e1a-e163f52bf372} - JSONAPI.Autofac.EntityFramework - - - {af7861f3-550b-4f70-a33e-1e5f48d39333} - JSONAPI.Autofac - - - {e906356c-93f6-41f6-9a0d-73b8a99aa53c} - JSONAPI.EntityFramework - - - {52b19fd6-efaa-45b5-9c3e-a652e27608d1} - JSONAPI - - - - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - - - - - True - True - 9283 - / - http://localhost:9283/ - False - False - - - False - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + + + + + Debug + AnyCPU + + + 2.0 + {76DEE472-723B-4BE6-8B97-428AC326E30F} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp + JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp + v4.5 + true + + + + + ..\ + true + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + False + ..\packages\Autofac.3.5.2\lib\net40\Autofac.dll + + + False + ..\packages\Autofac.Owin.3.1.0\lib\net45\Autofac.Integration.Owin.dll + + + False + ..\packages\Autofac.WebApi2.3.4.0\lib\net45\Autofac.Integration.WebApi.dll + + + False + ..\packages\Autofac.WebApi2.Owin.3.2.0\lib\net45\Autofac.Integration.WebApi.Owin.dll + + + False + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll + + + False + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll + + + + ..\packages\Microsoft.Owin.3.0.0\lib\net45\Microsoft.Owin.dll + + + ..\packages\Microsoft.Owin.Host.SystemWeb.3.0.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll + + + False + ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Owin.1.0\lib\net40\Owin.dll + + + + False + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll + + + + + + + + + + + + False + ..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll + + + ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.2\lib\net45\System.Web.Http.Owin.dll + + + + + + + + + + + + + Web.config + + + Web.config + + + + + Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {64abe648-efcb-46ee-9e1a-e163f52bf372} + JSONAPI.Autofac.EntityFramework + + + {af7861f3-550b-4f70-a33e-1e5f48d39333} + JSONAPI.Autofac + + + {e906356c-93f6-41f6-9a0d-73b8a99aa53c} + JSONAPI.EntityFramework + + + {52b19fd6-efaa-45b5-9c3e-a652e27608d1} + JSONAPI + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 9283 + / + http://localhost:9283/ + False + False + + + False + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + --> \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Child.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Child.cs deleted file mode 100644 index b3aefcc7..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Child.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using Newtonsoft.Json; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class Child - { - public int Id { get; set; } - - public string ChildDescription { get; set; } - - [Required] - [JsonIgnore] - public int MasterId { get; set; } - - [ForeignKey("MasterId")] - public Master Master { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Master.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Master.cs deleted file mode 100644 index 5ad2015c..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Master.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class Master - { - public int Id { get; set; } - - public string Description { get; set; } - - public virtual ICollection Children { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/TestDbContext.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/TestDbContext.cs index d0d8aec8..7efbb549 100644 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/TestDbContext.cs +++ b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/TestDbContext.cs @@ -47,7 +47,5 @@ protected override void OnModelCreating(DbModelBuilder modelBuilder) public DbSet StarshipClasses { get; set; } public DbSet Officers { get; set; } public DbSet StarshipOfficerLinks { get; set; } - public DbSet Masters { get; set; } - public DbSet Children { get; set; } } } \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Startup.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Startup.cs index b4fee0ec..ae14df36 100644 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Startup.cs +++ b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Startup.cs @@ -13,7 +13,6 @@ using JSONAPI.EntityFramework; using JSONAPI.EntityFramework.Configuration; using Owin; -using System.Collections.Generic; namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp { @@ -34,9 +33,7 @@ public Startup(Func dbContextFactory) public void Configuration(IAppBuilder app) { - var configuration = new JsonApiConfiguration( - new Core.PluralizationService( - new Dictionary { { "Child", "Children" } })); + var configuration = new JsonApiConfiguration(); configuration.RegisterEntityFrameworkResourceType(); configuration.RegisterEntityFrameworkResourceType(); configuration.RegisterEntityFrameworkResourceType(); @@ -61,8 +58,6 @@ public void Configuration(IAppBuilder app) rc => rc.UseMaterializer()); }); // Example of a resource that is mapped from a DB entity configuration.RegisterResourceType(); - configuration.RegisterEntityFrameworkResourceType(); - configuration.RegisterEntityFrameworkResourceType(); var configurator = new JsonApiHttpAutofacConfigurator(); configurator.OnApplicationLifetimeScopeCreating(builder => diff --git a/JSONAPI/Core/ResourceTypeRegistrar.cs b/JSONAPI/Core/ResourceTypeRegistrar.cs index 5b960a91..742e025c 100644 --- a/JSONAPI/Core/ResourceTypeRegistrar.cs +++ b/JSONAPI/Core/ResourceTypeRegistrar.cs @@ -77,7 +77,7 @@ public IResourceTypeRegistration BuildRegistration(Type type, string resourceTyp filterByIdFactory = (param, id) => { var propertyExpr = Expression.Property(param, idProperty); - var idExpr = Expression.Constant(Convert.ChangeType(id, idProperty.PropertyType)); + var idExpr = Expression.Constant(id); return Expression.Equal(propertyExpr, idExpr); }; } From 12716855770bbe4e1ba731acf50b1f4722d63205 Mon Sep 17 00:00:00 2001 From: Clint Good Date: Mon, 22 May 2017 07:46:11 +1000 Subject: [PATCH 4/4] Exploring extracting WebApi dependency --- JSONAPI.Autofac/JsonApiAutofacModule.cs | 11 +- .../DefaultFilteringTransformerTests.cs | 2 +- .../DefaultPaginationTransformerTests.cs | 4 +- .../FallbackDocumentBuilderAttributeTests.cs | 10 +- .../QueryableTransformerTestsBase.cs | 4 +- .../Core/ResourceTypeRegistryTests.cs | 18 ++ .../Documents/DefaultLinkConventionsTests.cs | 4 +- JSONAPI.sln | 305 +++++++++++++++++- .../FallbackDocumentBuilderAttribute.cs | 4 +- .../JsonApiExceptionFilterAttribute.cs | 4 +- ...ryableResourceCollectionDocumentBuilder.cs | 13 +- .../Builders/ErrorDocumentBuilder.cs | 5 + .../Builders/FallbackDocumentBuilder.cs | 12 +- .../Builders/IErrorDocumentBuilder.cs | 43 +-- .../Builders/IFallbackDocumentBuilder.cs | 7 +- ...ryableResourceCollectionDocumentBuilder.cs | 9 +- JSONAPI/Extensions/QueryableExtensions.cs | 10 +- JSONAPI/Http/BaseUrlService.cs | 6 +- .../Http/DefaultIncludeExpressionExtractor.cs | 8 +- .../Http/DefaultSortExpressionExtractor.cs | 8 +- JSONAPI/Http/IBaseUrlService.cs | 2 +- JSONAPI/Http/IDocumentMaterializer.cs | 8 +- JSONAPI/Http/IIncludeExpressionExtractor.cs | 7 +- .../IRelatedResourceDocumentMaterializer.cs | 6 +- JSONAPI/Http/ISortExpressionExtractor.cs | 6 +- JSONAPI/Http/JsonApiController.cs | 85 ----- JSONAPI/Http/MappedDocumentMaterializer.cs | 14 +- ...ManyRelatedResourceDocumentMaterializer.cs | 16 +- ...oOneRelatedResourceDocumentMaterializer.cs | 81 ++--- JSONAPI/JSONAPI.csproj | 9 - JSONAPI/Json/JsonApiFormatter.cs | 2 + .../DefaultFilteringTransformer.cs | 12 +- .../DefaultPaginationTransformResult.cs | 2 +- .../DefaultPaginationTransformer.cs | 193 +++++------ .../IQueryableFilteringTransformer.cs | 7 +- .../IQueryablePaginationTransformer.cs | 7 +- 36 files changed, 591 insertions(+), 353 deletions(-) delete mode 100644 JSONAPI/Http/JsonApiController.cs diff --git a/JSONAPI.Autofac/JsonApiAutofacModule.cs b/JSONAPI.Autofac/JsonApiAutofacModule.cs index dd248aa8..1151dda7 100644 --- a/JSONAPI.Autofac/JsonApiAutofacModule.cs +++ b/JSONAPI.Autofac/JsonApiAutofacModule.cs @@ -1,7 +1,7 @@ using System; using Autofac; using Autofac.Core; -using JSONAPI.ActionFilters; +//using JSONAPI.ActionFilters; using JSONAPI.Configuration; using JSONAPI.Core; using JSONAPI.Documents; @@ -125,7 +125,8 @@ protected override void Load(ContainerBuilder builder) return factory; }); - builder.RegisterType().SingleInstance(); + // TODO + // builder.RegisterType().SingleInstance(); if (_jsonApiConfiguration.CustomBaseUrlService != null) { builder.Register(c => _jsonApiConfiguration.CustomBaseUrlService).As().SingleInstance(); @@ -160,8 +161,10 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); - builder.RegisterType().SingleInstance(); - builder.RegisterType().SingleInstance(); + + //TODO + //builder.RegisterType().SingleInstance(); + //builder.RegisterType().SingleInstance(); builder.RegisterType().As(); // Misc diff --git a/JSONAPI.Tests/ActionFilters/DefaultFilteringTransformerTests.cs b/JSONAPI.Tests/ActionFilters/DefaultFilteringTransformerTests.cs index 6b458e2a..aa8d2991 100644 --- a/JSONAPI.Tests/ActionFilters/DefaultFilteringTransformerTests.cs +++ b/JSONAPI.Tests/ActionFilters/DefaultFilteringTransformerTests.cs @@ -7,7 +7,7 @@ using System.Threading; using System.Web.Http; using FluentAssertions; -using JSONAPI.ActionFilters; +//using JSONAPI.ActionFilters; using JSONAPI.Core; using JSONAPI.Documents.Builders; using JSONAPI.QueryableTransformers; diff --git a/JSONAPI.Tests/ActionFilters/DefaultPaginationTransformerTests.cs b/JSONAPI.Tests/ActionFilters/DefaultPaginationTransformerTests.cs index 8cb1e0af..3925c835 100644 --- a/JSONAPI.Tests/ActionFilters/DefaultPaginationTransformerTests.cs +++ b/JSONAPI.Tests/ActionFilters/DefaultPaginationTransformerTests.cs @@ -5,7 +5,7 @@ using System.Net.Http; using System.Web.Http; using FluentAssertions; -using JSONAPI.ActionFilters; +//using JSONAPI.ActionFilters; using JSONAPI.Core; using JSONAPI.Documents.Builders; using JSONAPI.QueryableTransformers; @@ -56,7 +56,7 @@ private DefaultPaginationTransformer GetTransformer(int maxPageSize) private Dummy[] GetArray(string uri, int maxPageSize = 50) { var request = new HttpRequestMessage(HttpMethod.Get, uri); - return GetTransformer(maxPageSize).ApplyPagination(_fixturesQuery, request).PagedQuery.ToArray(); + return GetTransformer(maxPageSize).ApplyPagination(_fixturesQuery, request.GetQueryNameValuePairs()).PagedQuery.ToArray(); } [TestMethod] diff --git a/JSONAPI.Tests/ActionFilters/FallbackDocumentBuilderAttributeTests.cs b/JSONAPI.Tests/ActionFilters/FallbackDocumentBuilderAttributeTests.cs index 49a87216..228c4679 100644 --- a/JSONAPI.Tests/ActionFilters/FallbackDocumentBuilderAttributeTests.cs +++ b/JSONAPI.Tests/ActionFilters/FallbackDocumentBuilderAttributeTests.cs @@ -9,7 +9,7 @@ using System.Web.Http.Controllers; using System.Web.Http.Filters; using FluentAssertions; -using JSONAPI.ActionFilters; +//using JSONAPI.ActionFilters; using JSONAPI.Documents; using JSONAPI.Documents.Builders; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -33,6 +33,7 @@ private HttpActionExecutedContext GetActionExecutedContext(object objectContentV return new HttpActionExecutedContext(actionContext, exception); } + /* TODO [TestMethod] public void OnActionExecutedAsync_leaves_ISingleResourceDocument_alone() { @@ -70,7 +71,7 @@ public void OnActionExecutedAsync_leaves_IResourceCollectionDocument_alone() ((ObjectContent)actionExecutedContext.Response.Content).Value.Should().BeSameAs(mockDocument.Object); actionExecutedContext.Response.StatusCode.Should().Be(HttpStatusCode.OK); } - + [TestMethod] public void OnActionExecutedAsync_leaves_IErrorDocument_alone_but_changes_request_status_to_match_error_status() { @@ -113,11 +114,14 @@ public void OnActionExecutedAsync_does_nothing_if_there_is_an_exception() newObjectContent.Should().BeSameAs(objectContent); actionExecutedContext.Exception.Should().Be(theException); } + + */ private class Fruit { } + /* TODO [TestMethod] public void OnActionExecutedAsync_delegates_to_fallback_document_builder_for_unknown_types() { @@ -169,5 +173,7 @@ public void OnActionExecutedAsync_creates_IErrorDocument_for_HttpError() ((ObjectContent)actionExecutedContext.Response.Content).Value.Should().BeSameAs(mockResult.Object); actionExecutedContext.Response.StatusCode.Should().Be(HttpStatusCode.OK); } + + */ } } diff --git a/JSONAPI.Tests/ActionFilters/QueryableTransformerTestsBase.cs b/JSONAPI.Tests/ActionFilters/QueryableTransformerTestsBase.cs index adba3c0a..27a93eef 100644 --- a/JSONAPI.Tests/ActionFilters/QueryableTransformerTestsBase.cs +++ b/JSONAPI.Tests/ActionFilters/QueryableTransformerTestsBase.cs @@ -1,6 +1,6 @@ using System.Linq; using System.Net.Http; -using JSONAPI.ActionFilters; +//using JSONAPI.ActionFilters; using JSONAPI.QueryableTransformers; namespace JSONAPI.Tests.ActionFilters @@ -10,7 +10,7 @@ public abstract class QueryableTransformerTestsBase internal IQueryable Transform(IQueryableFilteringTransformer filteringTransformer, IQueryable query, string uri) { var request = new HttpRequestMessage(HttpMethod.Get, uri); - return filteringTransformer.Filter(query, request); + return filteringTransformer.Filter(query, request.GetQueryNameValuePairs()); } } } diff --git a/JSONAPI.Tests/Core/ResourceTypeRegistryTests.cs b/JSONAPI.Tests/Core/ResourceTypeRegistryTests.cs index 7ffdb336..a6cded0a 100644 --- a/JSONAPI.Tests/Core/ResourceTypeRegistryTests.cs +++ b/JSONAPI.Tests/Core/ResourceTypeRegistryTests.cs @@ -163,5 +163,23 @@ public void TypeIsRegistered_returns_false_if_no_type_in_hierarchy_is_registered // Assert isRegistered.Should().BeFalse(); } + + [TestMethod] + public void TypeIsRegistered_returns_false_if_unrelated_type_is_registered() + { + // Arrange + var mockPostRegistration = new Mock(MockBehavior.Strict); + mockPostRegistration.Setup(m => m.Type).Returns(typeof(Post)); + mockPostRegistration.Setup(m => m.ResourceTypeName).Returns("posts"); + + var registry = new ResourceTypeRegistry(); + registry.AddRegistration(mockPostRegistration.Object); + + // Act + var isRegistered = registry.TypeIsRegistered(typeof(Comment)); + + // Assert + isRegistered.Should().BeFalse(); + } } } diff --git a/JSONAPI.Tests/Documents/DefaultLinkConventionsTests.cs b/JSONAPI.Tests/Documents/DefaultLinkConventionsTests.cs index f34c93bd..a2fce9a1 100644 --- a/JSONAPI.Tests/Documents/DefaultLinkConventionsTests.cs +++ b/JSONAPI.Tests/Documents/DefaultLinkConventionsTests.cs @@ -39,7 +39,7 @@ public void GetRelationshipLink_returns_default_url_for_relationship() var conventions = new DefaultLinkConventions(); var relationshipLink = conventions.GetRelationshipLink(relationshipOwner, mockRegistry.Object, relationshipProperty, "https://www.example.com"); - // Assert + // Asserte relationshipLink.Href.Should().Be("https://www.example.com/countries/45/relationships/cities"); } @@ -180,7 +180,7 @@ public void GetRelatedResourceLink_is_correct_if_template_is_present_and_base_ur // Act var conventions = new DefaultLinkConventions(); - var relationshipLink = conventions.GetRelatedResourceLink(relationshipOwner, mockRegistry.Object, relationshipProperty, "https://www.example.com"); + var relationshipLink = conventions.GetRelatedResourceLink(relationshipOwner, mockRegistry.Object, relationshipProperty, "https://www.example.com/"); // Assert relationshipLink.Href.Should().Be("https://www.example.com/bar/45/qux"); diff --git a/JSONAPI.sln b/JSONAPI.sln index 07c3e3b5..9eb00742 100644 --- a/JSONAPI.sln +++ b/JSONAPI.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26403.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONAPI", "JSONAPI\JSONAPI.csproj", "{52B19FD6-EFAA-45B5-9C3E-A652E27608D1}" EndProject @@ -35,52 +35,335 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONAPI.AcceptanceTests.Ent EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONAPI.Autofac.Tests", "JSONAPI.Autofac.Tests\JSONAPI.Autofac.Tests.csproj", "{AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONAPI.WebApi", "JSONAPI.WebApi\JSONAPI.WebApi.csproj", "{6CE7F3BD-2D61-44C3-828F-15D073C30690}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Osx_Debug|Any CPU = Osx_Debug|Any CPU + Osx_Debug|ARM = Osx_Debug|ARM + Osx_Debug|x64 = Osx_Debug|x64 + Osx_Debug|x86 = Osx_Debug|x86 + Osx_Release|Any CPU = Osx_Release|Any CPU + Osx_Release|ARM = Osx_Release|ARM + Osx_Release|x64 = Osx_Release|x64 + Osx_Release|x86 = Osx_Release|x86 Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + Ubuntu_Debug|Any CPU = Ubuntu_Debug|Any CPU + Ubuntu_Debug|ARM = Ubuntu_Debug|ARM + Ubuntu_Debug|x64 = Ubuntu_Debug|x64 + Ubuntu_Debug|x86 = Ubuntu_Debug|x86 + Ubuntu_Release|Any CPU = Ubuntu_Release|Any CPU + Ubuntu_Release|ARM = Ubuntu_Release|ARM + Ubuntu_Release|x64 = Ubuntu_Release|x64 + Ubuntu_Release|x86 = Ubuntu_Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Debug|ARM.ActiveCfg = Debug|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Debug|x64.ActiveCfg = Debug|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Debug|x86.ActiveCfg = Debug|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Osx_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Osx_Debug|ARM.ActiveCfg = Debug|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Osx_Debug|x64.ActiveCfg = Debug|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Osx_Debug|x86.ActiveCfg = Debug|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Osx_Release|Any CPU.ActiveCfg = Release|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Osx_Release|ARM.ActiveCfg = Release|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Osx_Release|x64.ActiveCfg = Release|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Osx_Release|x86.ActiveCfg = Release|Any CPU {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Release|Any CPU.ActiveCfg = Release|Any CPU {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Release|Any CPU.Build.0 = Release|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Release|ARM.ActiveCfg = Release|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Release|x64.ActiveCfg = Release|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Release|x86.ActiveCfg = Release|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Ubuntu_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Ubuntu_Debug|ARM.ActiveCfg = Debug|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Ubuntu_Debug|x64.ActiveCfg = Debug|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Ubuntu_Debug|x86.ActiveCfg = Debug|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Ubuntu_Release|Any CPU.ActiveCfg = Release|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Ubuntu_Release|ARM.ActiveCfg = Release|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Ubuntu_Release|x64.ActiveCfg = Release|Any CPU + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Ubuntu_Release|x86.ActiveCfg = Release|Any CPU {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Debug|ARM.ActiveCfg = Debug|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Debug|x64.ActiveCfg = Debug|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Debug|x86.ActiveCfg = Debug|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Osx_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Osx_Debug|ARM.ActiveCfg = Debug|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Osx_Debug|x64.ActiveCfg = Debug|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Osx_Debug|x86.ActiveCfg = Debug|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Osx_Release|Any CPU.ActiveCfg = Release|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Osx_Release|ARM.ActiveCfg = Release|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Osx_Release|x64.ActiveCfg = Release|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Osx_Release|x86.ActiveCfg = Release|Any CPU {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Release|Any CPU.ActiveCfg = Release|Any CPU {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Release|Any CPU.Build.0 = Release|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Release|ARM.ActiveCfg = Release|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Release|x64.ActiveCfg = Release|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Release|x86.ActiveCfg = Release|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Ubuntu_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Ubuntu_Debug|ARM.ActiveCfg = Debug|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Ubuntu_Debug|x64.ActiveCfg = Debug|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Ubuntu_Debug|x86.ActiveCfg = Debug|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Ubuntu_Release|Any CPU.ActiveCfg = Release|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Ubuntu_Release|ARM.ActiveCfg = Release|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Ubuntu_Release|x64.ActiveCfg = Release|Any CPU + {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Ubuntu_Release|x86.ActiveCfg = Release|Any CPU {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Debug|ARM.ActiveCfg = Debug|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Debug|x64.ActiveCfg = Debug|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Debug|x86.ActiveCfg = Debug|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Osx_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Osx_Debug|ARM.ActiveCfg = Debug|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Osx_Debug|x64.ActiveCfg = Debug|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Osx_Debug|x86.ActiveCfg = Debug|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Osx_Release|Any CPU.ActiveCfg = Release|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Osx_Release|ARM.ActiveCfg = Release|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Osx_Release|x64.ActiveCfg = Release|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Osx_Release|x86.ActiveCfg = Release|Any CPU {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Release|Any CPU.ActiveCfg = Release|Any CPU {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Release|Any CPU.Build.0 = Release|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Release|ARM.ActiveCfg = Release|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Release|x64.ActiveCfg = Release|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Release|x86.ActiveCfg = Release|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Ubuntu_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Ubuntu_Debug|ARM.ActiveCfg = Debug|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Ubuntu_Debug|x64.ActiveCfg = Debug|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Ubuntu_Debug|x86.ActiveCfg = Debug|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Ubuntu_Release|Any CPU.ActiveCfg = Release|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Ubuntu_Release|ARM.ActiveCfg = Release|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Ubuntu_Release|x64.ActiveCfg = Release|Any CPU + {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Ubuntu_Release|x86.ActiveCfg = Release|Any CPU {00655E05-F1BB-425D-92F3-659EFB581439}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {00655E05-F1BB-425D-92F3-659EFB581439}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Debug|ARM.ActiveCfg = Debug|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Debug|x64.ActiveCfg = Debug|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Debug|x86.ActiveCfg = Debug|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Osx_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Osx_Debug|ARM.ActiveCfg = Debug|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Osx_Debug|x64.ActiveCfg = Debug|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Osx_Debug|x86.ActiveCfg = Debug|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Osx_Release|Any CPU.ActiveCfg = Release|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Osx_Release|ARM.ActiveCfg = Release|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Osx_Release|x64.ActiveCfg = Release|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Osx_Release|x86.ActiveCfg = Release|Any CPU {00655E05-F1BB-425D-92F3-659EFB581439}.Release|Any CPU.ActiveCfg = Release|Any CPU {00655E05-F1BB-425D-92F3-659EFB581439}.Release|Any CPU.Build.0 = Release|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Release|ARM.ActiveCfg = Release|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Release|x64.ActiveCfg = Release|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Release|x86.ActiveCfg = Release|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Ubuntu_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Ubuntu_Debug|ARM.ActiveCfg = Debug|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Ubuntu_Debug|x64.ActiveCfg = Debug|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Ubuntu_Debug|x86.ActiveCfg = Debug|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Ubuntu_Release|Any CPU.ActiveCfg = Release|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Ubuntu_Release|ARM.ActiveCfg = Release|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Ubuntu_Release|x64.ActiveCfg = Release|Any CPU + {00655E05-F1BB-425D-92F3-659EFB581439}.Ubuntu_Release|x86.ActiveCfg = Release|Any CPU {ECFA3EC5-47B8-4060-925E-9205146D6562}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ECFA3EC5-47B8-4060-925E-9205146D6562}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Debug|ARM.ActiveCfg = Debug|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Debug|x64.ActiveCfg = Debug|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Debug|x86.ActiveCfg = Debug|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Osx_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Osx_Debug|ARM.ActiveCfg = Debug|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Osx_Debug|x64.ActiveCfg = Debug|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Osx_Debug|x86.ActiveCfg = Debug|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Osx_Release|Any CPU.ActiveCfg = Release|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Osx_Release|ARM.ActiveCfg = Release|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Osx_Release|x64.ActiveCfg = Release|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Osx_Release|x86.ActiveCfg = Release|Any CPU {ECFA3EC5-47B8-4060-925E-9205146D6562}.Release|Any CPU.ActiveCfg = Release|Any CPU {ECFA3EC5-47B8-4060-925E-9205146D6562}.Release|Any CPU.Build.0 = Release|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Release|ARM.ActiveCfg = Release|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Release|x64.ActiveCfg = Release|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Release|x86.ActiveCfg = Release|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Ubuntu_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Ubuntu_Debug|ARM.ActiveCfg = Debug|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Ubuntu_Debug|x64.ActiveCfg = Debug|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Ubuntu_Debug|x86.ActiveCfg = Debug|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Ubuntu_Release|Any CPU.ActiveCfg = Release|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Ubuntu_Release|ARM.ActiveCfg = Release|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Ubuntu_Release|x64.ActiveCfg = Release|Any CPU + {ECFA3EC5-47B8-4060-925E-9205146D6562}.Ubuntu_Release|x86.ActiveCfg = Release|Any CPU {76DEE472-723B-4BE6-8B97-428AC326E30F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {76DEE472-723B-4BE6-8B97-428AC326E30F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Debug|ARM.ActiveCfg = Debug|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Debug|x64.ActiveCfg = Debug|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Debug|x86.ActiveCfg = Debug|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Osx_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Osx_Debug|ARM.ActiveCfg = Debug|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Osx_Debug|x64.ActiveCfg = Debug|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Osx_Debug|x86.ActiveCfg = Debug|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Osx_Release|Any CPU.ActiveCfg = Release|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Osx_Release|ARM.ActiveCfg = Release|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Osx_Release|x64.ActiveCfg = Release|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Osx_Release|x86.ActiveCfg = Release|Any CPU {76DEE472-723B-4BE6-8B97-428AC326E30F}.Release|Any CPU.ActiveCfg = Release|Any CPU {76DEE472-723B-4BE6-8B97-428AC326E30F}.Release|Any CPU.Build.0 = Release|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Release|ARM.ActiveCfg = Release|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Release|x64.ActiveCfg = Release|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Release|x86.ActiveCfg = Release|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Ubuntu_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Ubuntu_Debug|ARM.ActiveCfg = Debug|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Ubuntu_Debug|x64.ActiveCfg = Debug|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Ubuntu_Debug|x86.ActiveCfg = Debug|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Ubuntu_Release|Any CPU.ActiveCfg = Release|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Ubuntu_Release|ARM.ActiveCfg = Release|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Ubuntu_Release|x64.ActiveCfg = Release|Any CPU + {76DEE472-723B-4BE6-8B97-428AC326E30F}.Ubuntu_Release|x86.ActiveCfg = Release|Any CPU {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Debug|ARM.ActiveCfg = Debug|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Debug|x64.ActiveCfg = Debug|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Debug|x86.ActiveCfg = Debug|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Osx_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Osx_Debug|ARM.ActiveCfg = Debug|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Osx_Debug|x64.ActiveCfg = Debug|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Osx_Debug|x86.ActiveCfg = Debug|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Osx_Release|Any CPU.ActiveCfg = Release|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Osx_Release|ARM.ActiveCfg = Release|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Osx_Release|x64.ActiveCfg = Release|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Osx_Release|x86.ActiveCfg = Release|Any CPU {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Release|Any CPU.ActiveCfg = Release|Any CPU {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Release|Any CPU.Build.0 = Release|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Release|ARM.ActiveCfg = Release|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Release|x64.ActiveCfg = Release|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Release|x86.ActiveCfg = Release|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Ubuntu_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Ubuntu_Debug|ARM.ActiveCfg = Debug|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Ubuntu_Debug|x64.ActiveCfg = Debug|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Ubuntu_Debug|x86.ActiveCfg = Debug|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Ubuntu_Release|Any CPU.ActiveCfg = Release|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Ubuntu_Release|ARM.ActiveCfg = Release|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Ubuntu_Release|x64.ActiveCfg = Release|Any CPU + {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Ubuntu_Release|x86.ActiveCfg = Release|Any CPU {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Debug|Any CPU.Build.0 = Debug|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Debug|ARM.ActiveCfg = Debug|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Debug|x64.ActiveCfg = Debug|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Debug|x86.ActiveCfg = Debug|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Osx_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Osx_Debug|ARM.ActiveCfg = Debug|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Osx_Debug|x64.ActiveCfg = Debug|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Osx_Debug|x86.ActiveCfg = Debug|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Osx_Release|Any CPU.ActiveCfg = Release|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Osx_Release|ARM.ActiveCfg = Release|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Osx_Release|x64.ActiveCfg = Release|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Osx_Release|x86.ActiveCfg = Release|Any CPU {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Release|Any CPU.ActiveCfg = Release|Any CPU {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Release|Any CPU.Build.0 = Release|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Release|ARM.ActiveCfg = Release|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Release|x64.ActiveCfg = Release|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Release|x86.ActiveCfg = Release|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Ubuntu_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Ubuntu_Debug|ARM.ActiveCfg = Debug|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Ubuntu_Debug|x64.ActiveCfg = Debug|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Ubuntu_Debug|x86.ActiveCfg = Debug|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Ubuntu_Release|Any CPU.ActiveCfg = Release|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Ubuntu_Release|ARM.ActiveCfg = Release|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Ubuntu_Release|x64.ActiveCfg = Release|Any CPU + {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Ubuntu_Release|x86.ActiveCfg = Release|Any CPU {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Debug|ARM.ActiveCfg = Debug|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Debug|x64.ActiveCfg = Debug|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Debug|x86.ActiveCfg = Debug|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Osx_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Osx_Debug|ARM.ActiveCfg = Debug|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Osx_Debug|x64.ActiveCfg = Debug|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Osx_Debug|x86.ActiveCfg = Debug|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Osx_Release|Any CPU.ActiveCfg = Release|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Osx_Release|ARM.ActiveCfg = Release|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Osx_Release|x64.ActiveCfg = Release|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Osx_Release|x86.ActiveCfg = Release|Any CPU {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Release|Any CPU.ActiveCfg = Release|Any CPU {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Release|Any CPU.Build.0 = Release|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Release|ARM.ActiveCfg = Release|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Release|x64.ActiveCfg = Release|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Release|x86.ActiveCfg = Release|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Ubuntu_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Ubuntu_Debug|ARM.ActiveCfg = Debug|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Ubuntu_Debug|x64.ActiveCfg = Debug|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Ubuntu_Debug|x86.ActiveCfg = Debug|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Ubuntu_Release|Any CPU.ActiveCfg = Release|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Ubuntu_Release|ARM.ActiveCfg = Release|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Ubuntu_Release|x64.ActiveCfg = Release|Any CPU + {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Ubuntu_Release|x86.ActiveCfg = Release|Any CPU {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Debug|ARM.ActiveCfg = Debug|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Debug|x64.ActiveCfg = Debug|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Debug|x86.ActiveCfg = Debug|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Osx_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Osx_Debug|ARM.ActiveCfg = Debug|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Osx_Debug|x64.ActiveCfg = Debug|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Osx_Debug|x86.ActiveCfg = Debug|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Osx_Release|Any CPU.ActiveCfg = Release|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Osx_Release|ARM.ActiveCfg = Release|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Osx_Release|x64.ActiveCfg = Release|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Osx_Release|x86.ActiveCfg = Release|Any CPU {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Release|Any CPU.ActiveCfg = Release|Any CPU {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Release|Any CPU.Build.0 = Release|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Release|ARM.ActiveCfg = Release|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Release|x64.ActiveCfg = Release|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Release|x86.ActiveCfg = Release|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Ubuntu_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Ubuntu_Debug|ARM.ActiveCfg = Debug|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Ubuntu_Debug|x64.ActiveCfg = Debug|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Ubuntu_Debug|x86.ActiveCfg = Debug|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Ubuntu_Release|Any CPU.ActiveCfg = Release|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Ubuntu_Release|ARM.ActiveCfg = Release|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Ubuntu_Release|x64.ActiveCfg = Release|Any CPU + {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Ubuntu_Release|x86.ActiveCfg = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Debug|ARM.ActiveCfg = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Debug|ARM.Build.0 = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Debug|x64.ActiveCfg = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Debug|x64.Build.0 = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Debug|x86.ActiveCfg = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Debug|x86.Build.0 = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Debug|Any CPU.Build.0 = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Debug|ARM.ActiveCfg = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Debug|ARM.Build.0 = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Debug|x64.ActiveCfg = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Debug|x64.Build.0 = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Debug|x86.ActiveCfg = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Debug|x86.Build.0 = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Release|Any CPU.ActiveCfg = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Release|Any CPU.Build.0 = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Release|ARM.ActiveCfg = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Release|ARM.Build.0 = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Release|x64.ActiveCfg = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Release|x64.Build.0 = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Release|x86.ActiveCfg = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Osx_Release|x86.Build.0 = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Release|Any CPU.Build.0 = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Release|ARM.ActiveCfg = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Release|ARM.Build.0 = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Release|x64.ActiveCfg = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Release|x64.Build.0 = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Release|x86.ActiveCfg = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Release|x86.Build.0 = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Debug|Any CPU.Build.0 = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Debug|ARM.ActiveCfg = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Debug|ARM.Build.0 = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Debug|x64.ActiveCfg = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Debug|x64.Build.0 = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Debug|x86.ActiveCfg = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Debug|x86.Build.0 = Debug|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Release|Any CPU.ActiveCfg = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Release|Any CPU.Build.0 = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Release|ARM.ActiveCfg = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Release|ARM.Build.0 = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Release|x64.ActiveCfg = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Release|x64.Build.0 = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Release|x86.ActiveCfg = Release|Any CPU + {6CE7F3BD-2D61-44C3-828F-15D073C30690}.Ubuntu_Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/JSONAPI/ActionFilters/FallbackDocumentBuilderAttribute.cs b/JSONAPI/ActionFilters/FallbackDocumentBuilderAttribute.cs index 405cf3c1..aa82e374 100644 --- a/JSONAPI/ActionFilters/FallbackDocumentBuilderAttribute.cs +++ b/JSONAPI/ActionFilters/FallbackDocumentBuilderAttribute.cs @@ -4,10 +4,11 @@ using System.Threading; using System.Threading.Tasks; using System.Web.Http; -using System.Web.Http.Filters; +//using System.Web.Http.Filters; using JSONAPI.Documents; using JSONAPI.Documents.Builders; +/* namespace JSONAPI.ActionFilters { /// @@ -88,3 +89,4 @@ public override async Task OnActionExecutedAsync(HttpActionExecutedContext actio } } } +*/ \ No newline at end of file diff --git a/JSONAPI/ActionFilters/JsonApiExceptionFilterAttribute.cs b/JSONAPI/ActionFilters/JsonApiExceptionFilterAttribute.cs index be96b26e..8b8d58a3 100644 --- a/JSONAPI/ActionFilters/JsonApiExceptionFilterAttribute.cs +++ b/JSONAPI/ActionFilters/JsonApiExceptionFilterAttribute.cs @@ -1,10 +1,11 @@ using System.Linq; using System.Net; using System.Net.Http; -using System.Web.Http.Filters; +//using System.Web.Http.Filters; using JSONAPI.Documents.Builders; using JSONAPI.Json; +/* namespace JSONAPI.ActionFilters { /// @@ -41,3 +42,4 @@ public override void OnException(HttpActionExecutedContext actionExecutedContext } } } +*/ \ No newline at end of file diff --git a/JSONAPI/Documents/Builders/DefaultQueryableResourceCollectionDocumentBuilder.cs b/JSONAPI/Documents/Builders/DefaultQueryableResourceCollectionDocumentBuilder.cs index d0488b1c..cefea72e 100644 --- a/JSONAPI/Documents/Builders/DefaultQueryableResourceCollectionDocumentBuilder.cs +++ b/JSONAPI/Documents/Builders/DefaultQueryableResourceCollectionDocumentBuilder.cs @@ -4,7 +4,8 @@ using System.Threading.Tasks; using JSONAPI.Http; using JSONAPI.QueryableTransformers; - +using System.Collections.Generic; + namespace JSONAPI.Documents.Builders { /// @@ -38,16 +39,16 @@ public DefaultQueryableResourceCollectionDocumentBuilder( _baseUrlService = baseUrlService; } - public async Task BuildDocument(IQueryable query, HttpRequestMessage request, string[] sortExpressions, CancellationToken cancellationToken, - string[] includes = null) + public async Task BuildDocument(IQueryable query, IEnumerable> requestParams, + System.Uri requestUri, string[] sortExpressions, CancellationToken cancellationToken, string[] includes = null) { - var filteredQuery = _filteringTransformer.Filter(query, request); + var filteredQuery = _filteringTransformer.Filter(query, requestParams); var sortedQuery = _sortingTransformer.Sort(filteredQuery, sortExpressions); - var paginationResults = _paginationTransformer.ApplyPagination(sortedQuery, request); + var paginationResults = _paginationTransformer.ApplyPagination(sortedQuery, requestParams); var paginatedQuery = paginationResults.PagedQuery; - var linkBaseUrl = _baseUrlService.GetBaseUrl(request); + var linkBaseUrl = _baseUrlService.GetBaseUrl(requestUri); var results = await _enumerationTransformer.Enumerate(paginatedQuery, cancellationToken); var metadata = await GetDocumentMetadata(query, filteredQuery, sortedQuery, paginationResults, cancellationToken); diff --git a/JSONAPI/Documents/Builders/ErrorDocumentBuilder.cs b/JSONAPI/Documents/Builders/ErrorDocumentBuilder.cs index aead058c..80b52c06 100644 --- a/JSONAPI/Documents/Builders/ErrorDocumentBuilder.cs +++ b/JSONAPI/Documents/Builders/ErrorDocumentBuilder.cs @@ -32,6 +32,7 @@ public IErrorDocument BuildFromException(Exception exception) return new ErrorDocument(new [] { error }, topLevelMetadata); } + /* public IErrorDocument BuildFromHttpError(HttpError httpError, HttpStatusCode statusCode) { var error = new Error @@ -47,6 +48,7 @@ public IErrorDocument BuildFromHttpError(HttpError httpError, HttpStatusCode sta var topLevelMetadata = GetTopLevelMetadata(); return new ErrorDocument(new[] { (IError)error }, topLevelMetadata); } + */ /// /// Builds an error object for a given exception. @@ -107,6 +109,8 @@ protected virtual IMetadata GetTopLevelMetadata() /// /// /// + /// + /* protected virtual IMetadata GetHttpErrorMetadata(HttpError httpError) { var metaObject = new JObject(); @@ -131,6 +135,7 @@ protected virtual IMetadata GetHttpErrorMetadata(HttpError httpError) return new BasicMetadata(metaObject); } + */ private IError GetErrorForJsonApiException(Exception ex) { diff --git a/JSONAPI/Documents/Builders/FallbackDocumentBuilder.cs b/JSONAPI/Documents/Builders/FallbackDocumentBuilder.cs index 8208f274..4992f69f 100644 --- a/JSONAPI/Documents/Builders/FallbackDocumentBuilder.cs +++ b/JSONAPI/Documents/Builders/FallbackDocumentBuilder.cs @@ -51,13 +51,13 @@ public FallbackDocumentBuilder(ISingleResourceDocumentBuilder singleResourceDocu .GetMethod("BuildDocument", BindingFlags.Instance | BindingFlags.Public)); } - public async Task BuildDocument(object obj, HttpRequestMessage requestMessage, - CancellationToken cancellationToken) + public async Task BuildDocument(object obj, IEnumerable> requestParams, + System.Uri requestUri, CancellationToken cancellationToken) { var type = obj.GetType(); // TODO: test includes - var includeExpressions = _includeExpressionExtractor.ExtractIncludeExpressions(requestMessage); + var includeExpressions = _includeExpressionExtractor.ExtractIncludeExpressions(requestParams); var queryableInterfaces = type.GetInterfaces(); var queryableInterface = @@ -69,10 +69,10 @@ public async Task BuildDocument(object obj, HttpRequestMessage var buildDocumentMethod = _openBuildDocumentFromQueryableMethod.Value.MakeGenericMethod(queryableElementType); - var sortExpressions = _sortExpressionExtractor.ExtractSortExpressions(requestMessage); + var sortExpressions = _sortExpressionExtractor.ExtractSortExpressions(requestParams); dynamic materializedQueryTask = buildDocumentMethod.Invoke(_queryableResourceCollectionDocumentBuilder, - new[] { obj, requestMessage, sortExpressions, cancellationToken, includeExpressions }); + new[] { obj, requestParams, requestUri, sortExpressions, cancellationToken, includeExpressions }); return await materializedQueryTask; } @@ -84,7 +84,7 @@ public async Task BuildDocument(object obj, HttpRequestMessage isCollection = true; } - var linkBaseUrl = _baseUrlService.GetBaseUrl(requestMessage); + var linkBaseUrl = _baseUrlService.GetBaseUrl(requestUri); if (isCollection) { diff --git a/JSONAPI/Documents/Builders/IErrorDocumentBuilder.cs b/JSONAPI/Documents/Builders/IErrorDocumentBuilder.cs index 900d6d05..ca5d6ddc 100644 --- a/JSONAPI/Documents/Builders/IErrorDocumentBuilder.cs +++ b/JSONAPI/Documents/Builders/IErrorDocumentBuilder.cs @@ -1,22 +1,23 @@ -using System; -using System.Net; -using System.Web.Http; - -namespace JSONAPI.Documents.Builders -{ - /// - /// Provides services for building an error document - /// - public interface IErrorDocumentBuilder - { - /// - /// Builds an error document based on an exception - /// - IErrorDocument BuildFromException(Exception exception); - - /// - /// Builds an error document based on an HttpError - /// - IErrorDocument BuildFromHttpError(HttpError httpError, HttpStatusCode statusCode); - } +using System; +using System.Net; +using System.Web.Http; + +namespace JSONAPI.Documents.Builders +{ + /// + /// Provides services for building an error document + /// + public interface IErrorDocumentBuilder + { + /// + /// Builds an error document based on an exception + /// + IErrorDocument BuildFromException(Exception exception); + + /// + /// Builds an error document based on an HttpError + /// + // TODO + //IErrorDocument BuildFromHttpError(HttpError httpError, HttpStatusCode statusCode); + } } \ No newline at end of file diff --git a/JSONAPI/Documents/Builders/IFallbackDocumentBuilder.cs b/JSONAPI/Documents/Builders/IFallbackDocumentBuilder.cs index 5004d2fd..5d17fb68 100644 --- a/JSONAPI/Documents/Builders/IFallbackDocumentBuilder.cs +++ b/JSONAPI/Documents/Builders/IFallbackDocumentBuilder.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Net.Http; using System.Threading; using System.Threading.Tasks; @@ -13,10 +14,12 @@ public interface IFallbackDocumentBuilder /// Builds a JSON API document based on the given object /// /// - /// + /// + /// /// /// /// Thrown when an error occurs when building the document - Task BuildDocument(object obj, HttpRequestMessage requestMessage, CancellationToken cancellationToken); + Task BuildDocument(object obj, IEnumerable> requestParams, + System.Uri requestUri, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/JSONAPI/Documents/Builders/IQueryableResourceCollectionDocumentBuilder.cs b/JSONAPI/Documents/Builders/IQueryableResourceCollectionDocumentBuilder.cs index 0c15cb50..ddcca69f 100644 --- a/JSONAPI/Documents/Builders/IQueryableResourceCollectionDocumentBuilder.cs +++ b/JSONAPI/Documents/Builders/IQueryableResourceCollectionDocumentBuilder.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Net.Http; using System.Threading; using System.Threading.Tasks; @@ -14,13 +15,15 @@ public interface IQueryableResourceCollectionDocumentBuilder /// Builds a document object for the given query /// /// The query to materialize to build the response document - /// The request containing parameters to determine how to sort/filter/paginate the query + /// The request containing parameters to determine how to sort/filter/paginate the query + /// The Uri of the request :) /// An array of paths to sort by /// /// The set of paths to include in the compound document /// /// - Task BuildDocument(IQueryable query, HttpRequestMessage request, string[] sortExpressions, CancellationToken cancellationToken, + Task BuildDocument(IQueryable query, IEnumerable> requestParams, + System.Uri requestUri, string[] sortExpressions, CancellationToken cancellationToken, string[] includePaths = null); } } diff --git a/JSONAPI/Extensions/QueryableExtensions.cs b/JSONAPI/Extensions/QueryableExtensions.cs index e6aca042..0c77560d 100644 --- a/JSONAPI/Extensions/QueryableExtensions.cs +++ b/JSONAPI/Extensions/QueryableExtensions.cs @@ -1,12 +1,4 @@ -using System; -using System.Linq; -using System.Linq.Expressions; -using System.Net.Http; -using System.Reflection; -using System.Web.Http.Filters; -using JSONAPI.Core; - -namespace JSONAPI.Extensions +namespace JSONAPI.Extensions { internal static class QueryableExtensions { diff --git a/JSONAPI/Http/BaseUrlService.cs b/JSONAPI/Http/BaseUrlService.cs index df1ee1a1..c98c06f6 100644 --- a/JSONAPI/Http/BaseUrlService.cs +++ b/JSONAPI/Http/BaseUrlService.cs @@ -42,10 +42,10 @@ public BaseUrlService(Uri publicOrigin, string contextPath) /// /// /// - public virtual string GetBaseUrl(HttpRequestMessage requestMessage) + public virtual string GetBaseUrl(Uri requestUri) { string pathAndQuery; - string absolutUri = requestMessage.RequestUri.AbsoluteUri; + string absolutUri = requestUri.AbsoluteUri; if (_publicOrigin != null) { var publicUriBuilder = new UriBuilder(absolutUri) @@ -59,7 +59,7 @@ public virtual string GetBaseUrl(HttpRequestMessage requestMessage) } else { - pathAndQuery = requestMessage.RequestUri.PathAndQuery; + pathAndQuery = requestUri.PathAndQuery; } pathAndQuery = RemoveFromBegin(pathAndQuery, GetContextPath()); pathAndQuery= pathAndQuery.TrimStart('/'); diff --git a/JSONAPI/Http/DefaultIncludeExpressionExtractor.cs b/JSONAPI/Http/DefaultIncludeExpressionExtractor.cs index cb040b19..0bdc4aea 100644 --- a/JSONAPI/Http/DefaultIncludeExpressionExtractor.cs +++ b/JSONAPI/Http/DefaultIncludeExpressionExtractor.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Net.Http; namespace JSONAPI.Http @@ -10,10 +11,9 @@ public class DefaultIncludeExpressionExtractor: IIncludeExpressionExtractor { private const string IncludeQueryParamKey = "include"; - public string[] ExtractIncludeExpressions(HttpRequestMessage requestMessage) + public string[] ExtractIncludeExpressions(IEnumerable> requestParams) { - var queryParams = requestMessage.GetQueryNameValuePairs(); - var includeParam = queryParams.FirstOrDefault(kvp => kvp.Key == IncludeQueryParamKey); + var includeParam = requestParams.FirstOrDefault(kvp => kvp.Key == IncludeQueryParamKey); if (includeParam.Key != IncludeQueryParamKey) return new string[] { }; return includeParam.Value.Split(','); } diff --git a/JSONAPI/Http/DefaultSortExpressionExtractor.cs b/JSONAPI/Http/DefaultSortExpressionExtractor.cs index 59cb449a..b1054b0c 100644 --- a/JSONAPI/Http/DefaultSortExpressionExtractor.cs +++ b/JSONAPI/Http/DefaultSortExpressionExtractor.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Net.Http; namespace JSONAPI.Http @@ -10,10 +11,9 @@ public class DefaultSortExpressionExtractor : ISortExpressionExtractor { private const string SortQueryParamKey = "sort"; - public string[] ExtractSortExpressions(HttpRequestMessage requestMessage) + public string[] ExtractSortExpressions(IEnumerable> requestParams) { - var queryParams = requestMessage.GetQueryNameValuePairs(); - var sortParam = queryParams.FirstOrDefault(kvp => kvp.Key == SortQueryParamKey); + var sortParam = requestParams.FirstOrDefault(kvp => kvp.Key == SortQueryParamKey); if (sortParam.Key != SortQueryParamKey) return new string[] {}; return sortParam.Value.Split(','); } diff --git a/JSONAPI/Http/IBaseUrlService.cs b/JSONAPI/Http/IBaseUrlService.cs index dd9f3177..a71c1345 100644 --- a/JSONAPI/Http/IBaseUrlService.cs +++ b/JSONAPI/Http/IBaseUrlService.cs @@ -10,7 +10,7 @@ public interface IBaseUrlService /// /// Gets the base URL for a request /// - string GetBaseUrl(HttpRequestMessage requestMessage); + string GetBaseUrl(System.Uri requestUri); /// /// Gets the context path JSONAPI is served under without slashes at the beginning and end. diff --git a/JSONAPI/Http/IDocumentMaterializer.cs b/JSONAPI/Http/IDocumentMaterializer.cs index b4eb4bce..f33e42ef 100644 --- a/JSONAPI/Http/IDocumentMaterializer.cs +++ b/JSONAPI/Http/IDocumentMaterializer.cs @@ -2,7 +2,8 @@ using System.Threading; using System.Threading.Tasks; using JSONAPI.Documents; - +using System.Collections.Generic; + namespace JSONAPI.Http { /// @@ -14,12 +15,13 @@ public interface IDocumentMaterializer /// Returns a document containing records that are filtered, sorted, /// and paginated according to query parameters present in the provided request. /// - Task GetRecords(HttpRequestMessage request, CancellationToken cancellationToken); + Task GetRecords(IEnumerable> requestParams, + System.Uri requestUri, CancellationToken cancellationToken); /// /// Returns a document with the resource identified by the given ID. /// - Task GetRecordById(string id, HttpRequestMessage request, + Task GetRecordById(string id, System.Uri requestUri, CancellationToken cancellationToken); /// diff --git a/JSONAPI/Http/IIncludeExpressionExtractor.cs b/JSONAPI/Http/IIncludeExpressionExtractor.cs index c8cf1358..f5d207c2 100644 --- a/JSONAPI/Http/IIncludeExpressionExtractor.cs +++ b/JSONAPI/Http/IIncludeExpressionExtractor.cs @@ -1,4 +1,5 @@ -using System.Net.Http; +using System.Collections.Generic; +using System.Net.Http; namespace JSONAPI.Http { @@ -10,8 +11,8 @@ public interface IIncludeExpressionExtractor /// /// Extracts include expressions from the request /// - /// + /// /// - string[] ExtractIncludeExpressions(HttpRequestMessage requestMessage); + string[] ExtractIncludeExpressions(IEnumerable> requestParams); } } diff --git a/JSONAPI/Http/IRelatedResourceDocumentMaterializer.cs b/JSONAPI/Http/IRelatedResourceDocumentMaterializer.cs index 893c9069..4833a064 100644 --- a/JSONAPI/Http/IRelatedResourceDocumentMaterializer.cs +++ b/JSONAPI/Http/IRelatedResourceDocumentMaterializer.cs @@ -2,7 +2,8 @@ using System.Threading; using System.Threading.Tasks; using JSONAPI.Documents; - +using System.Collections.Generic; + namespace JSONAPI.Http { /// @@ -13,6 +14,7 @@ public interface IRelatedResourceDocumentMaterializer /// /// Builds a document containing the results of the relationship. /// - Task GetRelatedResourceDocument(string primaryResourceId, HttpRequestMessage request, CancellationToken cancellationToken); + Task GetRelatedResourceDocument(string primaryResourceId, IEnumerable> requestParams, + System.Uri requestUri, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/JSONAPI/Http/ISortExpressionExtractor.cs b/JSONAPI/Http/ISortExpressionExtractor.cs index 62f9d42f..2bd3e911 100644 --- a/JSONAPI/Http/ISortExpressionExtractor.cs +++ b/JSONAPI/Http/ISortExpressionExtractor.cs @@ -1,4 +1,4 @@ -using System.Net.Http; +using System.Collections.Generic; namespace JSONAPI.Http { @@ -10,8 +10,8 @@ public interface ISortExpressionExtractor /// /// Extracts sort expressions from the request /// - /// + /// /// - string[] ExtractSortExpressions(HttpRequestMessage requestMessage); + string[] ExtractSortExpressions(IEnumerable> requestParams); } } diff --git a/JSONAPI/Http/JsonApiController.cs b/JSONAPI/Http/JsonApiController.cs deleted file mode 100644 index 8bc9bf22..00000000 --- a/JSONAPI/Http/JsonApiController.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using System.Web.Http; -using JSONAPI.Documents; - -namespace JSONAPI.Http -{ - /// - /// This ApiController is capable of serving all requests using JSON API. - /// - public class JsonApiController : ApiController - { - private readonly IDocumentMaterializerLocator _documentMaterializerLocator; - - /// - /// Creates a new JsonApiController - /// - /// The service locator to get document materializers for a given resource type. - public JsonApiController(IDocumentMaterializerLocator documentMaterializerLocator) - { - _documentMaterializerLocator = documentMaterializerLocator; - } - - /// - /// Returns a document corresponding to a set of records of this type. - /// - public virtual async Task GetResourceCollection(string resourceType, CancellationToken cancellationToken) - { - var materializer = _documentMaterializerLocator.GetMaterializerByResourceTypeName(resourceType); - var document = await materializer.GetRecords(Request, cancellationToken); - return Ok(document); - } - - /// - /// Returns a document corresponding to the single record matching the ID. - /// - public virtual async Task Get(string resourceType, string id, CancellationToken cancellationToken) - { - var materializer = _documentMaterializerLocator.GetMaterializerByResourceTypeName(resourceType); - var document = await materializer.GetRecordById(id, Request, cancellationToken); - return Ok(document); - } - - /// - /// Returns a document corresponding to the resource(s) related to the resource identified by the ID, - /// and the relationship name. - /// - public virtual async Task GetRelatedResource(string resourceType, string id, string relationshipName, CancellationToken cancellationToken) - { - var materializer = _documentMaterializerLocator.GetRelatedResourceMaterializer(resourceType, relationshipName); - var document = await materializer.GetRelatedResourceDocument(id, Request, cancellationToken); - return Ok(document); - } - - /// - /// Creates a new record corresponding to the data in the request document. - /// - public virtual async Task Post(string resourceType, [FromBody]ISingleResourceDocument requestDocument, CancellationToken cancellationToken) - { - var materializer = _documentMaterializerLocator.GetMaterializerByResourceTypeName(resourceType); - var document = await materializer.CreateRecord(requestDocument, Request, cancellationToken); - return Ok(document); - } - - /// - /// Updates the record with the given ID with data from the request payload. - /// - public virtual async Task Patch(string resourceType, string id, [FromBody]ISingleResourceDocument requestDocument, CancellationToken cancellationToken) - { - var materializer = _documentMaterializerLocator.GetMaterializerByResourceTypeName(resourceType); - var document = await materializer.UpdateRecord(id, requestDocument, Request, cancellationToken); - return Ok(document); - } - - /// - /// Deletes the record corresponding to the ID. - /// - public virtual async Task Delete(string resourceType, string id, CancellationToken cancellationToken) - { - var materializer = _documentMaterializerLocator.GetMaterializerByResourceTypeName(resourceType); - var document = await materializer.DeleteRecord(id, Request, cancellationToken); - return Ok(document); - } - } -} diff --git a/JSONAPI/Http/MappedDocumentMaterializer.cs b/JSONAPI/Http/MappedDocumentMaterializer.cs index 4c53c2e0..fd95344b 100644 --- a/JSONAPI/Http/MappedDocumentMaterializer.cs +++ b/JSONAPI/Http/MappedDocumentMaterializer.cs @@ -8,7 +8,8 @@ using JSONAPI.Documents; using JSONAPI.Documents.Builders; using JSONAPI.QueryableTransformers; - +using System.Collections.Generic; + namespace JSONAPI.Http { /// @@ -64,20 +65,21 @@ private string ResourceTypeName get { return _resourceTypeRegistry.GetRegistrationForType(typeof (TDto)).ResourceTypeName; } } - public virtual async Task GetRecords(HttpRequestMessage request, CancellationToken cancellationToken) + public virtual async Task GetRecords(IEnumerable> requestParams, + System.Uri requestUri, CancellationToken cancellationToken) { var entityQuery = GetQuery(); var includePaths = GetIncludePathsForQuery() ?? new Expression>[] { }; var jsonApiPaths = includePaths.Select(ConvertToJsonKeyPath).ToArray(); var mappedQuery = GetMappedQuery(entityQuery, includePaths); - var sortationPaths = _sortExpressionExtractor.ExtractSortExpressions(request); + var sortationPaths = _sortExpressionExtractor.ExtractSortExpressions(requestParams); if (sortationPaths == null || !sortationPaths.Any()) sortationPaths = GetDefaultSortExpressions(); - return await _queryableResourceCollectionDocumentBuilder.BuildDocument(mappedQuery, request, sortationPaths, cancellationToken, jsonApiPaths); + return await _queryableResourceCollectionDocumentBuilder.BuildDocument(mappedQuery, requestParams, requestUri, sortationPaths, cancellationToken, jsonApiPaths); } - public virtual async Task GetRecordById(string id, HttpRequestMessage request, CancellationToken cancellationToken) + public virtual async Task GetRecordById(string id, System.Uri requestUri, CancellationToken cancellationToken) { var entityQuery = GetByIdQuery(id); var includePaths = GetIncludePathsForSingleResource() ?? new Expression>[] { }; @@ -90,7 +92,7 @@ public virtual async Task GetRecordById(string id, Http await OnResourceFetched(primaryResource, cancellationToken); - var baseUrl = _baseUrlService.GetBaseUrl(request); + var baseUrl = _baseUrlService.GetBaseUrl(requestUri); return _singleResourceDocumentBuilder.BuildDocument(primaryResource, baseUrl, jsonApiPaths, null); } diff --git a/JSONAPI/Http/QueryableToManyRelatedResourceDocumentMaterializer.cs b/JSONAPI/Http/QueryableToManyRelatedResourceDocumentMaterializer.cs index 6aa2286f..ad6890a1 100644 --- a/JSONAPI/Http/QueryableToManyRelatedResourceDocumentMaterializer.cs +++ b/JSONAPI/Http/QueryableToManyRelatedResourceDocumentMaterializer.cs @@ -4,7 +4,8 @@ using System.Threading.Tasks; using JSONAPI.Documents; using JSONAPI.Documents.Builders; - +using System.Collections.Generic; + namespace JSONAPI.Http { /// @@ -34,17 +35,16 @@ protected QueryableToManyRelatedResourceDocumentMaterializer( _includeExpressionExtractor = includeExpressionExtractor; } - public async Task GetRelatedResourceDocument(string primaryResourceId, HttpRequestMessage request, - CancellationToken cancellationToken) + public async Task GetRelatedResourceDocument(string primaryResourceId, + IEnumerable> requestParams, System.Uri requestUri, CancellationToken cancellationToken) { - Includes = _includeExpressionExtractor.ExtractIncludeExpressions(request); + Includes = _includeExpressionExtractor.ExtractIncludeExpressions(requestParams); var query = await GetRelatedQuery(primaryResourceId, cancellationToken); - var sortExpressions = _sortExpressionExtractor.ExtractSortExpressions(request); + var sortExpressions = _sortExpressionExtractor.ExtractSortExpressions(requestParams); if (sortExpressions == null || sortExpressions.Length < 1) sortExpressions = GetDefaultSortExpressions(); - - - return await _queryableResourceCollectionDocumentBuilder.BuildDocument(query, request, sortExpressions, cancellationToken, Includes); // TODO: allow implementors to specify metadata + + return await _queryableResourceCollectionDocumentBuilder.BuildDocument(query, requestParams, requestUri, sortExpressions, cancellationToken, Includes); // TODO: allow implementors to specify metadata } /// diff --git a/JSONAPI/Http/QueryableToOneRelatedResourceDocumentMaterializer.cs b/JSONAPI/Http/QueryableToOneRelatedResourceDocumentMaterializer.cs index da9b23f4..90b4ccbd 100644 --- a/JSONAPI/Http/QueryableToOneRelatedResourceDocumentMaterializer.cs +++ b/JSONAPI/Http/QueryableToOneRelatedResourceDocumentMaterializer.cs @@ -1,41 +1,42 @@ -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.Documents; -using JSONAPI.Documents.Builders; - -namespace JSONAPI.Http -{ - /// - /// Base class for implementations of that use IQueryable to get related resources - /// for a to-many relationship. - /// - public abstract class QueryableToOneRelatedResourceDocumentMaterializer : IRelatedResourceDocumentMaterializer - { - private readonly ISingleResourceDocumentBuilder _singleResourceDocumentBuilder; - private readonly IBaseUrlService _baseUrlService; - - /// - /// Creates a new QueryableRelatedResourceDocumentMaterializer - /// - protected QueryableToOneRelatedResourceDocumentMaterializer( - ISingleResourceDocumentBuilder singleResourceDocumentBuilder, IBaseUrlService baseUrlService) - { - _singleResourceDocumentBuilder = singleResourceDocumentBuilder; - _baseUrlService = baseUrlService; - } - - public async Task GetRelatedResourceDocument(string primaryResourceId, HttpRequestMessage request, - CancellationToken cancellationToken) - { - var record = await GetRelatedRecord(primaryResourceId, cancellationToken); - var baseUrl = _baseUrlService.GetBaseUrl(request); - return _singleResourceDocumentBuilder.BuildDocument(record, baseUrl, null, null); // TODO: allow implementors to specify includes and metadata - } - - /// - /// Gets the query for the related resources - /// - protected abstract Task GetRelatedRecord(string primaryResourceId, CancellationToken cancellationToken); - } +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using JSONAPI.Documents; +using JSONAPI.Documents.Builders; +using System.Collections.Generic; + +namespace JSONAPI.Http +{ + /// + /// Base class for implementations of that use IQueryable to get related resources + /// for a to-many relationship. + /// + public abstract class QueryableToOneRelatedResourceDocumentMaterializer : IRelatedResourceDocumentMaterializer + { + private readonly ISingleResourceDocumentBuilder _singleResourceDocumentBuilder; + private readonly IBaseUrlService _baseUrlService; + + /// + /// Creates a new QueryableRelatedResourceDocumentMaterializer + /// + protected QueryableToOneRelatedResourceDocumentMaterializer( + ISingleResourceDocumentBuilder singleResourceDocumentBuilder, IBaseUrlService baseUrlService) + { + _singleResourceDocumentBuilder = singleResourceDocumentBuilder; + _baseUrlService = baseUrlService; + } + + public async Task GetRelatedResourceDocument(string primaryResourceId, + IEnumerable> requestParams, System.Uri requestUri, CancellationToken cancellationToken) + { + var record = await GetRelatedRecord(primaryResourceId, cancellationToken); + var baseUrl = _baseUrlService.GetBaseUrl(requestUri); + return _singleResourceDocumentBuilder.BuildDocument(record, baseUrl, null, null); // TODO: allow implementors to specify includes and metadata + } + + /// + /// Gets the query for the related resources + /// + protected abstract Task GetRelatedRecord(string primaryResourceId, CancellationToken cancellationToken); + } } \ No newline at end of file diff --git a/JSONAPI/JSONAPI.csproj b/JSONAPI/JSONAPI.csproj index 9bd3d2e2..818361f9 100644 --- a/JSONAPI/JSONAPI.csproj +++ b/JSONAPI/JSONAPI.csproj @@ -52,14 +52,6 @@ - - False - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll - - - False - ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.2\lib\net45\System.Web.Http.WebHost.dll - @@ -138,7 +130,6 @@ - diff --git a/JSONAPI/Json/JsonApiFormatter.cs b/JSONAPI/Json/JsonApiFormatter.cs index 4d1ddfa6..db247dcd 100644 --- a/JSONAPI/Json/JsonApiFormatter.cs +++ b/JSONAPI/Json/JsonApiFormatter.cs @@ -74,6 +74,7 @@ public override async Task WriteToStreamAsync(Type type, object value, Stream wr { await _errorDocumentFormatter.Serialize(errorDocument, writer); } + /* else { var error = value as HttpError; @@ -87,6 +88,7 @@ public override async Task WriteToStreamAsync(Type type, object value, Stream wr WriteErrorForUnsupportedType(value, writer); } } + */ writer.Flush(); } diff --git a/JSONAPI/QueryableTransformers/DefaultFilteringTransformer.cs b/JSONAPI/QueryableTransformers/DefaultFilteringTransformer.cs index f449d1bb..b3755a05 100644 --- a/JSONAPI/QueryableTransformers/DefaultFilteringTransformer.cs +++ b/JSONAPI/QueryableTransformers/DefaultFilteringTransformer.cs @@ -6,7 +6,8 @@ using System.Reflection; using JSONAPI.Core; using JSONAPI.Documents.Builders; - +using System.Collections.Generic; + namespace JSONAPI.QueryableTransformers { /// @@ -25,10 +26,10 @@ public DefaultFilteringTransformer(IResourceTypeRegistry resourceTypeRegistry) _resourceTypeRegistry = resourceTypeRegistry; } - public IQueryable Filter(IQueryable query, HttpRequestMessage request) + public IQueryable Filter(IQueryable query, IEnumerable> requestParams) { var parameter = Expression.Parameter(typeof(T)); - var bodyExpr = GetPredicateBody(request, parameter); + var bodyExpr = GetPredicateBody(requestParams, parameter); var lambdaExpr = Expression.Lambda>(bodyExpr, parameter); return query.Where(lambdaExpr); } @@ -54,13 +55,12 @@ public IQueryable Filter(IQueryable query, HttpRequestMessage request) .SingleOrDefault() ); - private Expression GetPredicateBody(HttpRequestMessage request, ParameterExpression param) + private Expression GetPredicateBody(IEnumerable> requestParams, ParameterExpression param) { Expression workingExpr = null; var type = param.Type; - var queryPairs = request.GetQueryNameValuePairs(); - foreach (var queryPair in queryPairs) + foreach (var queryPair in requestParams) { if (String.IsNullOrWhiteSpace(queryPair.Key)) continue; diff --git a/JSONAPI/QueryableTransformers/DefaultPaginationTransformResult.cs b/JSONAPI/QueryableTransformers/DefaultPaginationTransformResult.cs index 5c68886c..9db9af02 100644 --- a/JSONAPI/QueryableTransformers/DefaultPaginationTransformResult.cs +++ b/JSONAPI/QueryableTransformers/DefaultPaginationTransformResult.cs @@ -1,5 +1,5 @@ using System.Linq; -using JSONAPI.ActionFilters; +//using JSONAPI.ActionFilters; namespace JSONAPI.QueryableTransformers { diff --git a/JSONAPI/QueryableTransformers/DefaultPaginationTransformer.cs b/JSONAPI/QueryableTransformers/DefaultPaginationTransformer.cs index 21c87754..2eaf8a21 100644 --- a/JSONAPI/QueryableTransformers/DefaultPaginationTransformer.cs +++ b/JSONAPI/QueryableTransformers/DefaultPaginationTransformer.cs @@ -1,96 +1,97 @@ -using System; -using System.Linq; -using System.Net.Http; -using JSONAPI.ActionFilters; -using JSONAPI.Documents.Builders; - -namespace JSONAPI.QueryableTransformers -{ - /// - /// Performs pagination - /// - public class DefaultPaginationTransformer : IQueryablePaginationTransformer - { - private const int DefaultPageSize = 100; - private const string PageNumberQueryParam = "page.number"; - private const string PageSizeQueryParam = "page.size"; - - private readonly int? _maxPageSize; - - /// - /// Creates a DefaultPaginationTransformer - /// - /// The maximum page size to allow clients to request. Leave null for no restriction. - public DefaultPaginationTransformer(int? maxPageSize = null) - { - if (maxPageSize <= 0) throw new ArgumentOutOfRangeException("maxPageSize", "The maximum page size must be 1 or greater."); - - _maxPageSize = maxPageSize; - } - - public IPaginationTransformResult ApplyPagination(IQueryable query, HttpRequestMessage request) - { - var hasPageNumberParam = false; - var hasPageSizeParam = false; - var pageNumber = 0; - var pageSize = _maxPageSize ?? DefaultPageSize; - foreach (var kvp in request.GetQueryNameValuePairs()) - { - if (kvp.Key == PageNumberQueryParam) - { - hasPageNumberParam = true; - if (!int.TryParse(kvp.Value, out pageNumber)) - throw JsonApiException.CreateForParameterError("Invalid page number", - "Page number must be a positive integer.", PageNumberQueryParam); - - } - else if (kvp.Key == PageSizeQueryParam) - { - hasPageSizeParam = true; - if (!int.TryParse(kvp.Value, out pageSize)) - throw JsonApiException.CreateForParameterError("Invalid page size", - "Page size must be a positive integer.", PageSizeQueryParam); - } - } - - if (!hasPageNumberParam && !hasPageSizeParam) - { - return new DefaultPaginationTransformResult - { - PagedQuery = query, - PaginationWasApplied = false - }; - } - - if ((hasPageNumberParam && !hasPageSizeParam)) - throw JsonApiException.CreateForParameterError("Page size missing", - string.Format("In order for paging to work properly, if either {0} or {1} is set, both must be.", - PageNumberQueryParam, PageSizeQueryParam), PageNumberQueryParam); - - if ((!hasPageNumberParam && hasPageSizeParam)) - throw JsonApiException.CreateForParameterError("Page number missing", - string.Format("In order for paging to work properly, if either {0} or {1} is set, both must be.", - PageNumberQueryParam, PageSizeQueryParam), PageSizeQueryParam); - - if (pageNumber < 0) - throw JsonApiException.CreateForParameterError("Page number out of bounds", - "Page number must not be negative.", PageNumberQueryParam); - - if (pageSize <= 0) - throw JsonApiException.CreateForParameterError("Page size out of bounds", - "Page size must be greater than or equal to 1.", PageSizeQueryParam); - - if (_maxPageSize != null && pageSize > _maxPageSize.Value) - pageSize = _maxPageSize.Value; - - var skip = pageNumber * pageSize; - return new DefaultPaginationTransformResult - { - PageNumber = pageNumber, - PageSize = pageSize, - PagedQuery = query.Skip(skip).Take(pageSize), - PaginationWasApplied = true - }; - } - } -} +using System; +using System.Linq; +using System.Net.Http; +//using JSONAPI.ActionFilters; +using JSONAPI.Documents.Builders; +using System.Collections.Generic; + +namespace JSONAPI.QueryableTransformers +{ + /// + /// Performs pagination + /// + public class DefaultPaginationTransformer : IQueryablePaginationTransformer + { + private const int DefaultPageSize = 100; + private const string PageNumberQueryParam = "page.number"; + private const string PageSizeQueryParam = "page.size"; + + private readonly int? _maxPageSize; + + /// + /// Creates a DefaultPaginationTransformer + /// + /// The maximum page size to allow clients to request. Leave null for no restriction. + public DefaultPaginationTransformer(int? maxPageSize = null) + { + if (maxPageSize <= 0) throw new ArgumentOutOfRangeException("maxPageSize", "The maximum page size must be 1 or greater."); + + _maxPageSize = maxPageSize; + } + + public IPaginationTransformResult ApplyPagination(IQueryable query, IEnumerable> requestParams) + { + var hasPageNumberParam = false; + var hasPageSizeParam = false; + var pageNumber = 0; + var pageSize = _maxPageSize ?? DefaultPageSize; + foreach (var kvp in requestParams) + { + if (kvp.Key == PageNumberQueryParam) + { + hasPageNumberParam = true; + if (!int.TryParse(kvp.Value, out pageNumber)) + throw JsonApiException.CreateForParameterError("Invalid page number", + "Page number must be a positive integer.", PageNumberQueryParam); + + } + else if (kvp.Key == PageSizeQueryParam) + { + hasPageSizeParam = true; + if (!int.TryParse(kvp.Value, out pageSize)) + throw JsonApiException.CreateForParameterError("Invalid page size", + "Page size must be a positive integer.", PageSizeQueryParam); + } + } + + if (!hasPageNumberParam && !hasPageSizeParam) + { + return new DefaultPaginationTransformResult + { + PagedQuery = query, + PaginationWasApplied = false + }; + } + + if ((hasPageNumberParam && !hasPageSizeParam)) + throw JsonApiException.CreateForParameterError("Page size missing", + string.Format("In order for paging to work properly, if either {0} or {1} is set, both must be.", + PageNumberQueryParam, PageSizeQueryParam), PageNumberQueryParam); + + if ((!hasPageNumberParam && hasPageSizeParam)) + throw JsonApiException.CreateForParameterError("Page number missing", + string.Format("In order for paging to work properly, if either {0} or {1} is set, both must be.", + PageNumberQueryParam, PageSizeQueryParam), PageSizeQueryParam); + + if (pageNumber < 0) + throw JsonApiException.CreateForParameterError("Page number out of bounds", + "Page number must not be negative.", PageNumberQueryParam); + + if (pageSize <= 0) + throw JsonApiException.CreateForParameterError("Page size out of bounds", + "Page size must be greater than or equal to 1.", PageSizeQueryParam); + + if (_maxPageSize != null && pageSize > _maxPageSize.Value) + pageSize = _maxPageSize.Value; + + var skip = pageNumber * pageSize; + return new DefaultPaginationTransformResult + { + PageNumber = pageNumber, + PageSize = pageSize, + PagedQuery = query.Skip(skip).Take(pageSize), + PaginationWasApplied = true + }; + } + } +} diff --git a/JSONAPI/QueryableTransformers/IQueryableFilteringTransformer.cs b/JSONAPI/QueryableTransformers/IQueryableFilteringTransformer.cs index fdb5f770..da792199 100644 --- a/JSONAPI/QueryableTransformers/IQueryableFilteringTransformer.cs +++ b/JSONAPI/QueryableTransformers/IQueryableFilteringTransformer.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Net.Http; namespace JSONAPI.QueryableTransformers @@ -12,9 +13,9 @@ public interface IQueryableFilteringTransformer /// Filters the provided queryable based on information from the request message. /// /// The input query - /// The request message + /// The request message /// The element type of the query /// The filtered query - IQueryable Filter(IQueryable query, HttpRequestMessage request); + IQueryable Filter(IQueryable query, IEnumerable> requestParams); } } diff --git a/JSONAPI/QueryableTransformers/IQueryablePaginationTransformer.cs b/JSONAPI/QueryableTransformers/IQueryablePaginationTransformer.cs index 01ff8e1d..200ebc49 100644 --- a/JSONAPI/QueryableTransformers/IQueryablePaginationTransformer.cs +++ b/JSONAPI/QueryableTransformers/IQueryablePaginationTransformer.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Net.Http; namespace JSONAPI.QueryableTransformers @@ -12,10 +13,10 @@ public interface IQueryablePaginationTransformer /// Pages the query according to information from the request. /// /// The query to page - /// The request message + /// The request message /// The queryable element type /// The result of pagination - IPaginationTransformResult ApplyPagination(IQueryable query, HttpRequestMessage request); + IPaginationTransformResult ApplyPagination(IQueryable query, IEnumerable> requestParams); } ///