Update categoryv1.0.0 · JSON Schema
Updates an existing category in the Catalog.
1. Rename an Existing Category
A backoffice catalog manager renames a category (PUT /api/v1/categories).
Payload details
id: Required category UUID.name: Required non-empty updated category name.
Example payload
{ "id": "01960a1b-1000-7000-8a9b-0c1d2e3f4a01", "name": "Speculative & Science Fiction"}Using this example
Returns 200 OK with the updated Category JSON payload and invalidates cached category queries.
using BookWorm.Chassis.Utilities.Configurations;using BookWorm.Constants.Aspire;using Refit;
public interface ICatalogApiClient{ [Put("/api/v1/categories")] Task<CategoryResponse> UpdateCategoryAsync( [Body] UpdateCategoryRequest request, CancellationToken cancellationToken = default );}
public sealed record UpdateCategoryRequest(Guid Id, string Name);
// DI registration following BookWorm.Chassis Refit patternbuilder.Services .AddRefitGeneratedClient<ICatalogApiClient>(settings, Services.Catalog) .ConfigureHttpClient(client => client.BaseAddress = new($"https+http://{Services.Catalog}")) .ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler { PooledConnectionLifetime = TimeSpan.FromMinutes(5) } );
// Typed invocationvar updated = await catalogApiClient.UpdateCategoryAsync( new(Guid.Parse("01960a1b-1000-7000-8a9b-0c1d2e3f4a01"), "Speculative & Science Fiction"), cancellationToken);import categoriesApiClient from "@workspace/api-client/catalog/categories";import useUpdateCategory from "@workspace/api-hooks/catalog/categories/useUpdateCategory";
const request = { id: "01960a1b-1000-7000-8a9b-0c1d2e3f4a01", name: "Speculative & Science Fiction",};
// 1. Direct @workspace/api-client (Axios) callconst updatedCategory = await categoriesApiClient.update(request);
// 2. React / TanStack Query hook (@workspace/api-hooks)const { mutate: updateCategory, isPending } = useUpdateCategory({ onSuccess: (category) => { console.log(`Updated category ${category.id}: ${category.name}`); },});
updateCategory(request);1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "UpdateCategory",
4 "description": "Payload for updating a category.",
5 "type": "object",
6 "additionalProperties": false,
7 "required": ["id", "name"],
8 "properties": {
9 "id": {
10 "type": "string",
11 "format": "uuid",
12 "description": "Identifier of the category to update."
13 },
14 "name": {
15 "type": "string",
16 "minLength": 1,
17 "description": "New display name for the category."
18 }
19 }
20}
21