Repository navigation
Admin API: GetCollectionById returns the collection, not a list of it - #1122
Merged
Merged
Conversation
The endpoint is documented to return a CollectionDto, as GetBrandById and GetCategoryById do, but it returned the whole query, which serialized as a JSON array of one element. It now returns the collection itself; 404 for an unknown key is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type: bugfix
Issue
GET /api/Collection/{key}(GetCollectionById) is documented to return aCollectionDto, asGetBrandByIdandGetCategoryByIddo, but it returned the whole query: the response was a JSON array holding the one collection.Solution
The action returns the collection itself (
FirstOrDefault()after the existing not-found check), like the other get-by-key actions. 404 for an unknown key is unchanged.Breaking changes
A client that read this endpoint's response as an array (
[ { ... } ]) now gets the object ({ ... }), which is what the OpenAPI document already described.Testing
GET /api/Collection/{id}of an existing collection: the body is one collection object, not an array.GET /api/Collection/{unknown id}: 404.CollectionControllerTestscovers both;Grand.Module.Api.Tests(136) pass.