WIP NuGet API 3.5.0
This commit is contained in:
parent
c06f518836
commit
a4a1c6e271
12 changed files with 172 additions and 98 deletions
37
src/isnd/Controllers/PackagesController.GetVersions.cs
Normal file
37
src/isnd/Controllers/PackagesController.GetVersions.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using NuGet.Versioning;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
public partial class PackagesController
|
||||
{
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/index.json")]
|
||||
public IActionResult GetVersions(
|
||||
string id,
|
||||
string lower,
|
||||
bool prerelease = false,
|
||||
string packageType = null,
|
||||
int skip = 0,
|
||||
int take = 25)
|
||||
{
|
||||
if (take > maxTake)
|
||||
{
|
||||
ModelState.AddModelError("take", "Maximum exceeded");
|
||||
}
|
||||
// NugetVersion
|
||||
if (!NuGetVersion.TryParse(lower, out NuGetVersion parsedVersion))
|
||||
{
|
||||
ModelState.AddModelError("lower", "invalid version string");
|
||||
}
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
return Ok(new
|
||||
{
|
||||
versions = _packageManager.GetVersions(
|
||||
id, parsedVersion, prerelease, packageType, skip, take)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue