Skip to content

Admin API: GetCollectionById returns the collection, not a list of it - #1122

Merged
KrzysztofPajak merged 1 commit into
developfrom
fix/api-collection-get-single
Nov 25, 2026
Merged

KrzysztofPajak merged 1 commit into
developfrom
fix/api-collection-get-single

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Type: bugfix

Issue

GET /api/Collection/{key} (GetCollectionById) is documented to return a CollectionDto, as GetBrandById and GetCategoryById do, 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

  1. Enable the backend API and get a token.
  2. GET /api/Collection/{id} of an existing collection: the body is one collection object, not an array.
  3. GET /api/Collection/{unknown id}: 404.

CollectionControllerTests covers both; Grand.Module.Api.Tests (136) pass.

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.
Copilot AI balanced review requested due to automatic review settings November 25, 2026 19:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@KrzysztofPajak
KrzysztofPajak merged commit 5107895 into develop Nov 25, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants