Skip to content

Commit b0141b0

Browse files
author
Fernando Gutierres Damaceno
committed
feat: change DisplayAttribute to public
1 parent b3c4b54 commit b0141b0

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

src/Microsoft.OpenApi/Attributes/DisplayAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.OpenApi.Attributes
99
/// Represents the Open Api Data type metadata attribute.
1010
/// </summary>
1111
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
12-
internal class DisplayAttribute : Attribute
12+
public class DisplayAttribute : Attribute
1313
{
1414
/// <summary>
1515
/// Initializes a new instance of the <see cref="DisplayAttribute"/> class.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Microsoft.OpenApi.Attributes;
2+
using Microsoft.OpenApi.Extensions;
3+
using Xunit;
4+
5+
namespace Microsoft.OpenApi.Tests.Attributes
6+
{
7+
8+
public enum ApiLevel
9+
{
10+
[DisplayAttribute("private")]
11+
Private = 1,
12+
[DisplayAttribute("public")]
13+
Public = 2,
14+
[DisplayAttribute("corporate")]
15+
Corporate = 3
16+
}
17+
public class DisplayAttributeTests
18+
{
19+
[Theory]
20+
[InlineData(ApiLevel.Private,"private")]
21+
[InlineData(ApiLevel.Public, "public")]
22+
[InlineData(ApiLevel.Corporate, "corporate")]
23+
public void GetDisplayNameExtensionShouldUseDisplayAttribute(ApiLevel apiLevel, string expected)
24+
{
25+
Assert.Equal(expected, apiLevel.GetDisplayName());
26+
}
27+
}
28+
}

test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ namespace Microsoft.OpenApi.Any
120120
Password = 10,
121121
}
122122
}
123+
namespace Microsoft.OpenApi.Attributes
124+
{
125+
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field)]
126+
public class DisplayAttribute : System.Attribute
127+
{
128+
public DisplayAttribute(string name) { }
129+
public string Name { get; }
130+
}
131+
}
123132
namespace Microsoft.OpenApi.Exceptions
124133
{
125134
public class OpenApiException : System.Exception
@@ -899,43 +908,72 @@ namespace Microsoft.OpenApi.Models
899908
}
900909
public enum OperationType
901910
{
911+
[Microsoft.OpenApi.Attributes.Display("get")]
902912
Get = 0,
913+
[Microsoft.OpenApi.Attributes.Display("put")]
903914
Put = 1,
915+
[Microsoft.OpenApi.Attributes.Display("post")]
904916
Post = 2,
917+
[Microsoft.OpenApi.Attributes.Display("delete")]
905918
Delete = 3,
919+
[Microsoft.OpenApi.Attributes.Display("options")]
906920
Options = 4,
921+
[Microsoft.OpenApi.Attributes.Display("head")]
907922
Head = 5,
923+
[Microsoft.OpenApi.Attributes.Display("patch")]
908924
Patch = 6,
925+
[Microsoft.OpenApi.Attributes.Display("trace")]
909926
Trace = 7,
910927
}
911928
public enum ParameterLocation
912929
{
930+
[Microsoft.OpenApi.Attributes.Display("query")]
913931
Query = 0,
932+
[Microsoft.OpenApi.Attributes.Display("header")]
914933
Header = 1,
934+
[Microsoft.OpenApi.Attributes.Display("path")]
915935
Path = 2,
936+
[Microsoft.OpenApi.Attributes.Display("cookie")]
916937
Cookie = 3,
917938
}
918939
public enum ParameterStyle
919940
{
941+
[Microsoft.OpenApi.Attributes.Display("matrix")]
920942
Matrix = 0,
943+
[Microsoft.OpenApi.Attributes.Display("label")]
921944
Label = 1,
945+
[Microsoft.OpenApi.Attributes.Display("form")]
922946
Form = 2,
947+
[Microsoft.OpenApi.Attributes.Display("simple")]
923948
Simple = 3,
949+
[Microsoft.OpenApi.Attributes.Display("spaceDelimited")]
924950
SpaceDelimited = 4,
951+
[Microsoft.OpenApi.Attributes.Display("pipeDelimited")]
925952
PipeDelimited = 5,
953+
[Microsoft.OpenApi.Attributes.Display("deepObject")]
926954
DeepObject = 6,
927955
}
928956
public enum ReferenceType
929957
{
958+
[Microsoft.OpenApi.Attributes.Display("schemas")]
930959
Schema = 0,
960+
[Microsoft.OpenApi.Attributes.Display("responses")]
931961
Response = 1,
962+
[Microsoft.OpenApi.Attributes.Display("parameters")]
932963
Parameter = 2,
964+
[Microsoft.OpenApi.Attributes.Display("examples")]
933965
Example = 3,
966+
[Microsoft.OpenApi.Attributes.Display("requestBodies")]
934967
RequestBody = 4,
968+
[Microsoft.OpenApi.Attributes.Display("headers")]
935969
Header = 5,
970+
[Microsoft.OpenApi.Attributes.Display("securitySchemes")]
936971
SecurityScheme = 6,
972+
[Microsoft.OpenApi.Attributes.Display("links")]
937973
Link = 7,
974+
[Microsoft.OpenApi.Attributes.Display("callbacks")]
938975
Callback = 8,
976+
[Microsoft.OpenApi.Attributes.Display("tags")]
939977
Tag = 9,
940978
}
941979
public class RuntimeExpressionAnyWrapper : Microsoft.OpenApi.Interfaces.IOpenApiElement
@@ -947,9 +985,13 @@ namespace Microsoft.OpenApi.Models
947985
}
948986
public enum SecuritySchemeType
949987
{
988+
[Microsoft.OpenApi.Attributes.Display("apiKey")]
950989
ApiKey = 0,
990+
[Microsoft.OpenApi.Attributes.Display("http")]
951991
Http = 1,
992+
[Microsoft.OpenApi.Attributes.Display("oauth2")]
952993
OAuth2 = 2,
994+
[Microsoft.OpenApi.Attributes.Display("openIdConnect")]
953995
OpenIdConnect = 3,
954996
}
955997
}

0 commit comments

Comments
 (0)