Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

SwaggerStartup - add contact/license

support5215a3d606a6
diff --git a/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs b/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs
index a638d00cc..bd1c4ccff 100644
--- a/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs
+++ b/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs
@@ -26,9 +26,8 @@ namespace Grand.Api.Infrastructure
application.UseSwagger();
application.UseSwaggerUI(c =>
{
- c.SwaggerEndpoint("/swagger/v1/swagger.json", "Grandnode Backend API V1");
- c.SwaggerEndpoint("/swagger/v2/swagger.json", "Grandnode Frontend API V1");
-
+ c.SwaggerEndpoint("/swagger/v1/swagger.json", "Grandnode Backend API");
+ c.SwaggerEndpoint("/swagger/v2/swagger.json", "Grandnode Frontend API");
});
}
}
@@ -38,11 +37,22 @@ namespace Grand.Api.Infrastructure
var apiConfig = services.BuildServiceProvider().GetService<BackendAPIConfig>();
if (apiConfig.Enabled && apiConfig.UseSwagger)
{
-
services.AddSwaggerGen(c =>
{
- c.SwaggerDoc("v1", new OpenApiInfo { Title = "Grandnode Backend API", Version = "v1" });
- c.SwaggerDoc("v2", new OpenApiInfo { Title = "Grandnode Frontend API", Version = "v2" });
+ c.SwaggerDoc("v1", new OpenApiInfo
+ {
+ Title = "Grandnode Backend API",
+ Version = "v1",
+ Contact = GetOpenApiContact(),
+ License = GetOpenApiLicense()
+ });
+ c.SwaggerDoc("v2", new OpenApiInfo
+ {
+ Title = "Grandnode Frontend API",
+ Version = "v2",
+ Contact = GetOpenApiContact(),
+ License = GetOpenApiLicense()
+ });
c.AddSecurityDefinition(JwtBearerDefaults.AuthenticationScheme, //Name the security scheme
new OpenApiSecurityScheme
@@ -76,5 +86,21 @@ namespace Grand.Api.Infrastructure
public int Priority => 90;
public bool BeforeConfigure => true;
+ private OpenApiContact GetOpenApiContact()
+ {
+ return new OpenApiContact {
+ Name = "Grandnode",
+ Email = "[email protected]",
+ Url = new Uri("https://grancnode.com"),
+ };
+ }
+
+ private OpenApiLicense GetOpenApiLicense()
+ {
+ return new OpenApiLicense {
+ Name = "GNU General Public License v3.0",
+ Url = new Uri("https://github.com/grandnode/grandnode2/blob/master/LICENSE"),
+ };
+ }
}
}