add API versioning infrastructure

closes #142
This commit is contained in:
Collin M. Barrett 2017-10-30 14:41:51 -05:00
parent dba6f73f1a
commit a1aa7928d1
6 changed files with 101 additions and 5 deletions

View file

@ -1,5 +1,5 @@
{
"Email": "john.smith@protonmail.com",
"EmailAddress": "john.smith@protonmail.com",
"FilterLists": [
{
"Description": "A sample list to filter out advertisements.",
@ -10,6 +10,7 @@
"HomeUrl": "https://mysample.list/",
"IssuesUrl": "https://github.com/johnsmith/mysamplelist/issues",
"FilterListLanguages": null,
"FilterListRules": null,
"FilterListSoftware": null,
"MaintainerId": null,
"Name": "My Sample Advertisement Filter List",
@ -27,6 +28,7 @@
"HomeUrl": "https://mysample.list/",
"IssuesUrl": "https://github.com/johnsmith/mysamplelist/issues",
"FilterListLanguages": null,
"FilterListRules": null,
"FilterListSoftware": null,
"MaintainerId": null,
"Name": "My Sample Malware Filter List",

View file

@ -57,6 +57,15 @@
"$ref": "#/definitions/FilterListLanguage"
}
},
"FilterListRules": {
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/FilterListRule"
}
},
"FilterListSoftware": {
"type": [
"array",
@ -105,6 +114,7 @@
"HomeUrl",
"IssuesUrl",
"FilterListLanguages",
"FilterListRules",
"FilterListSoftware",
"MaintainerId",
"Name",
@ -154,6 +164,46 @@
"ModifiedDateUtc"
]
},
"FilterListRule": {
"type": [
"object",
"null"
],
"properties": {
"FilterListId": {
"type": "integer"
},
"FilterList": {
"$ref": "#/definitions/FilterList"
},
"RuleId": {
"type": "integer"
},
"Rule": {
"$ref": "#/definitions/Rule"
},
"Id": {
"type": "integer"
},
"CreatedDateUtc": {
"type": "string",
"format": "date-time"
},
"ModifiedDateUtc": {
"type": "string",
"format": "date-time"
}
},
"required": [
"FilterListId",
"FilterList",
"RuleId",
"Rule",
"Id",
"CreatedDateUtc",
"ModifiedDateUtc"
]
},
"FilterListSoftware": {
"type": [
"object",
@ -277,6 +327,47 @@
"ModifiedDateUtc"
]
},
"Rule": {
"type": [
"object",
"null"
],
"properties": {
"FilterListRules": {
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/FilterListRule"
}
},
"Raw": {
"type": [
"string",
"null"
]
},
"Id": {
"type": "integer"
},
"CreatedDateUtc": {
"type": "string",
"format": "date-time"
},
"ModifiedDateUtc": {
"type": "string",
"format": "date-time"
}
},
"required": [
"FilterListRules",
"Raw",
"Id",
"CreatedDateUtc",
"ModifiedDateUtc"
]
},
"Software": {
"type": [
"object",
@ -335,7 +426,7 @@
},
"type": "object",
"properties": {
"Email": {
"EmailAddress": {
"type": [
"string",
"null"
@ -381,7 +472,7 @@
}
},
"required": [
"Email",
"EmailAddress",
"FilterLists",
"HomeUrl",
"Name",

View file

@ -10,6 +10,7 @@ public static class ConfigureServicesCollection
public static void AddFilterListsApi(this IServiceCollection services)
{
services.AddMvc();
services.AddApiVersioning();
services.AddSwagger();
}

View file

@ -24,6 +24,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="2.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
</ItemGroup>

View file

@ -38,7 +38,7 @@ public void Configure(IApplicationBuilder app)
app.UseStaticFiles();
app.UseMvc(routes => { routes.MapRoute("default", "v1/{controller=Default}/{action=Get}/{id?}"); });
app.UseMvc(routes => { routes.MapRoute("default", "v{version:apiVersion}/{controller=Default}/{action=Get}/{id?}"); });
}
}
}

View file

@ -1,8 +1,9 @@
using FilterLists.Services.Contracts;
using Microsoft.AspNetCore.Mvc;
namespace FilterLists.Api.Controllers
namespace FilterLists.Api.V1.Controllers
{
[ApiVersion("1.0")]
[Produces("application/json")]
public class ListsController : Controller
{