-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Swashbuckle.AspNetCore.Annotations.SwaggerIgnoreAttribute (#2610)
Application of the SwaggerIgnoreAttribute suppresses the annotated property during schema generation, without altering the serialization behavior as with JsonIgnoreAttribute.
- Loading branch information
1 parent
f26510d
commit 1c29b4b
Showing
7 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/Swashbuckle.AspNetCore.SwaggerGen/Annotations/SwaggerIgnoreAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace Swashbuckle.AspNetCore.Annotations | ||
{ | ||
/// <summary> | ||
/// Causes the annotated member to be ignored during schema generation. | ||
/// Does not alter serialization behavior. | ||
/// </summary> | ||
/// <remarks> | ||
/// Can be used in combination with <see cref="System.Text.Json.Serialization.JsonExtensionDataAttribute"/> | ||
/// to capture and invalidate unsupported properties. | ||
/// </remarks> | ||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property)] | ||
public sealed class SwaggerIgnoreAttribute : Attribute { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/SwaggerIngoreAnnotatedType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
using Swashbuckle.AspNetCore.Annotations; | ||
|
||
namespace Swashbuckle.AspNetCore.SwaggerGen.Test.Fixtures | ||
{ | ||
public class SwaggerIngoreAnnotatedType | ||
{ | ||
public string NotIgnoredString { get; set; } | ||
|
||
[SwaggerIgnore] | ||
public string IgnoredString { get; set; } | ||
|
||
[SwaggerIgnore] | ||
[JsonExtensionData] | ||
public IDictionary<string, JsonElement> IgnoredExtensionData { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters