diff --git a/src/Atc.Rest.Extended/Extensions/ApplicationBuilder/RestApiExtendedBuilderExtensions.cs b/src/Atc.Rest.Extended/Extensions/ApplicationBuilder/RestApiExtendedBuilderExtensions.cs index c25dcf71..3e3feb2c 100644 --- a/src/Atc.Rest.Extended/Extensions/ApplicationBuilder/RestApiExtendedBuilderExtensions.cs +++ b/src/Atc.Rest.Extended/Extensions/ApplicationBuilder/RestApiExtendedBuilderExtensions.cs @@ -42,24 +42,27 @@ public static IApplicationBuilder ConfigureRestApi( if ((env.IsDevelopment() || restApiOptions.UseSwaggerUi) && restApiOptions.SwaggerUiTheme is not null) { - var cssFile = string.Empty; - if (restApiOptions.SwaggerUiTheme.EndsWith(".css", StringComparison.Ordinal) && - restApiOptions.SwaggerUiTheme.Contains("Light", StringComparison.OrdinalIgnoreCase)) + var cssFile = restApiOptions.SwaggerUiTheme.EndsWith(".css", StringComparison.Ordinal) switch { - cssFile = "SwaggerLight.css"; - } - else if (restApiOptions.SwaggerUiTheme.EndsWith(".css", StringComparison.Ordinal) && - restApiOptions.SwaggerUiTheme.Contains("Dark", StringComparison.OrdinalIgnoreCase)) - { - cssFile = "SwaggerDark.css"; - } + false when restApiOptions.SwaggerUiTheme.Contains("Light", StringComparison.OrdinalIgnoreCase) => + "SwaggerLight.css", + false when restApiOptions.SwaggerUiTheme.Contains("Dark", StringComparison.OrdinalIgnoreCase) => + "SwaggerDark.css", + _ => string.Empty, + }; var options = new SwaggerUIOptions(); - options.InjectStylesheet(restApiOptions.SwaggerUiTheme); options.EnableTryItOutByDefault(); options.InjectStylesheet($"/swagger-ui/{cssFile}"); options.InjectJavascript("/swagger-ui/main.js"); + // TODO: Add support for multiple versions + var groupName = "v1.0"; + var url = $"/swagger/{groupName}/swagger.json"; + var applicationName = env.ApplicationName; + var name = groupName.ToUpperInvariant(); + options.SwaggerEndpoint(url, $"{applicationName} {name}"); + app.UseOpenApiSpec(env, restApiOptions, options); } else