Skip to content

Commit 44f11b0

Browse files
authored
Revert "Validations new"
1 parent 093fb69 commit 44f11b0

24 files changed

+62
-165
lines changed

NorthwindCRUD/Controllers/CategoriesController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -51,8 +50,8 @@ public ActionResult<CategoryDto[]> GetAll()
5150
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5251
[HttpGet("GetCategoriesWithSkip")]
5352
public ActionResult<PagedResultDto<CategoryDto>> GetCategoriesWithSkip(
54-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
55-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
53+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
54+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
5655
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5756
{
5857
try

NorthwindCRUD/Controllers/CustomersController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -51,8 +50,8 @@ public ActionResult<CustomerDto[]> GetAll()
5150
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5251
[HttpGet("GetCustomersWithSkip")]
5352
public ActionResult<PagedResultDto<CustomerDto>> GetCustomersWithSkip(
54-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
55-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
53+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
54+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
5655
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5756
{
5857
try

NorthwindCRUD/Controllers/EmployeesController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -69,8 +68,8 @@ public ActionResult<OrderDto[]> GetAllAuthorized()
6968
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
7069
[HttpGet("GetEmployeesWithSkip")]
7170
public ActionResult<PagedResultDto<EmployeeDto>> GetPagedEmployees(
72-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
73-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
71+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
72+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
7473
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
7574
{
7675
try

NorthwindCRUD/Controllers/OrdersController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -57,8 +56,8 @@ public ActionResult<OrderDto[]> GetAll()
5756
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5857
[HttpGet("GetPagedOrders")]
5958
public ActionResult<PagedResultDto<OrderDto>> GetAllOrders(
60-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
61-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
59+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
60+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
6261
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
6362
{
6463
try

NorthwindCRUD/Controllers/ProductsController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -71,8 +70,8 @@ public ActionResult<OrderDto[]> GetAllAuthorized()
7170
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
7271
[HttpGet("GetPagedProducts")]
7372
public ActionResult<PagedResultDto<ProductDto>> GetAllProducts(
74-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
75-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
73+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
74+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
7675
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
7776
{
7877
try

NorthwindCRUD/Controllers/RegionsController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -51,8 +50,8 @@ public ActionResult<RegionDto[]> GetAll()
5150
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5251
[HttpGet("GetPagedRegions")]
5352
public ActionResult<PagedResultDto<RegionDto>> GetAllRegions(
54-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
55-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
53+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
54+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
5655
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5756
{
5857
try

NorthwindCRUD/Controllers/ShippersController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -51,8 +50,8 @@ public ActionResult<ShipperDto[]> GetAll()
5150
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5251
[HttpGet("GetPagedShippersWithSkip")]
5352
public ActionResult<PagedResultDto<ShipperDto>> GetPagedShippersWithSkip(
54-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
55-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
53+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
54+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
5655
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5756
{
5857
try

NorthwindCRUD/Controllers/SuppliersController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -51,8 +50,8 @@ public ActionResult<SupplierDto[]> GetAll()
5150
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5251
[HttpGet("GetPagedSuppliers")]
5352
public ActionResult<PagedResultDto<SupplierDto>> GetAllSuppliers(
54-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
55-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
53+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
54+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
5655
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5756
{
5857
try

NorthwindCRUD/Controllers/TerritoriesController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -53,8 +52,8 @@ public ActionResult<TerritoryDto[]> GetAll()
5352
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5453
[HttpGet("GetPagedTerritories")]
5554
public ActionResult<PagedResultDto<TerritoryDto>> GetAllTerritories(
56-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
57-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
55+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
56+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
5857
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5958
{
6059
try
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
using Microsoft.OpenApi.Any;
2-
using Microsoft.OpenApi.Models;
3-
using Swashbuckle.AspNetCore.SwaggerGen;
1+
using Microsoft.OpenApi.Any;
2+
using Microsoft.OpenApi.Models;
3+
using Swashbuckle.AspNetCore.SwaggerGen;
44

5-
namespace NorthwindCRUD.Filters
5+
namespace NorthwindCRUD.Filters
66
{
77
public class EnumSchemaFilter : ISchemaFilter
88
{
99
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
1010
{
1111
if (context.Type.IsEnum)
1212
{
13-
var enumValues = Enum.GetValues(context.Type)
14-
.Cast<object>()
15-
.Select(e => new OpenApiString(e.ToString()))
13+
schema.Type = "string";
14+
schema.Enum = context.Type
15+
.GetEnumNames()
16+
.Select(name => new OpenApiString(name))
1617
.ToList<IOpenApiAny>();
17-
18-
schema.Enum = enumValues;
1918
}
2019
}
2120
}
22-
}
21+
}

0 commit comments

Comments
 (0)