Skip to content

Commit 5cb5f31

Browse files
committed
Define responses
1 parent ffdf877 commit 5cb5f31

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

App/Api/Setup/ApiEndpoints.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Net;
12
using Asp.Versioning;
23
using Services;
34

@@ -36,6 +37,11 @@ public static void ConfigureEndpoints(this WebApplication app)
3637
return Results.Problem(statusCode: (int?)ex.StatusCode);
3738
}
3839
})
40+
.Produces<LongestDownwardTrendResponse>((int)HttpStatusCode.OK)
41+
.Produces((int)HttpStatusCode.NotFound)
42+
.Produces((int)HttpStatusCode.BadRequest)
43+
.ProducesProblem((int)HttpStatusCode.TooManyRequests)
44+
.ProducesProblem((int)HttpStatusCode.InternalServerError)
3945
.WithDescription("Get longest downward trend in days between given dates");
4046

4147
group.MapGet("/highestradingvolume",
@@ -59,6 +65,11 @@ public static void ConfigureEndpoints(this WebApplication app)
5965
return Results.Problem(statusCode: (int?)ex.StatusCode);
6066
}
6167
})
68+
.Produces<HighestTradingVolumeResponse>((int)HttpStatusCode.OK)
69+
.Produces((int)HttpStatusCode.NotFound)
70+
.Produces((int)HttpStatusCode.BadRequest)
71+
.ProducesProblem((int)HttpStatusCode.TooManyRequests)
72+
.ProducesProblem((int)HttpStatusCode.InternalServerError)
6273
.WithDescription("Get the date with the highest trading volume between given dates");
6374

6475
group.MapGet("/buyandsell",
@@ -82,6 +93,11 @@ public static void ConfigureEndpoints(this WebApplication app)
8293
return Results.Problem(statusCode: (int?)ex.StatusCode);
8394
}
8495
})
96+
.Produces<BuyAndSellResponse>((int)HttpStatusCode.OK)
97+
.Produces((int)HttpStatusCode.NotFound)
98+
.Produces((int)HttpStatusCode.BadRequest)
99+
.ProducesProblem((int)HttpStatusCode.TooManyRequests)
100+
.ProducesProblem((int)HttpStatusCode.InternalServerError)
85101
.WithDescription("Get pair of dates when it is best to buy and sell between given dates");
86102
}
87103

0 commit comments

Comments
 (0)