@@ -12,24 +12,19 @@ public static class CatalogApi
12
12
public static IEndpointRouteBuilder MapCatalogApi ( this IEndpointRouteBuilder app )
13
13
{
14
14
// 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
-
20
15
var vApi = app . NewVersionedApi ( "Catalog" ) ;
21
16
var api = vApi . MapGroup ( "api/catalog" ) . HasApiVersion ( 1 , 0 ) . HasApiVersion ( 2 , 0 ) ;
22
17
var v1 = vApi . MapGroup ( "api/catalog" ) . HasApiVersion ( 1 , 0 ) ;
23
18
var v2 = vApi . MapGroup ( "api/catalog" ) . HasApiVersion ( 2 , 0 ) ;
24
19
25
20
// Routes for querying catalog items.
26
21
v1 . MapGet ( "/items" , GetAllItemsV1 )
27
- // .WithName("ListItems")
22
+ . WithName ( "ListItems" )
28
23
. WithSummary ( "List catalog items" )
29
24
. WithDescription ( "Get a paginated list of items in the catalog." )
30
25
. WithTags ( "Items" ) ;
31
26
v2 . MapGet ( "/items" , GetAllItems )
32
- . WithName ( "ListItems" )
27
+ . WithName ( "ListItems-V2 " )
33
28
. WithSummary ( "List catalog items" )
34
29
. WithDescription ( "Get a paginated list of items in the catalog." )
35
30
. WithTags ( "Items" ) ;
@@ -56,14 +51,14 @@ public static IEndpointRouteBuilder MapCatalogApi(this IEndpointRouteBuilder app
56
51
57
52
// Routes for resolving catalog items using AI.
58
53
v1 . MapGet ( "/items/withsemanticrelevance/{text:minlength(1)}" , GetItemsBySemanticRelevanceV1 )
59
- // .WithName("GetRelevantItems")
54
+ . WithName ( "GetRelevantItems" )
60
55
. WithSummary ( "Search catalog for relevant items" )
61
56
. WithDescription ( "Search the catalog for items related to the specified text" )
62
57
. WithTags ( "Search" ) ;
63
58
64
59
// Routes for resolving catalog items using AI.
65
60
v2 . MapGet ( "/items/withsemanticrelevance" , GetItemsBySemanticRelevance )
66
- . WithName ( "GetRelevantItems" )
61
+ . WithName ( "GetRelevantItems-V2 " )
67
62
. WithSummary ( "Search catalog for relevant items" )
68
63
. WithDescription ( "Search the catalog for items related to the specified text" )
69
64
. WithTags ( "Search" ) ;
@@ -96,12 +91,12 @@ public static IEndpointRouteBuilder MapCatalogApi(this IEndpointRouteBuilder app
96
91
97
92
// Routes for modifying catalog items.
98
93
v1 . MapPut ( "/items" , UpdateItemV1 )
99
- // .WithName("UpdateItem")
94
+ . WithName ( "UpdateItem" )
100
95
. WithSummary ( "Create or replace a catalog item" )
101
96
. WithDescription ( "Create or replace a catalog item" )
102
97
. WithTags ( "Items" ) ;
103
98
v2 . MapPut ( "/items/{id:int}" , UpdateItem )
104
- . WithName ( "UpdateItem" )
99
+ . WithName ( "UpdateItem-V2 " )
105
100
. WithSummary ( "Create or replace a catalog item" )
106
101
. WithDescription ( "Create or replace a catalog item" )
107
102
. WithTags ( "Items" ) ;
@@ -325,12 +320,12 @@ public static async Task<Results<Created, BadRequest<ProblemDetails>, NotFound<P
325
320
[ AsParameters ] CatalogServices services ,
326
321
CatalogItem productToUpdate )
327
322
{
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 ) ;
329
324
330
325
if ( catalogItem == null )
331
326
{
332
327
return TypedResults . NotFound < ProblemDetails > ( new ( ) {
333
- Detail = $ "Item with id { productToUpdate . Id } not found."
328
+ Detail = $ "Item with id { id } not found."
334
329
} ) ;
335
330
}
336
331
@@ -357,7 +352,7 @@ public static async Task<Results<Created, BadRequest<ProblemDetails>, NotFound<P
357
352
{
358
353
await services . Context . SaveChangesAsync ( ) ;
359
354
}
360
- return TypedResults . Created ( $ "/api/catalog/items/{ productToUpdate . Id } ") ;
355
+ return TypedResults . Created ( $ "/api/catalog/items/{ id } ") ;
361
356
}
362
357
363
358
[ ProducesResponseType < ProblemDetails > ( StatusCodes . Status400BadRequest , "application/problem+json" ) ]
0 commit comments