Skip to content

Commit 9aad9c1

Browse files
authored
Add files via upload
1 parent ea58d59 commit 9aad9c1

7 files changed

+178
-0
lines changed

AspDotNetCoreWebAPISwaggerUI.csproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<UserSecretsId>aspnet-AspDotNetCoreWebAPI-BD2B6DA2-5332-46A5-8BDE-72EA765A0976</UserSecretsId>
6+
</PropertyGroup>
7+
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.1" />
11+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.1" />
12+
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.1" />
13+
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
14+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.1" />
15+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.1" />
16+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
17+
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
5+
<Controller_SelectedScaffolderCategoryPath>root/Controller</Controller_SelectedScaffolderCategoryPath>
6+
<WebStackScaffolding_ControllerDialogWidth>600</WebStackScaffolding_ControllerDialogWidth>
7+
<WebStackScaffolding_IsLayoutPageSelected>True</WebStackScaffolding_IsLayoutPageSelected>
8+
<WebStackScaffolding_IsPartialViewSelected>False</WebStackScaffolding_IsPartialViewSelected>
9+
<WebStackScaffolding_IsReferencingScriptLibrariesSelected>True</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
10+
<WebStackScaffolding_LayoutPageFile />
11+
<WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
12+
<ActiveDebugProfile>AspDotNetCoreWebAPI</ActiveDebugProfile>
13+
</PropertyGroup>
14+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
15+
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
16+
</PropertyGroup>
17+
</Project>

AspDotNetCoreWebAPISwaggerUI.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29709.97
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspDotNetCoreWebAPISwaggerUI", "AspDotNetCoreWebAPISwaggerUI.csproj", "{4B983B8F-612F-47D0-97DC-CAD324DAF500}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{4B983B8F-612F-47D0-97DC-CAD324DAF500}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{4B983B8F-612F-47D0-97DC-CAD324DAF500}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{4B983B8F-612F-47D0-97DC-CAD324DAF500}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{4B983B8F-612F-47D0-97DC-CAD324DAF500}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {94D72D66-C5D9-409C-BAD6-E34ED0B1C88E}
24+
EndGlobalSection
25+
EndGlobal

Program.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Hosting;
6+
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.Hosting;
8+
using Microsoft.Extensions.Logging;
9+
10+
namespace AspDotNetCoreWebAPI
11+
{
12+
public class Program
13+
{
14+
public static void Main(string[] args)
15+
{
16+
CreateHostBuilder(args).Build().Run();
17+
}
18+
19+
public static IHostBuilder CreateHostBuilder(string[] args) =>
20+
Host.CreateDefaultBuilder(args)
21+
.ConfigureWebHostDefaults(webBuilder =>
22+
{
23+
webBuilder.UseStartup<Startup>();
24+
});
25+
}
26+
}

Startup.cs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System;
2+
using System.Linq;
3+
using Microsoft.AspNetCore.Builder;
4+
using Microsoft.AspNetCore.Hosting;
5+
using Microsoft.Extensions.Configuration;
6+
using Microsoft.Extensions.DependencyInjection;
7+
using Microsoft.Extensions.Hosting;
8+
using AspDotNetCoreWebAPI.Config;
9+
using AspDotNetCoreWebAPISwaggerUI;
10+
using AspDotNetCoreWebAPISwaggerUI.ServiceRegistration;
11+
12+
namespace AspDotNetCoreWebAPI
13+
{
14+
public class Startup
15+
{
16+
public Startup(IConfiguration configuration)
17+
{
18+
Configuration = configuration;
19+
}
20+
21+
public IConfiguration Configuration { get; }
22+
23+
// This method gets called by the runtime. Use this method to add services to the container.
24+
public void ConfigureServices(IServiceCollection services)
25+
{
26+
services.RegistrarServicesInAssembly(Configuration);
27+
}
28+
29+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
30+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
31+
{
32+
if (env.IsDevelopment())
33+
{
34+
app.UseDeveloperExceptionPage();
35+
}
36+
else
37+
{
38+
app.UseHsts();
39+
}
40+
41+
var swaggerOptions = new SwaggerOptions();
42+
Configuration.GetSection(nameof(SwaggerOptions)).Bind(swaggerOptions);
43+
app.UseSwagger(options => { options.RouteTemplate = swaggerOptions.JsonRoute; });
44+
app.UseSwaggerUI(options => options.SwaggerEndpoint(swaggerOptions.UIEndPoint, swaggerOptions.Description));
45+
46+
app.UseHttpsRedirection();
47+
app.UseStaticFiles();
48+
49+
app.UseRouting();
50+
51+
app.UseEndpoints(endpoints =>
52+
{
53+
//endpoints.MapControllers();
54+
endpoints.MapControllerRoute(
55+
name: "default",
56+
pattern: "{controller=Home}/{action=Index}/{id?}");
57+
endpoints.MapRazorPages();
58+
});
59+
}
60+
}
61+
}

appsettings.Development.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
7+
}
8+
}
9+
}

appsettings.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"ConnectionStrings": {
3+
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-AspDotNetCoreWebAPI-BD2B6DA2-5332-46A5-8BDE-72EA765A0976;Trusted_Connection=True;MultipleActiveResultSets=true"
4+
},
5+
6+
"SwaggerOptions": {
7+
"JsonRoute": "/swagger/{documentName}/swagger.json",
8+
"Description": "ASP.NET Core WebAPI Example",
9+
"UIEndPoint": "v1/swagger.json"
10+
},
11+
12+
"Logging": {
13+
"LogLevel": {
14+
"Default": "Information",
15+
"Microsoft": "Warning",
16+
"Microsoft.Hosting.Lifetime": "Information"
17+
}
18+
},
19+
"AllowedHosts": "*"
20+
}

0 commit comments

Comments
 (0)