Create authorv1.0.0 · JSON Schema
Creates an author in the Catalog.
1. Register a New Author in the Catalog
A backoffice catalog manager creates an author record for “Ursula K. Le Guin” before linking her to book listings.
Payload details
name: Required non-empty display name of the author.
Example payload
{ "name": "Ursula K. Le Guin"}Using this example
Returns 201 Created with the created Author JSON payload and invalidates the catalog authors list cache.
using BookWorm.Chassis.Utilities.Configurations;using BookWorm.Constants.Aspire;using Refit;
public interface ICatalogApiClient{ [Post("/api/v1/authors")] Task<AuthorResponse> CreateAuthorAsync( [Body] CreateAuthorRequest request, CancellationToken cancellationToken = default );}
public sealed record CreateAuthorRequest(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 author = await catalogApiClient.CreateAuthorAsync( new("Ursula K. Le Guin"), cancellationToken);import authorsApiClient from "@workspace/api-client/catalog/authors";import useCreateAuthor from "@workspace/api-hooks/catalog/authors/useCreateAuthor";
// 1. Direct @workspace/api-client (Axios) callconst author = await authorsApiClient.create({ name: "Ursula K. Le Guin",});
// 2. React / TanStack Query hook (@workspace/api-hooks)const { mutate: createAuthor, isPending } = useCreateAuthor({ onSuccess: (created) => { console.log(`Created author ${created.id}: ${created.name}`); },});
createAuthor({ name: "Ursula K. Le Guin" });1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "CreateAuthor",
4 "description": "Payload for CreateAuthor.",
5 "type": "object",
6 "additionalProperties": false,
7 "required": ["name"],
8 "properties": {
9 "name": {
10 "type": "string",
11 "minLength": 1,
12 "description": "Display name of the catalog resource."
13 }
14 }
15}
16