Skip to content

Commit 74744d7

Browse files
committed
apply chnages
1 parent 57e9ba4 commit 74744d7

File tree

7 files changed

+17
-16
lines changed

7 files changed

+17
-16
lines changed

NorthwindCRUD/Controllers/ProductsController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace NorthwindCRUD.Controllers
22
{
3+
using System.ComponentModel.DataAnnotations;
34
using AutoMapper;
45
using Microsoft.AspNetCore.Authorization;
56
using Microsoft.AspNetCore.Mvc;
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.OpenApi.Any;
1+
using Microsoft.OpenApi.Any;
22
using Microsoft.OpenApi.Models;
33
using Swashbuckle.AspNetCore.SwaggerGen;
44

@@ -10,12 +10,13 @@ public void Apply(OpenApiSchema schema, SchemaFilterContext context)
1010
{
1111
if (context.Type.IsEnum)
1212
{
13-
schema.Type = "string";
14-
schema.Enum = context.Type
15-
.GetEnumNames()
16-
.Select(name => new OpenApiString(name))
13+
var enumValues = Enum.GetValues(context.Type)
14+
.Cast<object>()
15+
.Select(e => new OpenApiString(e.ToString()))
1716
.ToList<IOpenApiAny>();
17+
18+
schema.Enum = enumValues;
1819
}
1920
}
2021
}
21-
}
22+
}

NorthwindCRUD/Models/Contracts/IOrder.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ public interface IOrder
1111

1212
int EmployeeId { get; set; }
1313

14-
Shipping? ShipperId { get; set; }
14+
int? ShipperId { get; set; }
1515

1616
string OrderDate { get; set; }
1717

1818
string RequiredDate { get; set; }
1919

20-
Shipping? ShipVia { get; set; }
2120
Shipping? ShipVia { get; set; }
2221

2322
double Freight { get; set; }

NorthwindCRUD/Models/Dtos/AddressDto.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.ComponentModel.DataAnnotations;
1+
using System.ComponentModel.DataAnnotations;
22
using NorthwindCRUD.Models.Contracts;
33

44
namespace NorthwindCRUD.Models.Dtos
@@ -24,4 +24,4 @@ public class AddressDto : IAddress
2424
[RegularExpression(@"^\+?[1-9]\d{1,14}$", ErrorMessage = "Phone number is not valid.")]
2525
public string? Phone { get; set; }
2626
}
27-
}
27+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.ComponentModel.DataAnnotations;
1+
using System.ComponentModel.DataAnnotations;
22
using NorthwindCRUD.Models.Contracts;
33

44
namespace NorthwindCRUD.Models.Dtos
@@ -8,4 +8,4 @@ public class CategoryDetailsDto : CategoryDto, ICategoryDetail
88
[RegularExpression(@"^(http[s]?://.*\.(?:jpg|jpeg|png|gif))$", ErrorMessage = "Picture URL must start with http/s and end with .jpg, .jpeg, .png, or .gif.")]
99
public string Picture { get; set; }
1010
}
11-
}
11+
}

NorthwindCRUD/Models/Dtos/CategoryDto.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.ComponentModel.DataAnnotations;
1+
using System.ComponentModel.DataAnnotations;
22
using NorthwindCRUD.Models.Contracts;
33

44
namespace NorthwindCRUD.Models.Dtos
@@ -14,4 +14,4 @@ public class CategoryDto : ICategory
1414
[StringLength(50, MinimumLength = 3, ErrorMessage = "Name must be between 3 and 50 characters.")]
1515
public string Name { get; set; }
1616
}
17-
}
17+
}

NorthwindCRUD/Models/Dtos/OrderDetailDto.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.ComponentModel.DataAnnotations;
1+
using System.ComponentModel.DataAnnotations;
22

33
namespace NorthwindCRUD.Models.Dtos
44
{
@@ -17,4 +17,4 @@ public class OrderDetailDto
1717

1818
public float Discount { get; set; }
1919
}
20-
}
20+
}

0 commit comments

Comments
 (0)