Skip to content

Commit f0e828d

Browse files
authored
Merge pull request #22 from IgniteUI/cpi/enrich-swagger-metadata
Enrich swagger metadata
2 parents aa2334a + 14de7f8 commit f0e828d

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,45 @@
11
namespace NorthwindCRUD.Models.Dtos
22
{
33
using NorthwindCRUD.Models.Contracts;
4+
using Swashbuckle.AspNetCore.Annotations;
45
using System.ComponentModel.DataAnnotations;
56

67
public class EmployeeDto : IEmployee
78
{
9+
[SwaggerSchema("Number automatically assigned to new employee.")]
10+
[MinLength(8)] // Min length comes from IdGenerator.CreateDigitsId
11+
[Required]
812
public int EmployeeId { get; set; }
913

14+
[SwaggerSchema("Employee's last name.")]
1015
public string LastName { get; set; }
1116

17+
[SwaggerSchema("Employee's first name.")]
1218
public string FirstName { get; set; }
1319

20+
[SwaggerSchema("Employee's title")]
1421
public string Title { get; set; }
1522

23+
[SwaggerSchema("Title used in salutations")]
1624
public string TitleOfCourtesy { get; set; }
1725

26+
[SwaggerSchema("Employee's birth date", Format = "date")]
1827
public string BirthDate { get; set; }
1928

29+
[SwaggerSchema("Employee's hire date", Format = "date")]
2030
public string HireDate { get; set; }
2131

2232
public string AddressId { get; set; }
2333

2434
public AddressDto Address { get; set; }
25-
35+
36+
[SwaggerSchema("General information about employee's background.")]
2637
public string Notes { get; set; }
2738

39+
[SwaggerSchema("Employee's avatar url.", Format = "uri")]
2840
public string AvatarUrl { get; set; }
2941

42+
[SwaggerSchema("Employee's supervisor.")]
3043
public int ReportsTo { get; set; }
3144
}
3245
}

NorthwindCRUD/NorthwindCRUD.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.10" />
2828
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
2929
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
30+
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
3031
</ItemGroup>
3132

3233
</Project>

NorthwindCRUD/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
});
4242

4343
option.OperationFilter<AuthResponsesOperationFilter>();
44+
option.EnableAnnotations();
4445
});
4546

4647
builder.Services.AddCors(options =>

0 commit comments

Comments
 (0)