From 892f248acf7aeb827aa7b9488da4568c0db59ff3 Mon Sep 17 00:00:00 2001 From: Deep Choudhery <54324771+deepchoudhery@users.noreply.github.com> Date: Thu, 11 May 2023 14:23:33 -0700 Subject: [PATCH] corrected api route for some minimal api scenarios (#2403) --- .../VS.Web.CG.Mvc/Templates/MinimalApi/MinimalApi.cshtml | 5 +++-- .../Templates/MinimalApi/MinimalApiNoClass.cshtml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Scaffolding/VS.Web.CG.Mvc/Templates/MinimalApi/MinimalApi.cshtml b/src/Scaffolding/VS.Web.CG.Mvc/Templates/MinimalApi/MinimalApi.cshtml index 828c2c89e..32383ccd4 100644 --- a/src/Scaffolding/VS.Web.CG.Mvc/Templates/MinimalApi/MinimalApi.cshtml +++ b/src/Scaffolding/VS.Web.CG.Mvc/Templates/MinimalApi/MinimalApi.cshtml @@ -7,6 +7,7 @@ string endPointsClassName = Model.EndpointsName; string methodName = $"Map{@modelName}Endpoints"; string pluralModel = Model.ModelType.PluralName; + string routePrefixPlural = "/api/" + pluralModel; string getAllModels = $"GetAll{@pluralModel}"; string getModelById = $"Get{@modelName}ById"; string deleteModel = $"Delete{@modelName}"; @@ -94,11 +95,11 @@ public static class @endPointsClassName @{ if(!Model.UseTypedResults) { - @://return Results.Created($"/@pluralModel/{model.ID}", model); + @://return Results.Created($"@routePrefixPlural/{model.ID}", model); } else { - @://return TypedResults.Created($"/@pluralModel/{model.ID}", model); + @://return TypedResults.Created($"@routePrefixPlural/{model.ID}", model); } } }) diff --git a/src/Scaffolding/VS.Web.CG.Mvc/Templates/MinimalApi/MinimalApiNoClass.cshtml b/src/Scaffolding/VS.Web.CG.Mvc/Templates/MinimalApi/MinimalApiNoClass.cshtml index bb2cd5d28..daaced82c 100644 --- a/src/Scaffolding/VS.Web.CG.Mvc/Templates/MinimalApi/MinimalApiNoClass.cshtml +++ b/src/Scaffolding/VS.Web.CG.Mvc/Templates/MinimalApi/MinimalApiNoClass.cshtml @@ -7,6 +7,7 @@ string endPointsClassName = Model.EndpointsName; string methodName = $"Map{@modelName}Endpoints"; string pluralModel = Model.ModelType.PluralName; + string routePrefixPlural = "/api/" + pluralModel; string getAllModels = $"GetAll{@pluralModel}"; string getModelById = $"Get{@modelName}ById"; string deleteModel = $"Delete{@modelName}"; @@ -85,11 +86,11 @@ @{ if(!Model.UseTypedResults) { - @://return Results.Created($"/@pluralModel/{model.ID}", model); + @://return Results.Created($"@routePrefixPlural/{model.ID}", model); } else { - @://return TypedResults.Created($"/@pluralModel/{model.ID}", model); + @://return TypedResults.Created($"@routePrefixPlural/{model.ID}", model); } } })