Create publisherv1.0.0 · JSON Schema
Creates a publisher in the Catalog.
1. Register a New Publisher
A backoffice catalog manager registers “Ace Books” as a publisher in Catalog API.
Payload details
name: Required non-empty publisher name.
Example payload
{ "name": "Ace Books"}Using this example
Returns 201 Created with the created Publisher JSON payload and invalidates the publishers list cache.
using BookWorm.Chassis.Utilities.Configurations;using BookWorm.Constants.Aspire;using Refit;
public interface ICatalogApiClient{ [Post("/api/v1/publishers")] Task<PublisherResponse> CreatePublisherAsync( [Body] CreatePublisherRequest request, CancellationToken cancellationToken = default );}
public sealed record CreatePublisherRequest(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 publisher = await catalogApiClient.CreatePublisherAsync( new("Ace Books"), cancellationToken);import publishersApiClient from "@workspace/api-client/catalog/publishers";import useCreatePublisher from "@workspace/api-hooks/catalog/publishers/useCreatePublisher";
// 1. Direct @workspace/api-client (Axios) callconst publisher = await publishersApiClient.create({ name: "Ace Books",});
// 2. React / TanStack Query hook (@workspace/api-hooks)const { mutate: createPublisher, isPending } = useCreatePublisher({ onSuccess: (created) => { console.log(`Created publisher ${created.id}: ${created.name}`); },});
createPublisher({ name: "Ace Books" });1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "CreatePublisher",
4 "description": "Payload for CreatePublisher.",
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