Skip to content

Commit 2b609f8

Browse files
authored
Merge pull request #9 from Amitpnk/develop
Develop
2 parents 6d1f3d9 + 8fbeb7d commit 2b609f8

File tree

13 files changed

+77
-1
lines changed

13 files changed

+77
-1
lines changed

Assert/OnionArchitecture_icon.png

34.7 KB
Loading

Assert/Step1.png

36.4 KB
Loading

Assert/Step2.PNG

16.8 KB
Loading

Assert/Step3.PNG

24 KB
Loading

Assert/Step4.PNG

27.4 KB
Loading

OnionArchitecture/OnionArchitecture.Infrastructure/Extension/ConfigureContainer.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,17 @@ public static void ConfigureCustomExceptionMiddleware(this IApplicationBuilder a
99
{
1010
app.UseMiddleware<CustomExceptionMiddleware>();
1111
}
12+
13+
public static void ConfigureSwagger(this IApplicationBuilder app)
14+
{
15+
app.UseSwagger();
16+
17+
app.UseSwaggerUI(setupAction =>
18+
{
19+
setupAction.SwaggerEndpoint("/swagger/OpenAPISpecification/swagger.json", "Onion Architecture API");
20+
setupAction.RoutePrefix = string.Empty;
21+
});
22+
}
23+
1224
}
1325
}

OnionArchitecture/OnionArchitecture.Infrastructure/Extension/ConfigureServiceContainer.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
using OnionArchitecture.Persistence.Repository;
99
using OnionArchitecture.Service.Contract;
1010
using OnionArchitecture.Service.ImplementationBL;
11+
using System;
12+
using System.IO;
13+
using System.Reflection;
1114

1215
namespace OnionArchitecture.Infrastructure.Extension
1316
{
@@ -42,5 +45,36 @@ public static void AddTransientServices(this IServiceCollection serviceCollectio
4245
serviceCollection.AddTransient<ICustomerService, CustomerService>();
4346
}
4447

48+
public static void AddSwaggerOpenAPI(this IServiceCollection serviceCollection)
49+
{
50+
serviceCollection.AddSwaggerGen(setupAction =>
51+
{
52+
setupAction.SwaggerDoc(
53+
"OpenAPISpecification",
54+
new Microsoft.OpenApi.Models.OpenApiInfo()
55+
{
56+
Title = "Customer API",
57+
Version = "1",
58+
Description = "Through this API you can access customer details",
59+
Contact = new Microsoft.OpenApi.Models.OpenApiContact()
60+
{
61+
Email = "amit.naik8103@gmail.com",
62+
Name = "Amit Naik",
63+
Url = new Uri("https://amitpnk.github.io/")
64+
},
65+
License = new Microsoft.OpenApi.Models.OpenApiLicense()
66+
{
67+
Name = "MIT License",
68+
Url = new Uri("https://opensource.org/licenses/MIT")
69+
}
70+
});
71+
72+
var xmlCommentsFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
73+
var xmlCommentsFullPath = Path.Combine(AppContext.BaseDirectory, xmlCommentsFile);
74+
setupAction.IncludeXmlComments(xmlCommentsFullPath);
75+
});
76+
77+
}
78+
4579
}
4680
}

OnionArchitecture/OnionArchitecture.Infrastructure/OnionArchitecture.Infrastructure.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44
<TargetFramework>netcoreapp3.1</TargetFramework>
55
</PropertyGroup>
66

7+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
8+
<DocumentationFile>OnionArchitecture.Infrastructure.xml</DocumentationFile>
9+
<NoWarn>1701;1702;1591</NoWarn>
10+
</PropertyGroup>
11+
712
<ItemGroup>
813
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
914
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
1015
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.5" />
1116
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.5" />
1217
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
18+
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.0" />
1319
</ItemGroup>
1420

1521
<ItemGroup>

OnionArchitecture/OnionArchitecture.Infrastructure/OnionArchitecture.Infrastructure.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OnionArchitecture/OnionArchitecture/OnionArchitecture.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
<TargetFramework>netcoreapp3.1</TargetFramework>
55
</PropertyGroup>
66

7+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
8+
<DocumentationFile>OnionArchitectureSwagger.xml</DocumentationFile>
9+
<NoWarn>1701;1702;1591</NoWarn>
10+
</PropertyGroup>
11+
712
<ItemGroup>
813
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
914
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.5">

0 commit comments

Comments
 (0)