Skip to content

Commit

Permalink
Move method
Browse files Browse the repository at this point in the history
  • Loading branch information
RicoSuter committed Oct 16, 2018
1 parent b743686 commit 2da52e8
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/NSwag.AspNetCore/SwaggerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,6 @@ public static IApplicationBuilder UseSwaggerWithApiExplorer(
return UseSwaggerWithApiExplorerCore(app, settings, schemaGenerator);
}

private static IApplicationBuilder UseSwaggerWithApiExplorerCore(
IApplicationBuilder app,
SwaggerSettings<AspNetCoreToSwaggerGeneratorSettings> settings,
SwaggerJsonSchemaGenerator schemaGenerator)
{
if (settings.DocumentName != null)
{
var registry = app.ApplicationServices.GetService<DocumentRegistry>();
if (registry != null)
{
// Register our settings in the registry if possible. The middleware doesn't actually depend
// on any services, it does things the old way.
registry[settings.DocumentName] = RegisteredDocument.CreateAspNetCoreGeneratorDocument(settings.GeneratorSettings, schemaGenerator, settings.PostProcess);
}
}

return app.UseMiddleware<AspNetCoreToSwaggerMiddleware>(settings, schemaGenerator);
}

/// <summary>Adds services required for swagger generation.</summary>
/// <param name="serviceCollection">The <see cref="IServiceCollection"/>.</param>
/// <remarks>
Expand Down Expand Up @@ -437,5 +418,24 @@ public static IApplicationBuilder UseSwaggerReDocWithApiExplorer(
}

#endregion

private static IApplicationBuilder UseSwaggerWithApiExplorerCore(
IApplicationBuilder app,
SwaggerSettings<AspNetCoreToSwaggerGeneratorSettings> settings,
SwaggerJsonSchemaGenerator schemaGenerator)
{
if (settings.DocumentName != null)
{
var registry = app.ApplicationServices.GetService<DocumentRegistry>();
if (registry != null)
{
// Register our settings in the registry if possible. The middleware doesn't actually depend
// on any services, it does things the old way.
registry[settings.DocumentName] = RegisteredDocument.CreateAspNetCoreGeneratorDocument(settings.GeneratorSettings, schemaGenerator, settings.PostProcess);
}
}

return app.UseMiddleware<AspNetCoreToSwaggerMiddleware>(settings, schemaGenerator);
}
}
}

0 comments on commit 2da52e8

Please sign in to comment.