List booksv1.0.0 · JSON Schema
Returns a filterable collection of books with pricing, availability, relationships, and rating summaries.
1. Search and Filter Books with HTTP QUERY
A storefront shopper filters the catalog for science-fiction titles between $10 and $30 using the HTTP QUERY method on /api/v1/books.
Payload details
- Request body (
ListBooksQuery):pageIndex,pageSize,orderBy,isDescending,search,minPrice,maxPrice,categoryId,publisherId,authorIds. - Response body: JSON array of book summaries matching
ListBooksResponse, accompanied byPagination-CountandLinkheaders.
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 a JSON array of matching Book records and Pagination-Count / Link headers.
using BookWorm.Chassis.Utilities.Configurations;using BookWorm.Constants.Aspire;using Refit;
[AttributeUsage(AttributeTargets.Method)]public sealed class QueryMethodAttribute(string path) : HttpMethodAttribute(path){ public override HttpMethod Method => new("QUERY");}
public interface ICatalogApiClient{ [QueryMethod("/api/v1/books")] Task<IReadOnlyList<BookResponse>> ListBooksAsync( [Body] ListBooksRequest query, CancellationToken cancellationToken = default );}
public sealed record ListBooksRequest( int PageIndex = 1, int PageSize = 20, string? OrderBy = null, bool IsDescending = false, string? Search = null, decimal? MinPrice = null, decimal? MaxPrice = null, Guid[]? CategoryId = null, Guid[]? AuthorIds = null);
// 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 books = await catalogApiClient.ListBooksAsync( new(Search: "left hand", MinPrice: 10m, MaxPrice: 30m), cancellationToken);import booksApiClient from "@workspace/api-client/catalog/books";import useBooks from "@workspace/api-hooks/catalog/books/useBooks";
const query = { pageIndex: 1, pageSize: 20, orderBy: "Name", isDescending: false, search: "left hand", minPrice: 10, maxPrice: 30, categoryId: ["01960a1b-1000-7000-8a9b-0c1d2e3f4a01"], authorIds: ["01960a1b-3000-7000-8a9b-0c1d2e3f4a03"],};
// 1. Direct @workspace/api-client (Axios HTTP QUERY) callconst pagedBooks = await booksApiClient.list(query);
// 2. React / TanStack Query hook (@workspace/api-hooks)const { data: books, isLoading } = useBooks(query);1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "ListBooksResponse",
4 "description": "Book collection returned by the Catalog API.",
5 "type": "array",
6 "items": {
7 "type": "object",
8 "additionalProperties": false,
9 "required": [
10 "id",
11 "name",
12 "description",
13 "imageUrl",
14 "price",
15 "priceSale",
16 "status",
17 "category",
18 "publisher",
19 "authors",
20 "averageRating",
21 "totalReviews"
22 ],
23 "properties": {
24 "id": {
25 "type": "string",
26 "format": "uuid",
27 "description": "A UUID identifying the resource."
28 },
29 "name": {
30 "type": ["string", "null"]
31 },
32 "description": {
33 "type": ["string", "null"]
34 },
35 "imageUrl": {
36 "type": ["string", "null"],
37 "format": "uri"
38 },
39 "price": {
40 "type": "number"
41 },
42 "priceSale": {
43 "type": ["number", "null"]
44 },
45 "status": {
46 "type": "string",
47 "enum": ["InStock", "OutOfStock"]
48 },
49 "category": {
50 "type": ["object", "null"],
51 "properties": {
52 "id": {
53 "type": "string",
54 "format": "uuid",
55 "description": "A UUID identifying the resource."
56 },
57 "name": {
58 "type": ["string", "null"]
59 }
60 },
61 "required": ["id", "name"]
62 },
63 "publisher": {
64 "type": ["object", "null"],
65 "properties": {
66 "id": {
67 "type": "string",
68 "format": "uuid",
69 "description": "A UUID identifying the resource."
70 },
71 "name": {
72 "type": ["string", "null"]
73 }
74 },
75 "required": ["id", "name"]
76 },
77 "authors": {
78 "type": "array",
79 "items": {
80 "type": "object",
81 "properties": {
82 "id": {
83 "type": "string",
84 "format": "uuid",
85 "description": "A UUID identifying the resource."
86 },
87 "name": {
88 "type": ["string", "null"]
89 }
90 },
91 "required": ["id", "name"]
92 }
93 },
94 "averageRating": {
95 "type": "number",
96 "minimum": 0
97 },
98 "totalReviews": {
99 "type": "integer",
100 "minimum": 0
101 }
102 }
103 }
104}
105