Skip to content
Permalink
Browse files

Make global scope names optional (#2305)

  • Loading branch information...
RicoSuter committed Jul 10, 2019
1 parent 54ff7ef commit adcab5d05b26e5b2d8025afdb73c9b836c606889
@@ -22,11 +22,22 @@ public static class NSwagSwaggerGeneratorSettingsExtensions
/// <remarks>Adds a <see cref="SecurityDefinitionAppender"/> document processor with the given arguments.</remarks>
/// <param name="settings">The settings.</param>
/// <param name="name">The name/key of the security scheme/definition.</param>
/// <param name="scopeNames">The scope names to add to as security requirement with the scheme name in the 'security' property (can be an empty list).</param>
/// <param name="swaggerSecurityScheme">The Swagger security scheme.</param>
public static OpenApiDocumentGeneratorSettings AddSecurity(this OpenApiDocumentGeneratorSettings settings, string name, IEnumerable<string> scopeNames, OpenApiSecurityScheme swaggerSecurityScheme)
public static OpenApiDocumentGeneratorSettings AddSecurity(this OpenApiDocumentGeneratorSettings settings, string name, OpenApiSecurityScheme swaggerSecurityScheme)
{
settings.DocumentProcessors.Add(new SecurityDefinitionAppender(name, scopeNames, swaggerSecurityScheme));
settings.DocumentProcessors.Add(new SecurityDefinitionAppender(name, swaggerSecurityScheme));
return settings;
}

/// <summary>Appends the OAuth2 security scheme and requirement to the document's security definitions.</summary>
/// <remarks>Adds a <see cref="SecurityDefinitionAppender"/> document processor with the given arguments.</remarks>
/// <param name="settings">The settings.</param>
/// <param name="name">The name/key of the security scheme/definition.</param>
/// <param name="globalScopeNames">The global scope names to add to as security requirement with the scheme name in the document's 'security' property (can be an empty list).</param>
/// <param name="swaggerSecurityScheme">The Swagger security scheme.</param>
public static OpenApiDocumentGeneratorSettings AddSecurity(this OpenApiDocumentGeneratorSettings settings, string name, IEnumerable<string> globalScopeNames, OpenApiSecurityScheme swaggerSecurityScheme)
{
settings.DocumentProcessors.Add(new SecurityDefinitionAppender(name, globalScopeNames, swaggerSecurityScheme));
return settings;
}
}
@@ -23,7 +23,6 @@ public class SecurityDefinitionAppender : IDocumentProcessor
/// <summary>Initializes a new instance of the <see cref="SecurityDefinitionAppender" /> class where the security requirement must be manually added.</summary>
/// <param name="name">The name/key of the security scheme/definition.</param>
/// <param name="swaggerSecurityScheme">The Swagger security scheme.</param>
[Obsolete("Use the constructor with scopeNames parameter instead.")]
public SecurityDefinitionAppender(string name, OpenApiSecurityScheme swaggerSecurityScheme)
{
_name = name;
@@ -32,12 +31,12 @@ public SecurityDefinitionAppender(string name, OpenApiSecurityScheme swaggerSecu

/// <summary>Initializes a new instance of the <see cref="SecurityDefinitionAppender" /> class.</summary>
/// <param name="name">The name/key of the security scheme/definition.</param>
/// <param name="scopeNames">The scope names to add to as security requirement with the scheme name in the 'security' property (can be an empty list).</param>
/// <param name="globalScopeNames">The global scope names to add to as security requirement with the scheme name in the document's 'security' property (can be an empty list).</param>
/// <param name="swaggerSecurityScheme">The Swagger security scheme.</param>
public SecurityDefinitionAppender(string name, IEnumerable<string> scopeNames, OpenApiSecurityScheme swaggerSecurityScheme)
public SecurityDefinitionAppender(string name, IEnumerable<string> globalScopeNames, OpenApiSecurityScheme swaggerSecurityScheme)
{
_name = name;
_scopeNames = scopeNames ?? throw new ArgumentNullException(nameof(scopeNames));
_scopeNames = globalScopeNames ?? throw new ArgumentNullException(nameof(globalScopeNames));
_swaggerSecurityScheme = swaggerSecurityScheme;
}

0 comments on commit adcab5d

Please sign in to comment.
You can’t perform that action at this time.