Skip to content

Commit ce9aa77

Browse files
committed
corrected api route for some minimal api scenarios (#2403)
1 parent bd609eb commit ce9aa77

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Scaffolding/VS.Web.CG.Mvc/Templates/MinimalApi/MinimalApi.cshtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
string endPointsClassName = Model.EndpointsName;
88
string methodName = $"Map{@modelName}Endpoints";
99
string pluralModel = Model.ModelType.PluralName;
10+
string routePrefixPlural = "/api/" + pluralModel;
1011
string getAllModels = $"GetAll{@pluralModel}";
1112
string getModelById = $"Get{@modelName}ById";
1213
string deleteModel = $"Delete{@modelName}";
@@ -94,11 +95,11 @@ public static class @endPointsClassName
9495
@{
9596
if(!Model.UseTypedResults)
9697
{
97-
@://return Results.Created($"/@pluralModel/{model.ID}", model);
98+
@://return Results.Created($"@routePrefixPlural/{model.ID}", model);
9899
}
99100
else
100101
{
101-
@://return TypedResults.Created($"/@pluralModel/{model.ID}", model);
102+
@://return TypedResults.Created($"@routePrefixPlural/{model.ID}", model);
102103
}
103104
}
104105
})

src/Scaffolding/VS.Web.CG.Mvc/Templates/MinimalApi/MinimalApiNoClass.cshtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
string endPointsClassName = Model.EndpointsName;
88
string methodName = $"Map{@modelName}Endpoints";
99
string pluralModel = Model.ModelType.PluralName;
10+
string routePrefixPlural = "/api/" + pluralModel;
1011
string getAllModels = $"GetAll{@pluralModel}";
1112
string getModelById = $"Get{@modelName}ById";
1213
string deleteModel = $"Delete{@modelName}";
@@ -85,11 +86,11 @@
8586
@{
8687
if(!Model.UseTypedResults)
8788
{
88-
@://return Results.Created($"/@pluralModel/{model.ID}", model);
89+
@://return Results.Created($"@routePrefixPlural/{model.ID}", model);
8990
}
9091
else
9192
{
92-
@://return TypedResults.Created($"/@pluralModel/{model.ID}", model);
93+
@://return TypedResults.Created($"@routePrefixPlural/{model.ID}", model);
9394
}
9495
}
9596
})

0 commit comments

Comments
 (0)