Get bookv1.0.0 · JSON Schema
Returns one book and its catalog relationships by identifier.
1. Fetch Book Details for the Storefront Product Page
A storefront visitor opens the product page for “The Left Hand of Darkness” (GET /api/v1/books/{id}), optionally passing If-None-Match for conditional ETag caching.
Payload details
id: Book UUID.name,description,imageUrl: Book metadata and cover image URI.price,priceSale: Regular decimal price and nullable promotional sale price.status:"InStock"or"OutOfStock".category,publisher,authors: Embedded reference objects (id,name).averageRating,totalReviews: Aggregated rating metrics.
Example response
{ "id": "01960a1b-2c3d-7e4f-8a9b-0c1d2e3f4a10", "name": "The Left Hand of Darkness", "description": "A science-fiction novel by Ursula K. Le Guin set on the icy planet Gethen.", "imageUrl": "https://cdn.bookworm.dev/catalog-blob/left-hand-of-darkness.jpg", "price": 18.99, "priceSale": 14.99, "status": "InStock", "category": { "id": "01960a1b-1000-7000-8a9b-0c1d2e3f4a01", "name": "Science Fiction" }, "publisher": { "id": "01960a1b-2000-7000-8a9b-0c1d2e3f4a02", "name": "Ace Books" }, "authors": [ { "id": "01960a1b-3000-7000-8a9b-0c1d2e3f4a03", "name": "Ursula K. Le Guin" } ], "averageRating": 4.8, "totalReviews": 24}Using this example
Returns 200 OK with the GetBookResponse JSON payload (or 304 Not Modified when If-None-Match matches the current ETag).
using BookWorm.Chassis.Utilities.Configurations;using BookWorm.Constants.Aspire;using Refit;
public interface ICatalogApiClient{ [Get("/api/v1/books/{id}")] Task<BookResponse> GetBookAsync(Guid id, CancellationToken cancellationToken = default);}
public sealed record CatalogReferenceResponse(Guid Id, string? Name);
public sealed record BookResponse( Guid Id, string? Name, string? Description, Uri? ImageUrl, decimal Price, decimal? PriceSale, string Status, CatalogReferenceResponse? Category, CatalogReferenceResponse? Publisher, IReadOnlyList<CatalogReferenceResponse> Authors, double AverageRating, int TotalReviews);
// 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 book = await catalogApiClient.GetBookAsync( Guid.Parse("01960a1b-2c3d-7e4f-8a9b-0c1d2e3f4a10"), cancellationToken);import booksApiClient from "@workspace/api-client/catalog/books";import useBook from "@workspace/api-hooks/catalog/books/useBook";
const bookId = "01960a1b-2c3d-7e4f-8a9b-0c1d2e3f4a10";
// 1. Direct @workspace/api-client (Axios) callconst book = await booksApiClient.get(bookId);
// 2. React / TanStack Query hook (@workspace/api-hooks)const { data: bookDetail, isLoading } = useBook(bookId);1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "GetBookResponse",
4 "description": "Book representation returned by the Catalog API.",
5 "type": "object",
6 "allOf": [
7 {
8 "type": "object",
9 "additionalProperties": false,
10 "required": [
11 "id",
12 "name",
13 "description",
14 "imageUrl",
15 "price",
16 "priceSale",
17 "status",
18 "category",
19 "publisher",
20 "authors",
21 "averageRating",
22 "totalReviews"
23 ],
24 "properties": {
25 "id": {
26 "type": "string",
27 "format": "uuid",
28 "description": "A UUID identifying the resource."
29 },
30 "name": {
31 "type": ["string", "null"]
32 },
33 "description": {
34 "type": ["string", "null"]
35 },
36 "imageUrl": {
37 "type": ["string", "null"],
38 "format": "uri"
39 },
40 "price": {
41 "type": "number"
42 },
43 "priceSale": {
44 "type": ["number", "null"]
45 },
46 "status": {
47 "type": "string",
48 "enum": ["InStock", "OutOfStock"]
49 },
50 "category": {
51 "type": ["object", "null"],
52 "properties": {
53 "id": {
54 "type": "string",
55 "format": "uuid",
56 "description": "A UUID identifying the resource."
57 },
58 "name": {
59 "type": ["string", "null"]
60 }
61 },
62 "required": ["id", "name"]
63 },
64 "publisher": {
65 "type": ["object", "null"],
66 "properties": {
67 "id": {
68 "type": "string",
69 "format": "uuid",
70 "description": "A UUID identifying the resource."
71 },
72 "name": {
73 "type": ["string", "null"]
74 }
75 },
76 "required": ["id", "name"]
77 },
78 "authors": {
79 "type": "array",
80 "items": {
81 "type": "object",
82 "properties": {
83 "id": {
84 "type": "string",
85 "format": "uuid",
86 "description": "A UUID identifying the resource."
87 },
88 "name": {
89 "type": ["string", "null"]
90 }
91 },
92 "required": ["id", "name"]
93 }
94 },
95 "averageRating": {
96 "type": "number",
97 "minimum": 0
98 },
99 "totalReviews": {
100 "type": "integer",
101 "minimum": 0
102 }
103 }
104 }
105 ]
106}
107