Skip to content

Commit dee63a0

Browse files
committed
Adding two more custom swagger attributes
1 parent 1e7535e commit dee63a0

11 files changed

+45
-29
lines changed

NorthwindCRUD/Attributes/SwaggerParameterAttributes.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,20 @@ public SwaggerOrderByParameterAttribute()
2525
{
2626
}
2727
}
28+
29+
public class SwaggerSkipParameterAttribute : SwaggerParameterAttribute
30+
{
31+
public SwaggerSkipParameterAttribute()
32+
: base("The number of records to skip before starting to fetch them. If this parameter is not provided, fetching starts from the beginning.")
33+
{
34+
}
35+
}
36+
37+
public class SwaggerTopParameterAttribute : SwaggerParameterAttribute
38+
{
39+
public SwaggerTopParameterAttribute()
40+
: base("The maximum number of records to fetch. If this parameter is not provided, all records are fetched.")
41+
{
42+
}
43+
}
2844
}

NorthwindCRUD/Controllers/CategoriesController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public ActionResult<CategoryDto[]> GetAll()
5151
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5252
[HttpGet("GetCategoriesWithSkip")]
5353
public ActionResult<PagedResultDto<CategoryDto>> GetCategoriesWithSkip(
54-
[FromQuery][SwaggerParameter("The number of records to skip before starting to fetch them. If this parameter is not provided, fetching starts from the beginning.")] int? skip,
55-
[FromQuery][SwaggerParameter("The maximum number of records to fetch. If this parameter is not provided, all records are fetched.")] int? top,
56-
[FromQuery][SwaggerParameter("A comma-separated list of fields to order the records by, along with the sort direction (e.g., 'field1 asc, field2 desc').")] string? orderBy)
54+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
55+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
56+
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5757
{
5858
try
5959
{

NorthwindCRUD/Controllers/CustomersController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public ActionResult<CustomerDto[]> GetAll()
5151
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5252
[HttpGet("GetCustomersWithSkip")]
5353
public ActionResult<PagedResultDto<CustomerDto>> GetCustomersWithSkip(
54-
[FromQuery][SwaggerParameter("The number of records to skip before starting to fetch them. If this parameter is not provided, fetching starts from the beginning.")] int? skip,
55-
[FromQuery][SwaggerParameter("The maximum number of records to fetch. If this parameter is not provided, all records are fetched.")] int? top,
56-
[FromQuery][SwaggerParameter("A comma-separated list of fields to order the records by, along with the sort direction (e.g., 'field1 asc, field2 desc').")] string? orderBy)
54+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
55+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
56+
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5757
{
5858
try
5959
{

NorthwindCRUD/Controllers/EmployeesController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public ActionResult<EmployeeDto[]> GetAll()
5353
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5454
[HttpGet("GetEmployeesWithSkip")]
5555
public ActionResult<PagedResultDto<EmployeeDto>> GetPagedEmployees(
56-
[FromQuery][SwaggerParameter("The number of records to skip before starting to fetch the employees. If this parameter is not provided, fetching starts from the beginning.")] int? skip,
57-
[FromQuery][SwaggerParameter("The maximum number of employees to fetch. If this parameter is not provided, all employees are fetched.")] int? top,
58-
[FromQuery][SwaggerParameter("A comma-separated list of fields to order the employees by, along with the sort direction (e.g., 'field1 asc, field2 desc').")] string? orderBy)
56+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
57+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
58+
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5959
{
6060
try
6161
{

NorthwindCRUD/Controllers/OrdersController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ public ActionResult<OrderDto[]> GetAll()
5858
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5959
[HttpGet("GetPagedOrders")]
6060
public ActionResult<PagedResultDto<OrderDto>> GetAllOrders(
61-
[FromQuery][SwaggerParameter("The number of records to skip before starting to fetch the orders. If this parameter is not provided, fetching starts from the beginning.")] int? skip,
62-
[FromQuery][SwaggerParameter("The maximum number of orders to fetch. If this parameter is not provided, all orders are fetched.")] int? top,
63-
[FromQuery][SwaggerParameter("A comma-separated list of fields to order the orders by, along with the sort direction (e.g., 'field1 asc, field2 desc').")] string? orderBy)
61+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
62+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
63+
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
6464
{
6565
try
6666
{

NorthwindCRUD/Controllers/ProductsController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public ActionResult<ProductDto[]> GetAll()
5757
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5858
[HttpGet("GetPagedProducts")]
5959
public ActionResult<PagedResultDto<ProductDto>> GetAllProducts(
60-
[FromQuery][SwaggerParameter("The number of records to skip before starting to fetch the products. If this parameter is not provided, fetching starts from the beginning.")] int? skip,
61-
[FromQuery][SwaggerParameter("The maximum number of products to fetch. If this parameter is not provided, all products are fetched.")] int? top,
62-
[FromQuery][SwaggerParameter("A comma-separated list of fields to order the products by, along with the sort direction (e.g., 'field1 asc, field2 desc').")] string? orderBy)
60+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
61+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
62+
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
6363
{
6464
try
6565
{

NorthwindCRUD/Controllers/RegionsController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public ActionResult<RegionDto[]> GetAll()
5252
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5353
[HttpGet("GetPagedRegions")]
5454
public ActionResult<PagedResultDto<RegionDto>> GetAllRegions(
55-
[FromQuery][SwaggerParameter("The number of records to skip before starting to fetch the regions. If this parameter is not provided, fetching starts from the beginning.")] int? skip,
56-
[FromQuery][SwaggerParameter("The maximum number of regions to fetch. If this parameter is not provided, all regions are fetched.")] int? top,
57-
[FromQuery][SwaggerParameter("A comma-separated list of fields to order the regions by, along with the sort direction (e.g., 'field1 asc, field2 desc').")] string? orderBy)
55+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
56+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
57+
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5858
{
5959
try
6060
{

NorthwindCRUD/Controllers/ShippersController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public ActionResult<ShipperDto[]> GetAll()
5252
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5353
[HttpGet("GetPagedShippersWithSkip")]
5454
public ActionResult<PagedResultDto<ShipperDto>> GetPagedShippersWithSkip(
55-
[FromQuery][SwaggerParameter("The number of records to skip before starting to fetch the shippers. If this parameter is not provided, fetching starts from the beginning.")] int? skip,
56-
[FromQuery][SwaggerParameter("The maximum number of shippers to fetch. If this parameter is not provided, all shippers are fetched.")] int? top,
57-
[FromQuery][SwaggerParameter("A comma-separated list of fields to order the shippers by, along with the sort direction (e.g., 'field1 asc, field2 desc').")] string? orderBy)
55+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
56+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
57+
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5858
{
5959
try
6060
{
@@ -92,7 +92,7 @@ public ActionResult<PagedResultDto<ShipperDto>> GetPagedShippersWithPage(
9292
var shippers = this.shipperService.GetAllAsQueryable();
9393

9494
// Get paged data
95-
var pagedResult = pagingService.FetchPagedData<RegionDb, RegionDto>(shippers, null, null, pageIndex, size, orderBy);
95+
var pagedResult = pagingService.FetchPagedData<ShipperDb, ShipperDto>(shippers, null, null, pageIndex, size, orderBy);
9696

9797
return Ok(pagedResult);
9898
}

NorthwindCRUD/Controllers/SuppliersController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public ActionResult<SupplierDto[]> GetAll()
5252
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5353
[HttpGet("GetPagedSuppliers")]
5454
public ActionResult<PagedResultDto<SupplierDto>> GetAllSuppliers(
55-
[FromQuery][SwaggerParameter("The number of records to skip before starting to fetch the suppliers. If this parameter is not provided, fetching starts from the beginning.")] int? skip,
56-
[FromQuery][SwaggerParameter("The maximum number of suppliers to fetch. If this parameter is not provided, all suppliers are fetched.")] int? top,
57-
[FromQuery][SwaggerParameter("A comma-separated list of fields to order the suppliers by, along with the sort direction (e.g., 'field1 asc, field2 desc').")] string? orderBy)
55+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
56+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
57+
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5858
{
5959
try
6060
{

NorthwindCRUD/Controllers/TerritoriesController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public ActionResult<TerritoryDto[]> GetAll()
5454
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5555
[HttpGet("GetPagedTerritories")]
5656
public ActionResult<PagedResultDto<TerritoryDto>> GetAllTerritories(
57-
[FromQuery][SwaggerParameter("The number of records to skip before starting to fetch the territories. If this parameter is not provided, fetching starts from the beginning.")] int? skip,
58-
[FromQuery][SwaggerParameter("The maximum number of territories to fetch. If this parameter is not provided, all territories are fetched.")] int? top,
59-
[FromQuery][SwaggerParameter("A comma-separated list of fields to order the territories by, along with the sort direction (e.g., 'field1 asc, field2 desc').")] string? orderBy)
57+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
58+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
59+
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
6060
{
6161
try
6262
{

0 commit comments

Comments
 (0)