Skip to content

Commit

Permalink
Merge pull request #18 from dlcs/fix/serializationErrors
Browse files Browse the repository at this point in the history
Hierarchical collection to return with AsJson
  • Loading branch information
JackLewis-digirati authored Sep 13, 2024
2 parents ec18cbd + 4440462 commit 05fdc4b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/IIIFPresentation/API/Features/Storage/StorageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using FluentValidation;
using Models.API.Collection;
using IIIF.Presentation;
using IIIF.Serialisation;
using Models.API.Collection.Upsert;

namespace API.Features.Storage;
Expand All @@ -28,7 +28,8 @@ public async Task<IActionResult> GetHierarchicalRootCollection(int customerId)

if (storageRoot.Collection == null) return NotFound();

return Ok(storageRoot.Collection.ToHierarchicalCollection(GetUrlRoots(), storageRoot.Items));
return Content(storageRoot.Collection.ToHierarchicalCollection(GetUrlRoots(), storageRoot.Items).AsJson(),
ContentTypes.V3);
}

[HttpGet("{*slug}")]
Expand All @@ -39,7 +40,8 @@ public async Task<IActionResult> GetHierarchicalCollection(int customerId, strin

if (storageRoot.Collection is not { IsPublic: true }) return NotFound();

return Ok(storageRoot.Collection.ToHierarchicalCollection(GetUrlRoots(), storageRoot.Items));
return Content(storageRoot.Collection.ToHierarchicalCollection(GetUrlRoots(), storageRoot.Items).AsJson(),
ContentTypes.V3);
}

[HttpGet("collections/{id}")]
Expand All @@ -50,9 +52,13 @@ public async Task<IActionResult> Get(int customerId, string id)

if (storageRoot.Collection == null) return NotFound();

return Ok(Request.ShowExtraProperties()
? storageRoot.Collection.ToFlatCollection(GetUrlRoots(), Settings.PageSize, storageRoot.Items)
: storageRoot.Collection.ToHierarchicalCollection(GetUrlRoots(), storageRoot.Items));
if (Request.ShowExtraProperties())
{
return Ok(storageRoot.Collection.ToFlatCollection(GetUrlRoots(), Settings.PageSize, storageRoot.Items));
}

return Content(storageRoot.Collection.ToHierarchicalCollection(GetUrlRoots(), storageRoot.Items).AsJson(),
ContentTypes.V3);
}

[HttpPost("collections")]
Expand Down

0 comments on commit 05fdc4b

Please sign in to comment.