Skip to content

Commit

Permalink
remove legacy swagger ui (keep only UseSwaggerUi() with latest version)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico Suter committed Nov 1, 2023
1 parent 5dbeb3f commit 512eb65
Show file tree
Hide file tree
Showing 141 changed files with 357 additions and 53,202 deletions.
4 changes: 2 additions & 2 deletions src/NSwag.AspNet.Owin/Middlewares/SwaggerUiIndexMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ internal class SwaggerUiIndexMiddleware<T> : OwinMiddleware
where T : OpenApiDocumentGeneratorSettings, new()
{
private readonly string _indexPath;
private readonly SwaggerUiSettingsBase<T> _settings;
private readonly SwaggerUiSettings<T> _settings;
private readonly string _resourcePath;

public SwaggerUiIndexMiddleware(OwinMiddleware next, string indexPath, SwaggerUiSettingsBase<T> settings, string resourcePath)
public SwaggerUiIndexMiddleware(OwinMiddleware next, string indexPath, SwaggerUiSettings<T> settings, string resourcePath)
: base(next)
{
_indexPath = indexPath;
Expand Down
15 changes: 3 additions & 12 deletions src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,16 @@
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="ReDoc\index.html" />
<EmbeddedResource Include="SwaggerUi\**\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
<EmbeddedResource Include="SwaggerUi3\favicon-16x16.png" />
<EmbeddedResource Include="SwaggerUi3\favicon-32x32.png" />
<EmbeddedResource Include="SwaggerUi3\index.html" />
<EmbeddedResource Include="SwaggerUi3\oauth2-redirect.html" />
<EmbeddedResource Include="SwaggerUi3\swagger-ui-bundle.js" />
<EmbeddedResource Include="SwaggerUi3\swagger-ui-standalone-preset.js" />
<EmbeddedResource Include="SwaggerUi3\swagger-ui.css" />
<EmbeddedResource Include="SwaggerUi3\swagger-ui.js" />
<EmbeddedResource Include="ReDoc\**\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
<EmbeddedResource Include="SwaggerUi\**\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\NSwag.AspNetCore\HttpRequestExtension.cs" Link="HttpRequestExtension.cs" />
<Compile Include="..\NSwag.AspNetCore\OAuth2ClientSettings.cs" Link="OAuth2ClientSettings.cs" />
<Compile Include="..\NSwag.AspNetCore\ReDocSettings.cs" Link="ReDocSettings.cs" />
<Compile Include="..\NSwag.AspNetCore\SwaggerSettings.cs" Link="SwaggerSettings.cs" />
<Compile Include="..\NSwag.AspNetCore\SwaggerUi3Settings.cs" Link="SwaggerUi3Settings.cs" />
<Compile Include="..\NSwag.AspNetCore\SwaggerUiSettings.cs" Link="SwaggerUiSettings.cs" />
<Compile Include="..\NSwag.AspNetCore\SwaggerUiSettings.cs" Link="SwaggerUi3Settings.cs" />
<Compile Include="..\NSwag.AspNetCore\SwaggerUiSettingsBase.cs" Link="SwaggerUiSettingsBase.cs" />
</ItemGroup>

Expand Down
94 changes: 9 additions & 85 deletions src/NSwag.AspNet.Owin/SwaggerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using Microsoft.Owin.FileSystems;
using Microsoft.Owin.StaticFiles;
using NSwag.AspNet.Owin.Middlewares;
using NSwag.Generation;
using NSwag.Generation.WebApi;
using Owin;

Expand All @@ -26,39 +25,39 @@ public static class SwaggerExtensions
{
#region Swagger

/// <summary>Adds the Swagger generator to the OWIN pipeline.</summary>
/// <summary>Adds the OpenAPI/Swagger generator to the OWIN pipeline.</summary>
/// <param name="app">The app.</param>
/// <param name="webApiAssembly">The Web API assembly to search for controller types.</param>
/// <param name="configure">Configure the Swagger settings.</param>
/// <returns>The app builder.</returns>
public static IAppBuilder UseSwagger(
public static IAppBuilder UseOpenApi(
this IAppBuilder app,
Assembly webApiAssembly,
Action<SwaggerSettings<WebApiOpenApiDocumentGeneratorSettings>> configure = null)
{
return app.UseSwagger(new[] { webApiAssembly }, configure);
return app.UseOpenApi(new[] { webApiAssembly }, configure);
}

/// <summary>Adds the Swagger generator to the OWIN pipeline.</summary>
/// <summary>Adds the OpenAPI/Swagger generator to the OWIN pipeline.</summary>
/// <param name="app">The app.</param>
/// <param name="webApiAssemblies">The Web API assemblies to search for controller types.</param>
/// <param name="configure">Configure the Swagger settings.</param>
/// <returns>The app builder.</returns>
public static IAppBuilder UseSwagger(
public static IAppBuilder UseOpenApi(
this IAppBuilder app,
IEnumerable<Assembly> webApiAssemblies,
Action<SwaggerSettings<WebApiOpenApiDocumentGeneratorSettings>> configure = null)
{
var controllerTypes = webApiAssemblies.SelectMany(WebApiOpenApiDocumentGenerator.GetControllerClasses);
return app.UseSwagger(controllerTypes, configure);
return app.UseOpenApi(controllerTypes, configure);
}

/// <summary>Adds the Swagger generator to the OWIN pipeline.</summary>
/// <summary>Adds the OpenAPI/Swagger generator to the OWIN pipeline.</summary>
/// <param name="app">The app.</param>
/// <param name="controllerTypes">The Web API controller types.</param>
/// <param name="configure">Configure the Swagger settings.</param>
/// <returns>The app builder.</returns>
public static IAppBuilder UseSwagger(
public static IAppBuilder UseOpenApi(
this IAppBuilder app,
IEnumerable<Type> controllerTypes,
Action<SwaggerSettings<WebApiOpenApiDocumentGeneratorSettings>> configure = null)
Expand All @@ -80,7 +79,6 @@ public static IAppBuilder UseSwagger(
/// <param name="webApiAssembly">The Web API assembly to search for controller types.</param>
/// <param name="configure">Configure the Swagger settings.</param>
/// <returns>The app builder.</returns>
[Obsolete("Use " + nameof(UseSwaggerUi3) + " instead.")]
public static IAppBuilder UseSwaggerUi(
this IAppBuilder app,
Assembly webApiAssembly,
Expand All @@ -94,7 +92,6 @@ public static IAppBuilder UseSwaggerUi(
/// <param name="webApiAssemblies">The Web API assemblies to search for controller types.</param>
/// <param name="configure">Configure the Swagger settings.</param>
/// <returns>The app builder.</returns>
[Obsolete("Use " + nameof(UseSwaggerUi3) + " instead.")]
public static IAppBuilder UseSwaggerUi(
this IAppBuilder app,
IEnumerable<Assembly> webApiAssemblies,
Expand All @@ -108,10 +105,9 @@ public static IAppBuilder UseSwaggerUi(
/// <param name="app">The app.</param>
/// <param name="configure">Configure the Swagger settings.</param>
/// <returns>The app builder.</returns>
[Obsolete("Use " + nameof(UseSwaggerUi3) + " instead.")]
public static IAppBuilder UseSwaggerUi(
this IAppBuilder app,
Action<SwaggerSettings<WebApiOpenApiDocumentGeneratorSettings>> configure = null)
Action<SwaggerUiSettings<WebApiOpenApiDocumentGeneratorSettings>> configure = null)
{
return app.UseSwaggerUi((IEnumerable<Type>)null, configure);
}
Expand All @@ -121,7 +117,6 @@ public static IAppBuilder UseSwaggerUi(
/// <param name="controllerTypes">The Web API controller types.</param>
/// <param name="configure">Configure the Swagger settings.</param>
/// <returns>The app builder.</returns>
[Obsolete("Use " + nameof(UseSwaggerUi3) + " instead.")]
public static IAppBuilder UseSwaggerUi(
this IAppBuilder app,
IEnumerable<Type> controllerTypes,
Expand All @@ -148,77 +143,6 @@ public static IAppBuilder UseSwaggerUi(

#endregion

#region SwaggerUi3

/// <summary>Adds the Swagger generator and Swagger UI to the OWIN pipeline.</summary>
/// <param name="app">The app.</param>
/// <param name="webApiAssembly">The Web API assembly to search for controller types.</param>
/// <param name="configure">Configure the Swagger settings.</param>
/// <returns>The app builder.</returns>
public static IAppBuilder UseSwaggerUi3(
this IAppBuilder app,
Assembly webApiAssembly,
Action<SwaggerUi3Settings<WebApiOpenApiDocumentGeneratorSettings>> configure = null)
{
return app.UseSwaggerUi3(new[] { webApiAssembly }, configure);
}

/// <summary>Adds the Swagger generator and Swagger UI to the OWIN pipeline.</summary>
/// <param name="app">The app.</param>
/// <param name="webApiAssemblies">The Web API assemblies to search for controller types.</param>
/// <param name="configure">Configure the Swagger settings.</param>
/// <returns>The app builder.</returns>
public static IAppBuilder UseSwaggerUi3(
this IAppBuilder app,
IEnumerable<Assembly> webApiAssemblies,
Action<SwaggerUi3Settings<WebApiOpenApiDocumentGeneratorSettings>> configure = null)
{
var controllerTypes = webApiAssemblies.SelectMany(WebApiOpenApiDocumentGenerator.GetControllerClasses);
return app.UseSwaggerUi3(controllerTypes, configure);
}

/// <summary>Adds the Swagger UI (only) to the OWIN pipeline.</summary>
/// <param name="app">The app.</param>
/// <param name="configure">Configure the Swagger settings.</param>
/// <returns>The app builder.</returns>
public static IAppBuilder UseSwaggerUi3(
this IAppBuilder app,
Action<SwaggerUi3Settings<WebApiOpenApiDocumentGeneratorSettings>> configure = null)
{
return app.UseSwaggerUi3((IEnumerable<Type>)null, configure);
}

/// <summary>Adds the Swagger generator and Swagger UI to the OWIN pipeline.</summary>
/// <param name="app">The app.</param>
/// <param name="controllerTypes">The Web API controller types.</param>
/// <param name="configure">Configure the Swagger settings.</param>
/// <returns>The app builder.</returns>
public static IAppBuilder UseSwaggerUi3(
this IAppBuilder app,
IEnumerable<Type> controllerTypes,
Action<SwaggerUi3Settings<WebApiOpenApiDocumentGeneratorSettings>> configure = null)
{
var settings = new SwaggerUi3Settings<WebApiOpenApiDocumentGeneratorSettings>();
configure?.Invoke(settings);

if (controllerTypes != null)
{
app.Use<OpenApiDocumentMiddleware>(settings.ActualSwaggerDocumentPath, controllerTypes, settings);
}

app.Use<RedirectToIndexMiddleware>(settings.ActualSwaggerUiPath, settings.ActualSwaggerDocumentPath, settings.TransformToExternalPath);
app.Use<SwaggerUiIndexMiddleware<WebApiOpenApiDocumentGeneratorSettings>>(settings.ActualSwaggerUiPath + "/index.html", settings, "NSwag.AspNet.Owin.SwaggerUi3.index.html");
app.UseFileServer(new FileServerOptions
{
RequestPath = new PathString(settings.ActualSwaggerUiPath),
FileSystem = new EmbeddedResourceFileSystem(typeof(SwaggerExtensions).Assembly, "NSwag.AspNet.Owin.SwaggerUi3")
});
app.UseStageMarker(PipelineStage.MapHandler);
return app;
}

#endregion

#region ReDoc

/// <summary>Adds the Swagger generator and Swagger UI to the OWIN pipeline.</summary>
Expand Down
1 change: 0 additions & 1 deletion src/NSwag.AspNet.Owin/SwaggerUi/css/print.css

This file was deleted.

1 change: 0 additions & 1 deletion src/NSwag.AspNet.Owin/SwaggerUi/css/reset.css

This file was deleted.

1 change: 0 additions & 1 deletion src/NSwag.AspNet.Owin/SwaggerUi/css/screen.css

This file was deleted.

1 change: 0 additions & 1 deletion src/NSwag.AspNet.Owin/SwaggerUi/css/style.css

This file was deleted.

Empty file.
Binary file not shown.
Binary file removed src/NSwag.AspNet.Owin/SwaggerUi/fonts/DroidSans.ttf
Binary file not shown.
Binary file removed src/NSwag.AspNet.Owin/SwaggerUi/images/collapse.gif
Binary file not shown.
Binary file removed src/NSwag.AspNet.Owin/SwaggerUi/images/expand.gif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed src/NSwag.AspNet.Owin/SwaggerUi/images/favicon.ico
Binary file not shown.
Binary file removed src/NSwag.AspNet.Owin/SwaggerUi/images/logo_small.png
Binary file not shown.
Binary file not shown.
Binary file removed src/NSwag.AspNet.Owin/SwaggerUi/images/throbber.gif
Binary file not shown.
Binary file removed src/NSwag.AspNet.Owin/SwaggerUi/images/wordnik_api.png
Binary file not shown.
File renamed without changes.
Loading

0 comments on commit 512eb65

Please sign in to comment.