aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2021-03-03 18:35:12 +0200
committertranstrike <transtrike@gmail.com>2021-03-03 18:35:12 +0200
commitb9a9d63418d728560b17c23d49255328d16ccb11 (patch)
tree6e536e34d2118d9bdf8854dc3d12b493162ed0f3 /src
parent804d274223734ea1c67920622ceb453cca602fc9 (diff)
downloadDevHive-nswag.tar
DevHive-nswag.tar.gz
DevHive-nswag.zip
NSwag replaced Swagger; Doc prep configurednswag
Diffstat (limited to 'src')
-rw-r--r--src/Common/DevHive.Common.Models/DevHive.Common.Models.csproj2
-rw-r--r--src/Data/DevHive.Data.Models/DevHive.Data.Models.csproj2
-rw-r--r--src/Data/DevHive.Data.Tests/DevHive.Data.Tests.csproj2
-rw-r--r--src/Data/DevHive.Data/DevHive.Data.csproj2
-rw-r--r--src/Services/DevHive.Services.Models/DevHive.Services.Models.csproj10
-rw-r--r--src/Services/DevHive.Services.Tests/DevHive.Services.Tests.csproj20
-rw-r--r--src/Services/DevHive.Services/DevHive.Services.csproj22
-rw-r--r--src/Web/DevHive.Web.Models/DevHive.Web.Models.csproj10
-rw-r--r--src/Web/DevHive.Web.Tests/DevHive.Web.Tests.csproj18
-rw-r--r--src/Web/DevHive.Web/Configurations/Extensions/ConfigureSwagger.cs56
-rw-r--r--src/Web/DevHive.Web/DevHive.Web.csproj37
-rw-r--r--src/Web/DevHive.Web/Startup.cs2
12 files changed, 97 insertions, 86 deletions
diff --git a/src/Common/DevHive.Common.Models/DevHive.Common.Models.csproj b/src/Common/DevHive.Common.Models/DevHive.Common.Models.csproj
index f6d662c..a952c59 100644
--- a/src/Common/DevHive.Common.Models/DevHive.Common.Models.csproj
+++ b/src/Common/DevHive.Common.Models/DevHive.Common.Models.csproj
@@ -4,7 +4,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2"/>
- <PackageReference Include="SonarAnalyzer.CSharp" Version="8.18.0.27296"/>
+ <PackageReference Include="SonarAnalyzer.CSharp" Version="8.19.0.28253"/>
</ItemGroup>
<PropertyGroup>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
diff --git a/src/Data/DevHive.Data.Models/DevHive.Data.Models.csproj b/src/Data/DevHive.Data.Models/DevHive.Data.Models.csproj
index e9dc644..d249c77 100644
--- a/src/Data/DevHive.Data.Models/DevHive.Data.Models.csproj
+++ b/src/Data/DevHive.Data.Models/DevHive.Data.Models.csproj
@@ -5,6 +5,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0"/>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.3"/>
- <PackageReference Include="SonarAnalyzer.CSharp" Version="8.18.0.27296"/>
+ <PackageReference Include="SonarAnalyzer.CSharp" Version="8.19.0.28253"/>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/src/Data/DevHive.Data.Tests/DevHive.Data.Tests.csproj b/src/Data/DevHive.Data.Tests/DevHive.Data.Tests.csproj
index 46c7b83..25b2b39 100644
--- a/src/Data/DevHive.Data.Tests/DevHive.Data.Tests.csproj
+++ b/src/Data/DevHive.Data.Tests/DevHive.Data.Tests.csproj
@@ -9,7 +9,7 @@
<PackageReference Include="NUnit" Version="3.13.1"/>
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1"/>
- <PackageReference Include="SonarAnalyzer.CSharp" Version="8.18.0.27296"/>
+ <PackageReference Include="SonarAnalyzer.CSharp" Version="8.19.0.28253"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DevHive.Data\DevHive.Data.csproj"/>
diff --git a/src/Data/DevHive.Data/DevHive.Data.csproj b/src/Data/DevHive.Data/DevHive.Data.csproj
index 46928c6..fcdb7ae 100644
--- a/src/Data/DevHive.Data/DevHive.Data.csproj
+++ b/src/Data/DevHive.Data/DevHive.Data.csproj
@@ -12,7 +12,7 @@
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0"/>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2"/>
- <PackageReference Include="SonarAnalyzer.CSharp" Version="8.18.0.27296"/>
+ <PackageReference Include="SonarAnalyzer.CSharp" Version="8.19.0.28253"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DevHive.Data.Models\DevHive.Data.Models.csproj"/>
diff --git a/src/Services/DevHive.Services.Models/DevHive.Services.Models.csproj b/src/Services/DevHive.Services.Models/DevHive.Services.Models.csproj
index 6bbc60e..a55972a 100644
--- a/src/Services/DevHive.Services.Models/DevHive.Services.Models.csproj
+++ b/src/Services/DevHive.Services.Models/DevHive.Services.Models.csproj
@@ -3,11 +3,11 @@
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
- <PackageReference Include="SonarAnalyzer.CSharp" Version="8.18.0.27296" />
+ <PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2"/>
+ <PackageReference Include="SonarAnalyzer.CSharp" Version="8.19.0.28253"/>
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\..\Common\DevHive.Common\DevHive.Common.csproj" />
- <ProjectReference Include="..\..\Common\DevHive.Common.Models\DevHive.Common.Models.csproj" />
+ <ProjectReference Include="..\..\Common\DevHive.Common\DevHive.Common.csproj"/>
+ <ProjectReference Include="..\..\Common\DevHive.Common.Models\DevHive.Common.Models.csproj"/>
</ItemGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/src/Services/DevHive.Services.Tests/DevHive.Services.Tests.csproj b/src/Services/DevHive.Services.Tests/DevHive.Services.Tests.csproj
index b3d0a32..d85eea2 100644
--- a/src/Services/DevHive.Services.Tests/DevHive.Services.Tests.csproj
+++ b/src/Services/DevHive.Services.Tests/DevHive.Services.Tests.csproj
@@ -4,20 +4,20 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.3" />
- <PackageReference Include="Moq" Version="4.16.1" />
- <PackageReference Include="NUnit" Version="3.13.1" />
- <PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
- <PackageReference Include="SonarAnalyzer.CSharp" Version="8.18.0.27296" />
+ <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.3"/>
+ <PackageReference Include="Moq" Version="4.16.1"/>
+ <PackageReference Include="NUnit" Version="3.13.1"/>
+ <PackageReference Include="NUnit3TestAdapter" Version="3.17.0"/>
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1"/>
+ <PackageReference Include="SonarAnalyzer.CSharp" Version="8.19.0.28253"/>
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\DevHive.Services\DevHive.Services.csproj" />
- <ProjectReference Include="..\..\Common\DevHive.Common\DevHive.Common.csproj" />
- <ProjectReference Include="..\..\Common\DevHive.Common.Models\DevHive.Common.Models.csproj" />
+ <ProjectReference Include="..\DevHive.Services\DevHive.Services.csproj"/>
+ <ProjectReference Include="..\..\Common\DevHive.Common\DevHive.Common.csproj"/>
+ <ProjectReference Include="..\..\Common\DevHive.Common.Models\DevHive.Common.Models.csproj"/>
</ItemGroup>
<PropertyGroup>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
</PropertyGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/src/Services/DevHive.Services/DevHive.Services.csproj b/src/Services/DevHive.Services/DevHive.Services.csproj
index 55d9d4e..f51c1b6 100644
--- a/src/Services/DevHive.Services/DevHive.Services.csproj
+++ b/src/Services/DevHive.Services/DevHive.Services.csproj
@@ -3,25 +3,25 @@
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
+ <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
- <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.8.0" />
- <PackageReference Include="AutoMapper" Version="10.1.1" />
- <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
- <PackageReference Include="CloudinaryDotNet" Version="1.14.0" />
- <PackageReference Include="SonarAnalyzer.CSharp" Version="8.18.0.27296" />
+ <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.8.0"/>
+ <PackageReference Include="AutoMapper" Version="10.1.1"/>
+ <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1"/>
+ <PackageReference Include="CloudinaryDotNet" Version="1.14.0"/>
+ <PackageReference Include="SonarAnalyzer.CSharp" Version="8.19.0.28253"/>
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\..\Data\DevHive.Data\DevHive.Data.csproj" />
- <ProjectReference Include="..\DevHive.Services.Models\DevHive.Services.Models.csproj" />
- <ProjectReference Include="..\..\Common\DevHive.Common\DevHive.Common.csproj" />
- <ProjectReference Include="..\..\Common\DevHive.Common.Models\DevHive.Common.Models.csproj" />
+ <ProjectReference Include="..\..\Data\DevHive.Data\DevHive.Data.csproj"/>
+ <ProjectReference Include="..\DevHive.Services.Models\DevHive.Services.Models.csproj"/>
+ <ProjectReference Include="..\..\Common\DevHive.Common\DevHive.Common.csproj"/>
+ <ProjectReference Include="..\..\Common\DevHive.Common.Models\DevHive.Common.Models.csproj"/>
</ItemGroup>
<PropertyGroup>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
</PropertyGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/src/Web/DevHive.Web.Models/DevHive.Web.Models.csproj b/src/Web/DevHive.Web.Models/DevHive.Web.Models.csproj
index 7f3f577..9d62eee 100644
--- a/src/Web/DevHive.Web.Models/DevHive.Web.Models.csproj
+++ b/src/Web/DevHive.Web.Models/DevHive.Web.Models.csproj
@@ -3,11 +3,11 @@
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
- <ProjectReference Include="..\..\Common\DevHive.Common\DevHive.Common.csproj" />
- <ProjectReference Include="..\..\Common\DevHive.Common.Models\DevHive.Common.Models.csproj" />
+ <ProjectReference Include="..\..\Common\DevHive.Common\DevHive.Common.csproj"/>
+ <ProjectReference Include="..\..\Common\DevHive.Common.Models\DevHive.Common.Models.csproj"/>
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
- <PackageReference Include="SonarAnalyzer.CSharp" Version="8.18.0.27296" />
+ <PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2"/>
+ <PackageReference Include="SonarAnalyzer.CSharp" Version="8.19.0.28253"/>
</ItemGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/src/Web/DevHive.Web.Tests/DevHive.Web.Tests.csproj b/src/Web/DevHive.Web.Tests/DevHive.Web.Tests.csproj
index 41afbd4..5099119 100644
--- a/src/Web/DevHive.Web.Tests/DevHive.Web.Tests.csproj
+++ b/src/Web/DevHive.Web.Tests/DevHive.Web.Tests.csproj
@@ -4,19 +4,19 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Moq" Version="4.16.1" />
- <PackageReference Include="NUnit" Version="3.13.1" />
- <PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
- <PackageReference Include="SonarAnalyzer.CSharp" Version="8.18.0.27296" />
+ <PackageReference Include="Moq" Version="4.16.1"/>
+ <PackageReference Include="NUnit" Version="3.13.1"/>
+ <PackageReference Include="NUnit3TestAdapter" Version="3.17.0"/>
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1"/>
+ <PackageReference Include="SonarAnalyzer.CSharp" Version="8.19.0.28253"/>
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\DevHive.Web\DevHive.Web.csproj" />
- <ProjectReference Include="..\..\Common\DevHive.Common\DevHive.Common.csproj" />
- <ProjectReference Include="..\..\Common\DevHive.Common.Models\DevHive.Common.Models.csproj" />
+ <ProjectReference Include="..\DevHive.Web\DevHive.Web.csproj"/>
+ <ProjectReference Include="..\..\Common\DevHive.Common\DevHive.Common.csproj"/>
+ <ProjectReference Include="..\..\Common\DevHive.Common.Models\DevHive.Common.Models.csproj"/>
</ItemGroup>
<PropertyGroup>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
</PropertyGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/src/Web/DevHive.Web/Configurations/Extensions/ConfigureSwagger.cs b/src/Web/DevHive.Web/Configurations/Extensions/ConfigureSwagger.cs
index bfa44b0..9387561 100644
--- a/src/Web/DevHive.Web/Configurations/Extensions/ConfigureSwagger.cs
+++ b/src/Web/DevHive.Web/Configurations/Extensions/ConfigureSwagger.cs
@@ -1,12 +1,8 @@
-using System;
-using System.IO;
using System.Linq;
-using System.Reflection;
using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
-using Microsoft.OpenApi.Models;
-using Swashbuckle.AspNetCore.SwaggerGen;
+using NSwag;
+using NSwag.Generation.Processors.Security;
namespace DevHive.Web.Configurations.Extensions
{
@@ -20,33 +16,49 @@ namespace DevHive.Web.Configurations.Extensions
public static void SwaggerConfiguration(this IServiceCollection services)
{
- services.AddSwaggerGen(c =>
+ services.AddOpenApiDocument(c =>
{
- c.SwaggerDoc("v0.1", new OpenApiInfo
+ c.GenerateXmlObjects = true;
+ c.UseControllerSummaryAsTagDescription = true;
+
+ c.AllowNullableBodyParameters = false;
+ c.Description = "DevHive Social Media's API Endpoints";
+
+ c.PostProcess = doc =>
{
- Version = "v0.1",
- Title = "API",
- Description = "DevHive Social Media's first official API release",
- TermsOfService = new Uri(TermsOfServiceUri),
- License = new OpenApiLicense
+ doc.Info.Version = "v0.1";
+ doc.Info.Title = "API";
+ doc.Info.Description = "DevHive Social Media's first official API release";
+ doc.Info.TermsOfService = TermsOfServiceUri;
+ doc.Info.License = new NSwag.OpenApiLicense
{
Name = LicenseName,
- Url = new Uri(LicenseUri)
- }
- });
+ Url = LicenseUri
+ };
+ };
- string xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
- string xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
- c.IncludeXmlComments(xmlPath);
+ c.AddSecurity("Bearer", Enumerable.Empty<string>(), new OpenApiSecurityScheme
+ {
+ Type = OpenApiSecuritySchemeType.ApiKey,
+ Name = "Authorization",
+ In = OpenApiSecurityApiKeyLocation.Header,
+ Description = "Type into the textbox: Bearer {your JWT token}."
+ });
+ c.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("Bearer"));
});
}
public static void UseSwaggerConfiguration(this IApplicationBuilder app)
{
- app.UseSwagger();
- app.UseSwaggerUI(c =>
+ app.UseOpenApi(c =>
+ {
+ c.DocumentName = "v0.1";
+ });
+ app.UseSwaggerUi3(c =>
{
- c.SwaggerEndpoint("/swagger/v0.1/swagger.json", "v0.1");
+ c.DocumentTitle = "DevHive API";
+ c.EnableTryItOut = false;
+ c.DocExpansion = "list";
});
}
}
diff --git a/src/Web/DevHive.Web/DevHive.Web.csproj b/src/Web/DevHive.Web/DevHive.Web.csproj
index ea9eee6..38f21e6 100644
--- a/src/Web/DevHive.Web/DevHive.Web.csproj
+++ b/src/Web/DevHive.Web/DevHive.Web.csproj
@@ -5,32 +5,31 @@
<PropertyGroup>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
- <GenerateDocumentationFile>true</GenerateDocumentationFile>
- <AllowUntrustedCertificate>true</AllowUntrustedCertificate>
+ <GenerateDocumentationFile>true</GenerateDocumentationFile>
+ <AllowUntrustedCertificate>true</AllowUntrustedCertificate>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.3" NoWarn="NU1605" />
- <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.3" NoWarn="NU1605" />
+ <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.3" NoWarn="NU1605"/>
+ <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.3" NoWarn="NU1605"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
- <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2" />
- <PackageReference Include="Swashbuckle.AspNetCore" Version="6.0.7" />
- <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
- <PackageReference Include="AutoMapper" Version="10.1.1" />
- <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
- <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.3" />
- <PackageReference Include="SonarAnalyzer.CSharp" Version="8.18.0.27296" />
- <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.0.7" />
- <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.0.7" />
- <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.0.7" />
- <PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="6.1.0" />
+ <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2"/>
+ <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1"/>
+ <PackageReference Include="AutoMapper" Version="10.1.1"/>
+ <PackageReference Include="Newtonsoft.Json" Version="12.0.3"/>
+ <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.3"/>
+ <PackageReference Include="SonarAnalyzer.CSharp" Version="8.19.0.28253"/>
+ <PackageReference Include="NSwag.AspNetCore" Version="13.10.7"/>
+ <PackageReference Include="NSwag.Generation.AspNetCore" Version="13.10.7"/>
+ <PackageReference Include="NSwag.Annotations" Version="13.10.7"/>
+ <PackageReference Include="NSwag.Core" Version="13.10.7"/>
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\DevHive.Web.Models\DevHive.Web.Models.csproj" />
- <ProjectReference Include="..\..\Services\DevHive.Services\DevHive.Services.csproj" />
- <ProjectReference Include="..\..\Common\DevHive.Common.Models\DevHive.Common.Models.csproj" />
- <ProjectReference Include="..\..\Common\DevHive.Common\DevHive.Common.csproj" />
+ <ProjectReference Include="..\DevHive.Web.Models\DevHive.Web.Models.csproj"/>
+ <ProjectReference Include="..\..\Services\DevHive.Services\DevHive.Services.csproj"/>
+ <ProjectReference Include="..\..\Common\DevHive.Common.Models\DevHive.Common.Models.csproj"/>
+ <ProjectReference Include="..\..\Common\DevHive.Common\DevHive.Common.csproj"/>
</ItemGroup>
</Project>
diff --git a/src/Web/DevHive.Web/Startup.cs b/src/Web/DevHive.Web/Startup.cs
index 40f674d..ebd091e 100644
--- a/src/Web/DevHive.Web/Startup.cs
+++ b/src/Web/DevHive.Web/Startup.cs
@@ -48,7 +48,6 @@ namespace DevHive.Web
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
- app.UseSwaggerConfiguration();
}
else
{
@@ -56,6 +55,7 @@ namespace DevHive.Web
app.UseExceptionHandlerMiddlewareConfiguration();
}
+ app.UseSwaggerConfiguration();
app.UseDatabaseConfiguration();
app.UseAutoMapperConfiguration();