Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal api changes #1986

Merged
merged 7 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ internal async Task AddEndpointsMethod(string membersBlockText, string endpoints
if (templateModel.OpenAPI)
{
usings.Add("Microsoft.AspNetCore.Http.HttpResults");
deepchoudhery marked this conversation as resolved.
Show resolved Hide resolved
usings.Add("Microsoft.AspNetCore.OpenApi");
}
deepchoudhery marked this conversation as resolved.
Show resolved Hide resolved

var endpointsCodeFile = new CodeFile { Usings = usings.ToArray()};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public HashSet<string> RequiredNamespaces
if (OpenAPI)
{
requiredNamespaces.Add("Microsoft.AspNetCore.Http.HttpResults");
requiredNamespaces.Add("Microsoft.AspNetCore.OpenApi");
}

// Finally we remove the ControllerNamespace as it's not required.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public static class @endPointsClassName
public static void @Model.MethodName (this IEndpointRouteBuilder routes)
{
var group = routes.MapGroup("@routePrefix");
@{
if(Model.OpenAPI)
{
@:group.WithOpenApi();
}
}
group.MapGet("/", () =>
{
return new [] { new @modelConstructor };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public static class @endPointsClassName
public static void @Model.MethodName (this IEndpointRouteBuilder routes)
{
var group = routes.MapGroup("@routePrefix");
@{
if(Model.OpenAPI)
{
@:group.WithOpenApi();
}
}
group.MapGet("/", async (@dbContextName db) =>
{
return await db.@modelToList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
public static void @Model.MethodName (this IEndpointRouteBuilder routes)
{
var group = routes.MapGroup("@routePrefix");
@{
if(Model.OpenAPI)
{
@:group.WithOpenApi();
}
}
group.MapGet("/", async (@dbContextName db) =>
{
return await db.@modelToList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
public static void @Model.MethodName (this IEndpointRouteBuilder routes)
{
var group = routes.MapGroup("@routePrefix");
@{
if(Model.OpenAPI)
{
@:group.WithOpenApi();
}
}
group.MapGet("/", () =>
{
return new [] { new @modelConstructor };
Expand Down