Skip to content

Commit 4302e65

Browse files
committed
Address PR review comments
1 parent 319011e commit 4302e65

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

src/Catalog.API/Apis/CatalogApi.cs

+9-14
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,19 @@ public static class CatalogApi
1212
public static IEndpointRouteBuilder MapCatalogApi(this IEndpointRouteBuilder app)
1313
{
1414
// RouteGroupBuilder for catalog endpoints
15-
// var vapi = app.NewVersionedApi("Catalog").MapGroup("api/catalog");
16-
// var api = vapi.HasApiVersion(1.0).HasApiVersion(2.0);
17-
// var v1 = vapi.HasApiVersion(1.0);
18-
// var v2 = vapi.HasApiVersion(2.0);
19-
2015
var vApi = app.NewVersionedApi("Catalog");
2116
var api = vApi.MapGroup("api/catalog").HasApiVersion(1, 0).HasApiVersion(2, 0);
2217
var v1 = vApi.MapGroup("api/catalog").HasApiVersion(1, 0);
2318
var v2 = vApi.MapGroup("api/catalog").HasApiVersion(2, 0);
2419

2520
// Routes for querying catalog items.
2621
v1.MapGet("/items", GetAllItemsV1)
27-
// .WithName("ListItems")
22+
.WithName("ListItems")
2823
.WithSummary("List catalog items")
2924
.WithDescription("Get a paginated list of items in the catalog.")
3025
.WithTags("Items");
3126
v2.MapGet("/items", GetAllItems)
32-
.WithName("ListItems")
27+
.WithName("ListItems-V2")
3328
.WithSummary("List catalog items")
3429
.WithDescription("Get a paginated list of items in the catalog.")
3530
.WithTags("Items");
@@ -56,14 +51,14 @@ public static IEndpointRouteBuilder MapCatalogApi(this IEndpointRouteBuilder app
5651

5752
// Routes for resolving catalog items using AI.
5853
v1.MapGet("/items/withsemanticrelevance/{text:minlength(1)}", GetItemsBySemanticRelevanceV1)
59-
// .WithName("GetRelevantItems")
54+
.WithName("GetRelevantItems")
6055
.WithSummary("Search catalog for relevant items")
6156
.WithDescription("Search the catalog for items related to the specified text")
6257
.WithTags("Search");
6358

6459
// Routes for resolving catalog items using AI.
6560
v2.MapGet("/items/withsemanticrelevance", GetItemsBySemanticRelevance)
66-
.WithName("GetRelevantItems")
61+
.WithName("GetRelevantItems-V2")
6762
.WithSummary("Search catalog for relevant items")
6863
.WithDescription("Search the catalog for items related to the specified text")
6964
.WithTags("Search");
@@ -96,12 +91,12 @@ public static IEndpointRouteBuilder MapCatalogApi(this IEndpointRouteBuilder app
9691

9792
// Routes for modifying catalog items.
9893
v1.MapPut("/items", UpdateItemV1)
99-
// .WithName("UpdateItem")
94+
.WithName("UpdateItem")
10095
.WithSummary("Create or replace a catalog item")
10196
.WithDescription("Create or replace a catalog item")
10297
.WithTags("Items");
10398
v2.MapPut("/items/{id:int}", UpdateItem)
104-
.WithName("UpdateItem")
99+
.WithName("UpdateItem-V2")
105100
.WithSummary("Create or replace a catalog item")
106101
.WithDescription("Create or replace a catalog item")
107102
.WithTags("Items");
@@ -325,12 +320,12 @@ public static async Task<Results<Created, BadRequest<ProblemDetails>, NotFound<P
325320
[AsParameters] CatalogServices services,
326321
CatalogItem productToUpdate)
327322
{
328-
var catalogItem = await services.Context.CatalogItems.SingleOrDefaultAsync(i => i.Id == productToUpdate.Id);
323+
var catalogItem = await services.Context.CatalogItems.SingleOrDefaultAsync(i => i.Id == id);
329324

330325
if (catalogItem == null)
331326
{
332327
return TypedResults.NotFound<ProblemDetails>(new (){
333-
Detail = $"Item with id {productToUpdate.Id} not found."
328+
Detail = $"Item with id {id} not found."
334329
});
335330
}
336331

@@ -357,7 +352,7 @@ public static async Task<Results<Created, BadRequest<ProblemDetails>, NotFound<P
357352
{
358353
await services.Context.SaveChangesAsync();
359354
}
360-
return TypedResults.Created($"/api/catalog/items/{productToUpdate.Id}");
355+
return TypedResults.Created($"/api/catalog/items/{id}");
361356
}
362357

363358
[ProducesResponseType<ProblemDetails>(StatusCodes.Status400BadRequest, "application/problem+json")]

src/Catalog.API/Catalog.API.json

+3
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@
407407
],
408408
"summary": "List catalog items",
409409
"description": "Get a paginated list of items in the catalog.",
410+
"operationId": "ListItems",
410411
"parameters": [
411412
{
412413
"name": "PageSize",
@@ -468,6 +469,7 @@
468469
],
469470
"summary": "Create or replace a catalog item",
470471
"description": "Create or replace a catalog item",
472+
"operationId": "UpdateItem",
471473
"parameters": [
472474
{
473475
"name": "api-version",
@@ -597,6 +599,7 @@
597599
],
598600
"summary": "Search catalog for relevant items",
599601
"description": "Search the catalog for items related to the specified text",
602+
"operationId": "GetRelevantItems",
600603
"parameters": [
601604
{
602605
"name": "PageSize",

src/Catalog.API/Catalog.API_v2.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
],
166166
"summary": "Create or replace a catalog item",
167167
"description": "Create or replace a catalog item",
168-
"operationId": "UpdateItem",
168+
"operationId": "UpdateItem-V2",
169169
"parameters": [
170170
{
171171
"name": "id",
@@ -471,7 +471,7 @@
471471
],
472472
"summary": "List catalog items",
473473
"description": "Get a paginated list of items in the catalog.",
474-
"operationId": "ListItems",
474+
"operationId": "ListItems-V2",
475475
"parameters": [
476476
{
477477
"name": "PageSize",
@@ -561,7 +561,7 @@
561561
],
562562
"summary": "Search catalog for relevant items",
563563
"description": "Search the catalog for items related to the specified text",
564-
"operationId": "GetRelevantItems",
564+
"operationId": "GetRelevantItems-V2",
565565
"parameters": [
566566
{
567567
"name": "PageSize",

0 commit comments

Comments
 (0)