Deprecate API v1 - API v1.1 is now default (#469)
This commit is contained in:
@@ -15,7 +15,7 @@ namespace gaseous_server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize]
|
||||
public class AccountController : Controller
|
||||
|
@@ -10,7 +10,7 @@ namespace gaseous_server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize(Roles = "Admin,Gamer,Player")]
|
||||
public class BackgroundTasksController : Controller
|
||||
|
@@ -12,7 +12,7 @@ namespace gaseous_server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize]
|
||||
public class BiosController : Controller
|
||||
|
@@ -14,7 +14,7 @@ namespace gaseous_server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize]
|
||||
public class CollectionsController : Controller
|
||||
@@ -29,7 +29,7 @@ namespace gaseous_server.Controllers
|
||||
_userManager = userManager;
|
||||
_signInManager = signInManager;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets all ROM collections
|
||||
/// </summary>
|
||||
@@ -145,7 +145,7 @@ namespace gaseous_server.Controllers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return NotFound(ex);
|
||||
return NotFound(ex);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -212,7 +212,7 @@ namespace gaseous_server.Controllers
|
||||
public async Task<ActionResult> NewCollectionAsync(Classes.Collections.CollectionItem Item)
|
||||
{
|
||||
var user = await _userManager.GetUserAsync(User);
|
||||
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
try
|
||||
@@ -246,7 +246,7 @@ namespace gaseous_server.Controllers
|
||||
public async Task<ActionResult> EditCollection(long CollectionId, Classes.Collections.CollectionItem Item)
|
||||
{
|
||||
var user = await _userManager.GetUserAsync(User);
|
||||
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
try
|
||||
@@ -277,10 +277,10 @@ namespace gaseous_server.Controllers
|
||||
[Route("{CollectionId}/AlwaysInclude")]
|
||||
[ProducesResponseType(typeof(Classes.Collections.CollectionItem), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> EditCollectionAlwaysInclude(long CollectionId, [FromQuery]bool Rebuild, [FromBody]Collections.CollectionItem.AlwaysIncludeItem Inclusion)
|
||||
public async Task<ActionResult> EditCollectionAlwaysInclude(long CollectionId, [FromQuery] bool Rebuild, [FromBody] Collections.CollectionItem.AlwaysIncludeItem Inclusion)
|
||||
{
|
||||
var user = await _userManager.GetUserAsync(User);
|
||||
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
try
|
||||
@@ -326,7 +326,7 @@ namespace gaseous_server.Controllers
|
||||
public async Task<ActionResult> DeleteCollection(long CollectionId)
|
||||
{
|
||||
var user = await _userManager.GetUserAsync(User);
|
||||
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
try
|
||||
|
@@ -15,7 +15,7 @@ using Asp.Versioning;
|
||||
namespace gaseous_server.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
@@ -23,7 +23,7 @@ namespace gaseous_server.Controllers
|
||||
{
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
private readonly SignInManager<ApplicationUser> _signInManager;
|
||||
|
||||
|
||||
public FilterController(
|
||||
UserManager<ApplicationUser> userManager,
|
||||
SignInManager<ApplicationUser> signInManager)
|
||||
@@ -40,7 +40,7 @@ namespace gaseous_server.Controllers
|
||||
public async Task<IActionResult> FilterAsync()
|
||||
{
|
||||
var user = await _userManager.GetUserAsync(User);
|
||||
|
||||
|
||||
return Ok(Filters.Filter(user.SecurityProfile.AgeRestrictionPolicy.MaximumAgeRestriction, user.SecurityProfile.AgeRestrictionPolicy.IncludeUnrated));
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ using Asp.Versioning;
|
||||
namespace gaseous_server.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
@@ -30,7 +30,7 @@ namespace gaseous_server.Controllers
|
||||
{
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
private readonly SignInManager<ApplicationUser> _signInManager;
|
||||
|
||||
|
||||
public GamesController(
|
||||
UserManager<ApplicationUser> userManager,
|
||||
SignInManager<ApplicationUser> signInManager
|
||||
@@ -53,7 +53,7 @@ namespace gaseous_server.Controllers
|
||||
int minrating = -1,
|
||||
int maxrating = -1,
|
||||
bool sortdescending = false)
|
||||
{
|
||||
{
|
||||
|
||||
return Ok(GetGames(name, platform, genre, gamemode, playerperspective, theme, minrating, maxrating, "Adult", true, true, sortdescending));
|
||||
}
|
||||
@@ -473,14 +473,15 @@ namespace gaseous_server.Controllers
|
||||
try
|
||||
{
|
||||
IGDB.Models.Artwork artworkObject = Artworks.GetArtwork(ArtworkId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), true);
|
||||
|
||||
if (artworkObject != null) {
|
||||
|
||||
if (artworkObject != null)
|
||||
{
|
||||
//string coverFilePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Artwork", size.ToString(), artworkObject.ImageId + ".jpg");
|
||||
|
||||
string basePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Artwork");
|
||||
|
||||
Communications comms = new Communications();
|
||||
Task<string> ImgFetch = comms.GetSpecificImageFromServer(basePath, artworkObject.ImageId, size, new List<Communications.IGDBAPI_ImageSize>{ Communications.IGDBAPI_ImageSize.original });
|
||||
Task<string> ImgFetch = comms.GetSpecificImageFromServer(basePath, artworkObject.ImageId, size, new List<Communications.IGDBAPI_ImageSize> { Communications.IGDBAPI_ImageSize.original });
|
||||
|
||||
string coverFilePath = ImgFetch.Result;
|
||||
|
||||
@@ -578,13 +579,14 @@ namespace gaseous_server.Controllers
|
||||
{
|
||||
IGDB.Models.Cover cover = Classes.Metadata.Covers.GetCover(gameObject.Cover.Id, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), false);
|
||||
string basePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Covers");
|
||||
|
||||
|
||||
Communications comms = new Communications();
|
||||
Task<string> ImgFetch = comms.GetSpecificImageFromServer(basePath, cover.ImageId, size, new List<Communications.IGDBAPI_ImageSize>{ Communications.IGDBAPI_ImageSize.cover_big, Communications.IGDBAPI_ImageSize.original });
|
||||
Task<string> ImgFetch = comms.GetSpecificImageFromServer(basePath, cover.ImageId, size, new List<Communications.IGDBAPI_ImageSize> { Communications.IGDBAPI_ImageSize.cover_big, Communications.IGDBAPI_ImageSize.original });
|
||||
|
||||
string coverFilePath = ImgFetch.Result;
|
||||
|
||||
if (System.IO.File.Exists(coverFilePath)) {
|
||||
if (System.IO.File.Exists(coverFilePath))
|
||||
{
|
||||
string filename = cover.ImageId + ".jpg";
|
||||
string filepath = coverFilePath;
|
||||
byte[] filedata = System.IO.File.ReadAllBytes(filepath);
|
||||
@@ -627,7 +629,7 @@ namespace gaseous_server.Controllers
|
||||
if (gameObject != null)
|
||||
{
|
||||
var user = await _userManager.GetUserAsync(User);
|
||||
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
Favourites favourites = new Favourites();
|
||||
@@ -664,7 +666,7 @@ namespace gaseous_server.Controllers
|
||||
if (gameObject != null)
|
||||
{
|
||||
var user = await _userManager.GetUserAsync(User);
|
||||
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
Favourites favourites = new Favourites();
|
||||
@@ -796,7 +798,8 @@ namespace gaseous_server.Controllers
|
||||
companyData.Add("company", company);
|
||||
|
||||
return Ok(companyData);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
@@ -895,7 +898,7 @@ namespace gaseous_server.Controllers
|
||||
foreach (long icId in gameObject.ReleaseDates.Ids)
|
||||
{
|
||||
ReleaseDate releaseDate = Classes.Metadata.ReleaseDates.GetReleaseDates(icId);
|
||||
|
||||
|
||||
rdObjects.Add(releaseDate);
|
||||
}
|
||||
}
|
||||
@@ -923,7 +926,7 @@ namespace gaseous_server.Controllers
|
||||
public async Task<ActionResult> GameRomAsync(long GameId, int pageNumber = 0, int pageSize = 0, long PlatformId = -1, string NameSearch = "")
|
||||
{
|
||||
var user = await _userManager.GetUserAsync(User);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false);
|
||||
@@ -1113,7 +1116,7 @@ namespace gaseous_server.Controllers
|
||||
public async Task<ActionResult> GameRomGroupAsync(long GameId, long RomGroupId)
|
||||
{
|
||||
var user = await _userManager.GetUserAsync(User);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false);
|
||||
@@ -1144,7 +1147,7 @@ namespace gaseous_server.Controllers
|
||||
public async Task<ActionResult> GetGameRomGroupAsync(long GameId)
|
||||
{
|
||||
var user = await _userManager.GetUserAsync(User);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false);
|
||||
@@ -1204,7 +1207,7 @@ namespace gaseous_server.Controllers
|
||||
public async Task<ActionResult> GameRomGroupMembersAsync(long GameId, long RomGroupId, [FromBody] List<long> RomIds)
|
||||
{
|
||||
var user = await _userManager.GetUserAsync(User);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false);
|
||||
@@ -1386,9 +1389,10 @@ namespace gaseous_server.Controllers
|
||||
public async Task<ActionResult> GameScreenshot(long GameId, long ScreenshotId)
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
IGDB.Models.Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false);
|
||||
if (gameObject != null) {
|
||||
if (gameObject != null)
|
||||
{
|
||||
IGDB.Models.Screenshot screenshotObject = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), false);
|
||||
if (screenshotObject != null)
|
||||
{
|
||||
@@ -1428,7 +1432,7 @@ namespace gaseous_server.Controllers
|
||||
string basePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Screenshots");
|
||||
|
||||
Communications comms = new Communications();
|
||||
Task<string> ImgFetch = comms.GetSpecificImageFromServer(basePath, screenshotObject.ImageId, Size, new List<Communications.IGDBAPI_ImageSize>{ Communications.IGDBAPI_ImageSize.original });
|
||||
Task<string> ImgFetch = comms.GetSpecificImageFromServer(basePath, screenshotObject.ImageId, Size, new List<Communications.IGDBAPI_ImageSize> { Communications.IGDBAPI_ImageSize.original });
|
||||
|
||||
string coverFilePath = ImgFetch.Result;
|
||||
|
||||
|
@@ -11,7 +11,7 @@ namespace gaseous_server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public class LibraryController : Controller
|
||||
|
@@ -11,7 +11,7 @@ namespace gaseous_server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public class LogsController : Controller
|
||||
|
@@ -19,7 +19,7 @@ using Asp.Versioning;
|
||||
namespace gaseous_server.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
|
@@ -18,7 +18,7 @@ using Asp.Versioning;
|
||||
namespace gaseous_server.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
|
@@ -19,7 +19,7 @@ using Asp.Versioning;
|
||||
namespace gaseous_server.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
|
@@ -18,7 +18,7 @@ namespace gaseous_server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize]
|
||||
public class SearchController : Controller
|
||||
|
@@ -17,7 +17,7 @@ namespace gaseous_server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v{version:apiVersion}/[controller]/[action]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize]
|
||||
public class SignaturesController : Controller
|
||||
|
@@ -19,7 +19,7 @@ namespace gaseous_server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize]
|
||||
public class SystemController : Controller
|
||||
|
@@ -11,7 +11,7 @@ using System.IO.Compression;
|
||||
namespace gaseous_server.Controllers.v1_1
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[ApiController]
|
||||
public class StateManagerController : ControllerBase
|
||||
|
@@ -9,10 +9,10 @@ using Asp.Versioning;
|
||||
namespace gaseous_server.Controllers.v1_1
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.0", Deprecated = true)]
|
||||
[ApiVersion("1.1")]
|
||||
[ApiController]
|
||||
public class StatisticsController: ControllerBase
|
||||
public class StatisticsController : ControllerBase
|
||||
{
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
private readonly SignInManager<ApplicationUser> _signInManager;
|
||||
|
@@ -136,7 +136,7 @@ builder.Services.AddControllers(options =>
|
||||
});
|
||||
builder.Services.AddApiVersioning(config =>
|
||||
{
|
||||
config.DefaultApiVersion = new ApiVersion(1, 0);
|
||||
config.DefaultApiVersion = new ApiVersion(1, 1);
|
||||
config.AssumeDefaultVersionWhenUnspecified = true;
|
||||
config.ReportApiVersions = true;
|
||||
config.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader(),
|
||||
@@ -207,6 +207,9 @@ builder.Services.AddSwaggerGen(options =>
|
||||
// using System.Reflection;
|
||||
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
|
||||
|
||||
// sort the endpoints
|
||||
options.OrderActionsBy((apiDesc) => $"{apiDesc.RelativePath}_{apiDesc.HttpMethod}");
|
||||
}
|
||||
);
|
||||
builder.Services.AddHostedService<TimedHostedService>();
|
||||
@@ -271,9 +274,12 @@ app.UseSwaggerUI(options =>
|
||||
var descriptions = app.DescribeApiVersions();
|
||||
foreach (var description in descriptions)
|
||||
{
|
||||
var url = $"/swagger/{description.GroupName}/swagger.json";
|
||||
var name = description.GroupName.ToUpperInvariant();
|
||||
options.SwaggerEndpoint(url, name);
|
||||
if (description.IsDeprecated == false)
|
||||
{
|
||||
var url = $"/swagger/{description.GroupName}/swagger.json";
|
||||
var name = description.GroupName.ToUpperInvariant();
|
||||
options.SwaggerEndpoint(url, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
Reference in New Issue
Block a user