refactor: remove asp.net versioning

This commit is contained in:
spiral 2022-01-19 19:25:04 -05:00
parent 1626e0f548
commit eb4f53c69e
No known key found for this signature in database
GPG Key ID: A6059F0CA0E1BD31
14 changed files with 119 additions and 36 deletions

View File

@ -7,8 +7,7 @@ using PluralKit.Core;
namespace PluralKit.API; namespace PluralKit.API;
[ApiController] [ApiController]
[ApiVersion("1.0")] [Route("v1/a")]
[Route("v{version:apiVersion}/a")]
public class AccountController: ControllerBase public class AccountController: ControllerBase
{ {
private readonly IDatabase _db; private readonly IDatabase _db;

View File

@ -10,8 +10,7 @@ using PluralKit.Core;
namespace PluralKit.API; namespace PluralKit.API;
[ApiController] [ApiController]
[ApiVersion("1.0")] [Route("v1/m")]
[Route("v{version:apiVersion}/m")]
public class MemberController: ControllerBase public class MemberController: ControllerBase
{ {
private readonly IDatabase _db; private readonly IDatabase _db;

View File

@ -7,8 +7,7 @@ using PluralKit.Core;
namespace PluralKit.API; namespace PluralKit.API;
[ApiController] [ApiController]
[ApiVersion("1.0")] [Route("v1")]
[Route("v{version:apiVersion}/msg")]
public class MessageController: ControllerBase public class MessageController: ControllerBase
{ {
private readonly IDatabase _db; private readonly IDatabase _db;
@ -20,7 +19,7 @@ public class MessageController: ControllerBase
_db = db; _db = db;
} }
[HttpGet("{mid}")] [HttpGet("msg/{mid}")]
public async Task<ActionResult<JObject>> GetMessage(ulong mid) public async Task<ActionResult<JObject>> GetMessage(ulong mid)
{ {
var msg = await _db.Execute(c => _repo.GetMessage(c, mid)); var msg = await _db.Execute(c => _repo.GetMessage(c, mid));

View File

@ -7,8 +7,7 @@ using PluralKit.Core;
namespace PluralKit.API; namespace PluralKit.API;
[ApiController] [ApiController]
[ApiVersion("1.0")] [Route("v1")]
[Route("v{version:apiVersion}")]
public class MetaController: ControllerBase public class MetaController: ControllerBase
{ {
private readonly IDatabase _db; private readonly IDatabase _db;

View File

@ -31,8 +31,7 @@ public struct PostSwitchParams
} }
[ApiController] [ApiController]
[ApiVersion("1.0")] [Route("v1/s")]
[Route("v{version:apiVersion}/s")]
public class SystemController: ControllerBase public class SystemController: ControllerBase
{ {
private readonly IDatabase _db; private readonly IDatabase _db;

View File

@ -7,8 +7,7 @@ using PluralKit.Core;
namespace PluralKit.API; namespace PluralKit.API;
[ApiController] [ApiController]
[ApiVersion("2.0")] [Route("v2")]
[Route("v{version:apiVersion}")]
public class DiscordControllerV2: PKControllerBase public class DiscordControllerV2: PKControllerBase
{ {
public DiscordControllerV2(IServiceProvider svc) : base(svc) { } public DiscordControllerV2(IServiceProvider svc) : base(svc) { }

View File

@ -7,8 +7,7 @@ using PluralKit.Core;
namespace PluralKit.API; namespace PluralKit.API;
[ApiController] [ApiController]
[ApiVersion("2.0")] [Route("v2")]
[Route("v{version:apiVersion}")]
public class GroupControllerV2: PKControllerBase public class GroupControllerV2: PKControllerBase
{ {
public GroupControllerV2(IServiceProvider svc) : base(svc) { } public GroupControllerV2(IServiceProvider svc) : base(svc) { }

View File

@ -7,8 +7,7 @@ using PluralKit.Core;
namespace PluralKit.API; namespace PluralKit.API;
[ApiController] [ApiController]
[ApiVersion("2.0")] [Route("v2")]
[Route("v{version:apiVersion}")]
public class GroupMemberControllerV2: PKControllerBase public class GroupMemberControllerV2: PKControllerBase
{ {
public GroupMemberControllerV2(IServiceProvider svc) : base(svc) { } public GroupMemberControllerV2(IServiceProvider svc) : base(svc) { }

View File

@ -7,8 +7,7 @@ using PluralKit.Core;
namespace PluralKit.API; namespace PluralKit.API;
[ApiController] [ApiController]
[ApiVersion("2.0")] [Route("v2")]
[Route("v{version:apiVersion}")]
public class MemberControllerV2: PKControllerBase public class MemberControllerV2: PKControllerBase
{ {
public MemberControllerV2(IServiceProvider svc) : base(svc) { } public MemberControllerV2(IServiceProvider svc) : base(svc) { }

View File

@ -5,8 +5,7 @@ using Newtonsoft.Json.Linq;
namespace PluralKit.API; namespace PluralKit.API;
[ApiController] [ApiController]
[ApiVersion("2.0")] [Route("v2")]
[Route("v{version:apiVersion}")]
public class PrivateControllerV2: PKControllerBase public class PrivateControllerV2: PKControllerBase
{ {
public PrivateControllerV2(IServiceProvider svc) : base(svc) { } public PrivateControllerV2(IServiceProvider svc) : base(svc) { }

View File

@ -11,8 +11,7 @@ using PluralKit.Core;
namespace PluralKit.API; namespace PluralKit.API;
[ApiController] [ApiController]
[ApiVersion("2.0")] [Route("v2")]
[Route("v{version:apiVersion}")]
public class SwitchControllerV2: PKControllerBase public class SwitchControllerV2: PKControllerBase
{ {
public SwitchControllerV2(IServiceProvider svc) : base(svc) { } public SwitchControllerV2(IServiceProvider svc) : base(svc) { }

View File

@ -7,8 +7,7 @@ using PluralKit.Core;
namespace PluralKit.API; namespace PluralKit.API;
[ApiController] [ApiController]
[ApiVersion("2.0")] [Route("v2/systems")]
[Route("v{version:apiVersion}/systems")]
public class SystemControllerV2: PKControllerBase public class SystemControllerV2: PKControllerBase
{ {
public SystemControllerV2(IServiceProvider svc) : base(svc) { } public SystemControllerV2(IServiceProvider svc) : base(svc) { }

View File

@ -64,15 +64,6 @@ public class Startup
throw Errors.GenericBadRequest throw Errors.GenericBadRequest
); );
services.AddApiVersioning();
services.AddVersionedApiExplorer(c =>
{
c.GroupNameFormat = "'v'VV";
c.ApiVersionParameterSource = new UrlSegmentApiVersionReader();
c.SubstituteApiVersionInUrl = true;
});
services.AddSwaggerGen(c => services.AddSwaggerGen(c =>
{ {
c.SwaggerDoc("v1.0", new OpenApiInfo { Title = "PluralKit", Version = "1.0" }); c.SwaggerDoc("v1.0", new OpenApiInfo { Title = "PluralKit", Version = "1.0" });

View File

@ -444,8 +444,8 @@
}, },
"Microsoft.NETCore.Platforms": { "Microsoft.NETCore.Platforms": {
"type": "Transitive", "type": "Transitive",
"resolved": "1.1.0", "resolved": "5.0.0",
"contentHash": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==" "contentHash": "VyPlqzH2wavqquTcYpkIIAQ6WdenuKoFN0BdYBbCWsclXacSOHNQn66Gt4z5NBqEYW0FAPm5rlvki9ZiCij5xQ=="
}, },
"Microsoft.NETCore.Targets": { "Microsoft.NETCore.Targets": {
"type": "Transitive", "type": "Transitive",
@ -467,6 +467,23 @@
"System.Runtime": "4.3.0" "System.Runtime": "4.3.0"
} }
}, },
"Microsoft.Win32.Registry": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "dDoKi0PnDz31yAyETfRntsLArTlVAVzUzCIvvEDsDsucrl33Dl8pIJG06ePTJTI3tGpeyHS9Cq7Foc/s4EeKcg==",
"dependencies": {
"System.Security.AccessControl": "5.0.0",
"System.Security.Principal.Windows": "5.0.0"
}
},
"Microsoft.Win32.SystemEvents": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "Bh6blKG8VAKvXiLe2L+sEsn62nc1Ij34MrNxepD2OCrS5cpCwQa9MeLyhVQPQ/R4Wlzwuy6wMK8hLb11QPDRsQ==",
"dependencies": {
"Microsoft.NETCore.Platforms": "5.0.0"
}
},
"NETStandard.Library": { "NETStandard.Library": {
"type": "Transitive", "type": "Transitive",
"resolved": "1.6.1", "resolved": "1.6.1",
@ -565,6 +582,14 @@
"Npgsql": "4.1.5" "Npgsql": "4.1.5"
} }
}, },
"Pipelines.Sockets.Unofficial": {
"type": "Transitive",
"resolved": "2.2.0",
"contentHash": "7hzHplEIVOGBl5zOQZGX/DiJDHjq+RVRVrYgDiqXb6RriqWAdacXxp+XO9WSrATCEXyNOUOQg9aqQArsjase/A==",
"dependencies": {
"System.IO.Pipelines": "5.0.0"
}
},
"runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl": { "runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl": {
"type": "Transitive", "type": "Transitive",
"resolved": "4.3.0", "resolved": "4.3.0",
@ -824,6 +849,15 @@
"dapper": "1.50.5" "dapper": "1.50.5"
} }
}, },
"StackExchange.Redis": {
"type": "Transitive",
"resolved": "2.2.88",
"contentHash": "JJi1jcO3/ZiamBhlsC/TR8aZmYf+nqpGzMi0HRRCy5wJkUPmMnRp0kBA6V84uhU8b531FHSdTDaFCAyCUJomjA==",
"dependencies": {
"Pipelines.Sockets.Unofficial": "2.2.0",
"System.Diagnostics.PerformanceCounter": "5.0.0"
}
},
"Swashbuckle.AspNetCore": { "Swashbuckle.AspNetCore": {
"type": "Transitive", "type": "Transitive",
"resolved": "5.0.0", "resolved": "5.0.0",
@ -875,6 +909,15 @@
"System.Threading.Tasks": "4.3.0" "System.Threading.Tasks": "4.3.0"
} }
}, },
"System.Configuration.ConfigurationManager": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "aM7cbfEfVNlEEOj3DsZP+2g9NRwbkyiAv2isQEzw7pnkDg9ekCU2m1cdJLM02Uq691OaCS91tooaxcEn8d0q5w==",
"dependencies": {
"System.Security.Cryptography.ProtectedData": "5.0.0",
"System.Security.Permissions": "5.0.0"
}
},
"System.Console": { "System.Console": {
"type": "Transitive", "type": "Transitive",
"resolved": "4.3.0", "resolved": "4.3.0",
@ -902,6 +945,17 @@
"resolved": "4.7.1", "resolved": "4.7.1",
"contentHash": "j81Lovt90PDAq8kLpaJfJKV/rWdWuEk6jfV+MBkee33vzYLEUsy4gXK8laa9V2nZlLM9VM9yA/OOQxxPEJKAMw==" "contentHash": "j81Lovt90PDAq8kLpaJfJKV/rWdWuEk6jfV+MBkee33vzYLEUsy4gXK8laa9V2nZlLM9VM9yA/OOQxxPEJKAMw=="
}, },
"System.Diagnostics.PerformanceCounter": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "kcQWWtGVC3MWMNXdMDWfrmIlFZZ2OdoeT6pSNVRtk9+Sa7jwdPiMlNwb0ZQcS7NRlT92pCfmjRtkSWUW3RAKwg==",
"dependencies": {
"Microsoft.NETCore.Platforms": "5.0.0",
"Microsoft.Win32.Registry": "5.0.0",
"System.Configuration.ConfigurationManager": "5.0.0",
"System.Security.Principal.Windows": "5.0.0"
}
},
"System.Diagnostics.Tools": { "System.Diagnostics.Tools": {
"type": "Transitive", "type": "Transitive",
"resolved": "4.3.0", "resolved": "4.3.0",
@ -922,6 +976,14 @@
"System.Runtime": "4.3.0" "System.Runtime": "4.3.0"
} }
}, },
"System.Drawing.Common": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "SztFwAnpfKC8+sEKXAFxCBWhKQaEd97EiOL7oZJZP56zbqnLpmxACWA8aGseaUExciuEAUuR9dY8f7HkTRAdnw==",
"dependencies": {
"Microsoft.Win32.SystemEvents": "5.0.0"
}
},
"System.Dynamic.Runtime": { "System.Dynamic.Runtime": {
"type": "Transitive", "type": "Transitive",
"resolved": "4.0.11", "resolved": "4.0.11",
@ -1059,6 +1121,11 @@
"System.Runtime": "4.3.0" "System.Runtime": "4.3.0"
} }
}, },
"System.IO.Pipelines": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "irMYm3vhVgRsYvHTU5b2gsT2CwT/SMM6LZFzuJjpIvT5Z4CshxNsaoBC1X/LltwuR3Opp8d6jOS/60WwOb7Q2Q=="
},
"System.Linq": { "System.Linq": {
"type": "Transitive", "type": "Transitive",
"resolved": "4.3.0", "resolved": "4.3.0",
@ -1315,6 +1382,15 @@
"System.Runtime.Extensions": "4.3.0" "System.Runtime.Extensions": "4.3.0"
} }
}, },
"System.Security.AccessControl": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "dagJ1mHZO3Ani8GH0PHpPEe/oYO+rVdbQjvjJkBRNQkX4t0r1iaeGn8+/ybkSLEan3/slM0t59SVdHzuHf2jmw==",
"dependencies": {
"Microsoft.NETCore.Platforms": "5.0.0",
"System.Security.Principal.Windows": "5.0.0"
}
},
"System.Security.Cryptography.Algorithms": { "System.Security.Cryptography.Algorithms": {
"type": "Transitive", "type": "Transitive",
"resolved": "4.3.0", "resolved": "4.3.0",
@ -1427,6 +1503,11 @@
"System.Threading.Tasks": "4.3.0" "System.Threading.Tasks": "4.3.0"
} }
}, },
"System.Security.Cryptography.ProtectedData": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "HGxMSAFAPLNoxBvSfW08vHde0F9uh7BjASwu6JF9JnXuEPhCY3YUqURn0+bQV/4UWeaqymmrHWV+Aw9riQCtCA=="
},
"System.Security.Cryptography.X509Certificates": { "System.Security.Cryptography.X509Certificates": {
"type": "Transitive", "type": "Transitive",
"resolved": "4.3.0", "resolved": "4.3.0",
@ -1459,6 +1540,20 @@
"runtime.native.System.Security.Cryptography.OpenSsl": "4.3.0" "runtime.native.System.Security.Cryptography.OpenSsl": "4.3.0"
} }
}, },
"System.Security.Permissions": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "uE8juAhEkp7KDBCdjDIE3H9R1HJuEHqeqX8nLX9gmYKWwsqk3T5qZlPx8qle5DPKimC/Fy3AFTdV7HamgCh9qQ==",
"dependencies": {
"System.Security.AccessControl": "5.0.0",
"System.Windows.Extensions": "5.0.0"
}
},
"System.Security.Principal.Windows": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "t0MGLukB5WAVU9bO3MGzvlGnyJPgUlcwerXn1kzBRjwLKixT96XV0Uza41W49gVd8zEMFu9vQEFlv0IOrytICA=="
},
"System.Text.Encoding": { "System.Text.Encoding": {
"type": "Transitive", "type": "Transitive",
"resolved": "4.3.0", "resolved": "4.3.0",
@ -1532,6 +1627,14 @@
"System.Runtime": "4.3.0" "System.Runtime": "4.3.0"
} }
}, },
"System.Windows.Extensions": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "c1ho9WU9ZxMZawML+ssPKZfdnrg/OjR3pe0m9v8230z3acqphwvPJqzAkH54xRYm5ntZHGG1EPP3sux9H3qSPg==",
"dependencies": {
"System.Drawing.Common": "5.0.0"
}
},
"System.Xml.ReaderWriter": { "System.Xml.ReaderWriter": {
"type": "Transitive", "type": "Transitive",
"resolved": "4.3.0", "resolved": "4.3.0",
@ -1605,6 +1708,7 @@
"Serilog.Sinks.File": "4.1.0", "Serilog.Sinks.File": "4.1.0",
"SqlKata": "2.3.7", "SqlKata": "2.3.7",
"SqlKata.Execution": "2.3.7", "SqlKata.Execution": "2.3.7",
"StackExchange.Redis": "2.2.88",
"System.Interactive.Async": "5.0.0", "System.Interactive.Async": "5.0.0",
"ipnetwork2": "2.5.381" "ipnetwork2": "2.5.381"
} }