Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Swagger UI #973

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Applications/AdminApi/src/AdminApi/AdminApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<PackageReference Include="Microsoft.AspNetCore.OData" Version="9.1.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />
<PackageReference Include="OpenIddict.EntityFrameworkCore" Version="5.8.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.1.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageReference Include="NetEscapades.AspNetCore.SecurityHeaders" Version="0.24.0" />
<PackageReference Include="ReHackt.Extensions.Options.Validation" Version="9.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ public class AdminConfiguration

public CorsConfiguration Cors { get; set; } = new();

public SwaggerUiConfiguration SwaggerUi { get; set; } = new();

[Required]
public AdminInfrastructureConfiguration Infrastructure { get; set; } = new();

Expand All @@ -30,12 +28,6 @@ public class CorsConfiguration
public bool AccessControlAllowCredentials { get; set; } = false;
}

public class SwaggerUiConfiguration
{
[Required]
public bool Enabled { get; set; } = false;
}

public class AdminInfrastructureConfiguration
{
[Required]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,6 @@ private static object GetPropertyValue(object source, string propertyPath)
return source;
}

public static IServiceCollection AddCustomSwaggerWithUi(this IServiceCollection services)
{
services
.AddEndpointsApiExplorer()
.AddSwaggerGen();

return services;
}

public static IServiceCollection AddOData(this IServiceCollection services)
{
var builder = new ODataConventionModelBuilder()
Expand Down
6 changes: 0 additions & 6 deletions Applications/AdminApi/src/AdminApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ static void ConfigureServices(IServiceCollection services, IConfiguration config
.AddChallenges(parsedConfiguration.Modules.Challenges)
.AddHealthChecks();

if (parsedConfiguration.SwaggerUi.Enabled)
services.AddCustomSwaggerWithUi();

services
.AddOpenIddict()
.AddCore(options =>
Expand Down Expand Up @@ -190,9 +187,6 @@ static void Configure(WebApplication app)
policies.AddCustomHeader("Access-Control-Allow-Credentials", "true");
});

if (configuration.SwaggerUi.Enabled)
app.UseSwagger().UseSwaggerUI();

if (app.Environment.IsDevelopment())
IdentityModelEventSource.ShowPII = true;

Expand Down
3 changes: 0 additions & 3 deletions Applications/AdminApi/src/AdminApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"Authentication": {
"JwtLifetimeInSeconds": 300
},
"SwaggerUi": {
"Enabled": false
},
"Infrastructure": {
"EventBus": {
"SubscriptionClientName": "adminui"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public class BackboneConfiguration

public CorsConfiguration Cors { get; set; } = new();

public SwaggerUiConfiguration SwaggerUi { get; set; } = new();

[Required]
public BackboneInfrastructureConfiguration Infrastructure { get; set; } = new();

Expand All @@ -41,14 +39,6 @@ public class CorsConfiguration
public string ExposedHeaders { get; set; } = "";
}

public class SwaggerUiConfiguration
{
[Required]
public bool Enabled { get; set; } = false;

public string TokenUrl { get; set; } = "";
}

public class BackboneInfrastructureConfiguration
{
[Required]
Expand Down
1 change: 0 additions & 1 deletion Applications/ConsumerApi/src/ConsumerApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
<PackageReference Include="ReHackt.Extensions.Options.Validation" Version="9.0.0" />
<PackageReference Include="Serilog.Enrichers.Sensitive" Version="1.7.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.0" />
<PackageReference Include="Serilog" Version="4.2.0" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
using Backbone.Modules.Devices.Infrastructure.Persistence.Database;
using Backbone.Modules.Devices.Infrastructure.PushNotifications.Connectors.Sse;
using FluentValidation;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.OpenApi.Models;
using OpenIddict.Validation.AspNetCore;
using PublicKey = Backbone.Modules.Devices.Application.Devices.DTOs.PublicKey;

Expand Down Expand Up @@ -167,39 +165,6 @@ public static IServiceCollection AddCustomFluentValidation(this IServiceCollecti

return services;
}

public static IServiceCollection AddCustomSwaggerUi(this IServiceCollection services,
BackboneConfiguration.SwaggerUiConfiguration configuration)
{
services
.AddEndpointsApiExplorer()
.AddSwaggerGen(c =>
{
var securityScheme = new OpenApiSecurityScheme
{
Type = SecuritySchemeType.OAuth2,
Flows = new OpenApiOAuthFlows { Password = new OpenApiOAuthFlow { TokenUrl = new Uri(configuration.TokenUrl) } },
Name = "Authorization",
In = ParameterLocation.Header,
Scheme = "bearer",
UnresolvedReference = false,
BearerFormat = "JWT",
Reference = new OpenApiReference
{
Id = JwtBearerDefaults.AuthenticationScheme,
Type = ReferenceType.SecurityScheme
}
};

c.AddSecurityDefinition(securityScheme.Reference.Id, securityScheme);
c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{ securityScheme, Array.Empty<string>() }
});
});

return services;
}
}

public class SseServerHealthCheck : IHealthCheck
Expand Down
6 changes: 0 additions & 6 deletions Applications/ConsumerApi/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ static void ConfigureServices(IServiceCollection services, IConfiguration config
.AddCustomFluentValidation()
.AddCustomOpenIddict(parsedConfiguration.Authentication);

if (parsedConfiguration.SwaggerUi.Enabled)
services.AddCustomSwaggerUi(parsedConfiguration.SwaggerUi);

services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders =
Expand Down Expand Up @@ -206,9 +203,6 @@ static void Configure(WebApplication app)

var configuration = app.Services.GetRequiredService<IOptions<BackboneConfiguration>>().Value;

if (configuration.SwaggerUi.Enabled)
app.UseSwagger().UseSwaggerUI();

if (app.Environment.IsDevelopment())
IdentityModelEventSource.ShowPII = true;

Expand Down
3 changes: 0 additions & 3 deletions Applications/ConsumerApi/src/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"Authentication": {
"JwtLifetimeInSeconds": 300
},
"SwaggerUi": {
"Enabled": false
},
"Infrastructure": {
"EventBus": {
"SubscriptionClientName": "consumerapi",
Expand Down
4 changes: 0 additions & 4 deletions appsettings.override.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
"ExposedHeaders": "",
"AccessControlAllowCredentials": true
},
"SwaggerUi": {
"TokenUrl": "http://localhost:5000/connect/token",
"Enabled": true
},
"Infrastructure": {
"EventBus": {
"Vendor": "RabbitMQ", // possible values: InMemory, RabbitMQ, GoogleCloud, Azure
Expand Down
3 changes: 0 additions & 3 deletions docker-compose/adminui.appsettings.override.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"ExposedHeaders": "",
"AccessControlAllowCredentials": true
},
"SwaggerUi": {
"Enabled": true
},
"Infrastructure": {
"EventBus": {
"Vendor": "RabbitMQ", // possible values: InMemory, RabbitMQ, GoogleCloud, Azure
Expand Down
4 changes: 0 additions & 4 deletions docker-compose/appsettings.override.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
"ExposedHeaders": "",
"AccessControlAllowCredentials": true
},
"SwaggerUi": {
"TokenUrl": "http://localhost:8082/connect/token",
"Enabled": true
},
"Infrastructure": {
"EventBus": {
"Vendor": "RabbitMQ", // possible values: InMemory, RabbitMQ, GoogleCloud, Azure
Expand Down
5 changes: 0 additions & 5 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -585,11 +585,6 @@ global:
allowedOrigins: ""
# allowedMethods - a semicolon-separated list of headers that are exposed to the client; the specified headers are recommended, because they are used by the official Enmeshed app
exposedHeaders: "X-Request-Time;X-Response-Time;X-Response-Duration-ms;X-Trace-Id"
swaggerUi:
# enabled - whether the Swagger UI should be enabled
enabled: false
# tokenUrl - the URL from which the Swagger UI can obtain a JWT; it usually follows the pattern "<backbone-base-url>/connect/token"
tokenUrl: ""
infrastructure:
eventBus:
# vendor - possible values: "RabbitMQ"/"Azure"/"GoogleCloud"
Expand Down
Loading