Browse Source

Enable nullable annotations for Volo.Abp.Swashbuckle

pull/17108/head
liangshiwei 3 years ago
parent
commit
09681147ec
  1. 4
      framework/src/Volo.Abp.Swashbuckle/Microsoft/AspNetCore/Builder/AbpSwaggerUIBuilderExtensions.cs
  2. 12
      framework/src/Volo.Abp.Swashbuckle/Microsoft/Extensions/DependencyInjection/AbpSwaggerGenServiceCollectionExtensions.cs
  3. 2
      framework/src/Volo.Abp.Swashbuckle/Volo.Abp.Swashbuckle.csproj
  4. 2
      framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleDocumentFilter.cs
  5. 2
      framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/SwaggerHtmlResolver.cs

4
framework/src/Volo.Abp.Swashbuckle/Microsoft/AspNetCore/Builder/AbpSwaggerUIBuilderExtensions.cs

@ -9,7 +9,7 @@ public static class AbpSwaggerUIBuilderExtensions
{
public static IApplicationBuilder UseAbpSwaggerUI(
this IApplicationBuilder app,
Action<SwaggerUIOptions> setupAction = null)
Action<SwaggerUIOptions>? setupAction = null)
{
var resolver = app.ApplicationServices.GetService<ISwaggerHtmlResolver>();
@ -17,7 +17,7 @@ public static class AbpSwaggerUIBuilderExtensions
{
options.InjectJavascript("ui/abp.js");
options.InjectJavascript("ui/abp.swagger.js");
options.IndexStream = () => resolver.Resolver();
options.IndexStream = () => resolver?.Resolver();
setupAction?.Invoke(options);
});

12
framework/src/Volo.Abp.Swashbuckle/Microsoft/Extensions/DependencyInjection/AbpSwaggerGenServiceCollectionExtensions.cs

@ -12,7 +12,7 @@ public static class AbpSwaggerGenServiceCollectionExtensions
{
public static IServiceCollection AddAbpSwaggerGen(
this IServiceCollection services,
Action<SwaggerGenOptions> setupAction = null)
Action<SwaggerGenOptions>? setupAction = null)
{
return services.AddSwaggerGen(
options =>
@ -34,7 +34,7 @@ public static class AbpSwaggerGenServiceCollectionExtensions
this IServiceCollection services,
[NotNull] string authority,
[NotNull] Dictionary<string, string> scopes,
Action<SwaggerGenOptions> setupAction = null,
Action<SwaggerGenOptions>? setupAction = null,
string authorizationEndpoint = "/connect/authorize",
string tokenEndpoint = "/connect/token")
{
@ -82,10 +82,10 @@ public static class AbpSwaggerGenServiceCollectionExtensions
public static IServiceCollection AddAbpSwaggerGenWithOidc(
this IServiceCollection services,
[NotNull] string authority,
string[] scopes = null,
string[] flows = null,
string discoveryEndpoint = null,
Action<SwaggerGenOptions> setupAction = null)
string[]? scopes = null,
string[]? flows = null,
string? discoveryEndpoint = null,
Action<SwaggerGenOptions>? setupAction = null)
{
var discoveryUrl = discoveryEndpoint != null ?
new Uri(discoveryEndpoint) :

2
framework/src/Volo.Abp.Swashbuckle/Volo.Abp.Swashbuckle.csproj

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.Swashbuckle</AssemblyName>
<PackageId>Volo.Abp.Swashbuckle</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

2
framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleDocumentFilter.cs

@ -30,7 +30,7 @@ public class AbpSwashbuckleDocumentFilter : IDocumentFilter
.RemoveAll(path => !actionUrls.Contains(path.Key));
}
protected virtual string RemoveRouteParameterConstraints(ActionDescriptor actionDescriptor)
protected virtual string? RemoveRouteParameterConstraints(ActionDescriptor actionDescriptor)
{
var route = actionDescriptor.AttributeRouteInfo?.Template?.EnsureStartsWith('/').Replace("?", "");
if (string.IsNullOrWhiteSpace(route))

2
framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/SwaggerHtmlResolver.cs

@ -13,7 +13,7 @@ public class SwaggerHtmlResolver : ISwaggerHtmlResolver, ITransientDependency
var stream = typeof(SwaggerUIOptions).GetTypeInfo().Assembly
.GetManifestResourceStream("Swashbuckle.AspNetCore.SwaggerUI.index.html");
var html = new StreamReader(stream)
var html = new StreamReader(stream!)
.ReadToEnd()
.Replace("SwaggerUIBundle(configObject)", "abp.SwaggerUIBundle(configObject)");

Loading…
Cancel
Save