Deprecate API v1 - API v1.1 is now default (#469)
This commit is contained in:
@@ -15,7 +15,7 @@ namespace gaseous_server.Controllers
|
|||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class AccountController : Controller
|
public class AccountController : Controller
|
||||||
|
@@ -10,7 +10,7 @@ namespace gaseous_server.Controllers
|
|||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[Authorize(Roles = "Admin,Gamer,Player")]
|
[Authorize(Roles = "Admin,Gamer,Player")]
|
||||||
public class BackgroundTasksController : Controller
|
public class BackgroundTasksController : Controller
|
||||||
|
@@ -12,7 +12,7 @@ namespace gaseous_server.Controllers
|
|||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class BiosController : Controller
|
public class BiosController : Controller
|
||||||
|
@@ -14,7 +14,7 @@ namespace gaseous_server.Controllers
|
|||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class CollectionsController : Controller
|
public class CollectionsController : Controller
|
||||||
@@ -145,7 +145,7 @@ namespace gaseous_server.Controllers
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return NotFound(ex);
|
return NotFound(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -277,7 +277,7 @@ namespace gaseous_server.Controllers
|
|||||||
[Route("{CollectionId}/AlwaysInclude")]
|
[Route("{CollectionId}/AlwaysInclude")]
|
||||||
[ProducesResponseType(typeof(Classes.Collections.CollectionItem), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(Classes.Collections.CollectionItem), StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[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);
|
var user = await _userManager.GetUserAsync(User);
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@ using Asp.Versioning;
|
|||||||
namespace gaseous_server.Controllers
|
namespace gaseous_server.Controllers
|
||||||
{
|
{
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
|
@@ -22,7 +22,7 @@ using Asp.Versioning;
|
|||||||
namespace gaseous_server.Controllers
|
namespace gaseous_server.Controllers
|
||||||
{
|
{
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
@@ -53,7 +53,7 @@ namespace gaseous_server.Controllers
|
|||||||
int minrating = -1,
|
int minrating = -1,
|
||||||
int maxrating = -1,
|
int maxrating = -1,
|
||||||
bool sortdescending = false)
|
bool sortdescending = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
return Ok(GetGames(name, platform, genre, gamemode, playerperspective, theme, minrating, maxrating, "Adult", true, true, sortdescending));
|
return Ok(GetGames(name, platform, genre, gamemode, playerperspective, theme, minrating, maxrating, "Adult", true, true, sortdescending));
|
||||||
}
|
}
|
||||||
@@ -474,13 +474,14 @@ namespace gaseous_server.Controllers
|
|||||||
{
|
{
|
||||||
IGDB.Models.Artwork artworkObject = Artworks.GetArtwork(ArtworkId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), true);
|
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 coverFilePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Artwork", size.ToString(), artworkObject.ImageId + ".jpg");
|
||||||
|
|
||||||
string basePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Artwork");
|
string basePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Artwork");
|
||||||
|
|
||||||
Communications comms = new Communications();
|
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;
|
string coverFilePath = ImgFetch.Result;
|
||||||
|
|
||||||
@@ -580,11 +581,12 @@ namespace gaseous_server.Controllers
|
|||||||
string basePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Covers");
|
string basePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Covers");
|
||||||
|
|
||||||
Communications comms = new Communications();
|
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;
|
string coverFilePath = ImgFetch.Result;
|
||||||
|
|
||||||
if (System.IO.File.Exists(coverFilePath)) {
|
if (System.IO.File.Exists(coverFilePath))
|
||||||
|
{
|
||||||
string filename = cover.ImageId + ".jpg";
|
string filename = cover.ImageId + ".jpg";
|
||||||
string filepath = coverFilePath;
|
string filepath = coverFilePath;
|
||||||
byte[] filedata = System.IO.File.ReadAllBytes(filepath);
|
byte[] filedata = System.IO.File.ReadAllBytes(filepath);
|
||||||
@@ -796,7 +798,8 @@ namespace gaseous_server.Controllers
|
|||||||
companyData.Add("company", company);
|
companyData.Add("company", company);
|
||||||
|
|
||||||
return Ok(companyData);
|
return Ok(companyData);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
@@ -1388,7 +1391,8 @@ namespace gaseous_server.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
IGDB.Models.Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false);
|
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);
|
IGDB.Models.Screenshot screenshotObject = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), false);
|
||||||
if (screenshotObject != null)
|
if (screenshotObject != null)
|
||||||
{
|
{
|
||||||
@@ -1428,7 +1432,7 @@ namespace gaseous_server.Controllers
|
|||||||
string basePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Screenshots");
|
string basePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Screenshots");
|
||||||
|
|
||||||
Communications comms = new Communications();
|
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;
|
string coverFilePath = ImgFetch.Result;
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@ namespace gaseous_server.Controllers
|
|||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[Authorize(Roles = "Admin")]
|
[Authorize(Roles = "Admin")]
|
||||||
public class LibraryController : Controller
|
public class LibraryController : Controller
|
||||||
|
@@ -11,7 +11,7 @@ namespace gaseous_server.Controllers
|
|||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[Authorize(Roles = "Admin")]
|
[Authorize(Roles = "Admin")]
|
||||||
public class LogsController : Controller
|
public class LogsController : Controller
|
||||||
|
@@ -19,7 +19,7 @@ using Asp.Versioning;
|
|||||||
namespace gaseous_server.Controllers
|
namespace gaseous_server.Controllers
|
||||||
{
|
{
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
|
@@ -18,7 +18,7 @@ using Asp.Versioning;
|
|||||||
namespace gaseous_server.Controllers
|
namespace gaseous_server.Controllers
|
||||||
{
|
{
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
|
@@ -19,7 +19,7 @@ using Asp.Versioning;
|
|||||||
namespace gaseous_server.Controllers
|
namespace gaseous_server.Controllers
|
||||||
{
|
{
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
|
@@ -18,7 +18,7 @@ namespace gaseous_server.Controllers
|
|||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class SearchController : Controller
|
public class SearchController : Controller
|
||||||
|
@@ -17,7 +17,7 @@ namespace gaseous_server.Controllers
|
|||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v{version:apiVersion}/[controller]/[action]")]
|
[Route("api/v{version:apiVersion}/[controller]/[action]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class SignaturesController : Controller
|
public class SignaturesController : Controller
|
||||||
|
@@ -19,7 +19,7 @@ namespace gaseous_server.Controllers
|
|||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class SystemController : Controller
|
public class SystemController : Controller
|
||||||
|
@@ -11,7 +11,7 @@ using System.IO.Compression;
|
|||||||
namespace gaseous_server.Controllers.v1_1
|
namespace gaseous_server.Controllers.v1_1
|
||||||
{
|
{
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class StateManagerController : ControllerBase
|
public class StateManagerController : ControllerBase
|
||||||
|
@@ -9,10 +9,10 @@ using Asp.Versioning;
|
|||||||
namespace gaseous_server.Controllers.v1_1
|
namespace gaseous_server.Controllers.v1_1
|
||||||
{
|
{
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiVersion("1.0")]
|
[ApiVersion("1.0", Deprecated = true)]
|
||||||
[ApiVersion("1.1")]
|
[ApiVersion("1.1")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class StatisticsController: ControllerBase
|
public class StatisticsController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly UserManager<ApplicationUser> _userManager;
|
private readonly UserManager<ApplicationUser> _userManager;
|
||||||
private readonly SignInManager<ApplicationUser> _signInManager;
|
private readonly SignInManager<ApplicationUser> _signInManager;
|
||||||
|
@@ -136,7 +136,7 @@ builder.Services.AddControllers(options =>
|
|||||||
});
|
});
|
||||||
builder.Services.AddApiVersioning(config =>
|
builder.Services.AddApiVersioning(config =>
|
||||||
{
|
{
|
||||||
config.DefaultApiVersion = new ApiVersion(1, 0);
|
config.DefaultApiVersion = new ApiVersion(1, 1);
|
||||||
config.AssumeDefaultVersionWhenUnspecified = true;
|
config.AssumeDefaultVersionWhenUnspecified = true;
|
||||||
config.ReportApiVersions = true;
|
config.ReportApiVersions = true;
|
||||||
config.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader(),
|
config.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader(),
|
||||||
@@ -207,6 +207,9 @@ builder.Services.AddSwaggerGen(options =>
|
|||||||
// using System.Reflection;
|
// using System.Reflection;
|
||||||
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||||
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
|
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
|
||||||
|
|
||||||
|
// sort the endpoints
|
||||||
|
options.OrderActionsBy((apiDesc) => $"{apiDesc.RelativePath}_{apiDesc.HttpMethod}");
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
builder.Services.AddHostedService<TimedHostedService>();
|
builder.Services.AddHostedService<TimedHostedService>();
|
||||||
@@ -271,9 +274,12 @@ app.UseSwaggerUI(options =>
|
|||||||
var descriptions = app.DescribeApiVersions();
|
var descriptions = app.DescribeApiVersions();
|
||||||
foreach (var description in descriptions)
|
foreach (var description in descriptions)
|
||||||
{
|
{
|
||||||
var url = $"/swagger/{description.GroupName}/swagger.json";
|
if (description.IsDeprecated == false)
|
||||||
var name = description.GroupName.ToUpperInvariant();
|
{
|
||||||
options.SwaggerEndpoint(url, name);
|
var url = $"/swagger/{description.GroupName}/swagger.json";
|
||||||
|
var name = description.GroupName.ToUpperInvariant();
|
||||||
|
options.SwaggerEndpoint(url, name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user