Skip to content

Commit ea6f93e

Browse files
Merge pull request #909 from fernandolamp/enhancement/fgd/changeDisplayAttributeToPublic
feat: change DisplayAttribute to public
2 parents a4ea02f + b0141b0 commit ea6f93e

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
@@ -129,6 +129,15 @@ namespace Microsoft.OpenApi.Any
129129
Password = 10,
130130
}
131131
}
132+
namespace Microsoft.OpenApi.Attributes
133+
{
134+
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field)]
135+
public class DisplayAttribute : System.Attribute
136+
{
137+
public DisplayAttribute(string name) { }
138+
public string Name { get; }
139+
}
140+
}
132141
namespace Microsoft.OpenApi.Exceptions
133142
{
134143
public class OpenApiException : System.Exception
@@ -938,43 +947,72 @@ namespace Microsoft.OpenApi.Models
938947
}
939948
public enum OperationType
940949
{
950+
[Microsoft.OpenApi.Attributes.Display("get")]
941951
Get = 0,
952+
[Microsoft.OpenApi.Attributes.Display("put")]
942953
Put = 1,
954+
[Microsoft.OpenApi.Attributes.Display("post")]
943955
Post = 2,
956+
[Microsoft.OpenApi.Attributes.Display("delete")]
944957
Delete = 3,
958+
[Microsoft.OpenApi.Attributes.Display("options")]
945959
Options = 4,
960+
[Microsoft.OpenApi.Attributes.Display("head")]
946961
Head = 5,
962+
[Microsoft.OpenApi.Attributes.Display("patch")]
947963
Patch = 6,
964+
[Microsoft.OpenApi.Attributes.Display("trace")]
948965
Trace = 7,
949966
}
950967
public enum ParameterLocation
951968
{
969+
[Microsoft.OpenApi.Attributes.Display("query")]
952970
Query = 0,
971+
[Microsoft.OpenApi.Attributes.Display("header")]
953972
Header = 1,
973+
[Microsoft.OpenApi.Attributes.Display("path")]
954974
Path = 2,
975+
[Microsoft.OpenApi.Attributes.Display("cookie")]
955976
Cookie = 3,
956977
}
957978
public enum ParameterStyle
958979
{
980+
[Microsoft.OpenApi.Attributes.Display("matrix")]
959981
Matrix = 0,
982+
[Microsoft.OpenApi.Attributes.Display("label")]
960983
Label = 1,
984+
[Microsoft.OpenApi.Attributes.Display("form")]
961985
Form = 2,
986+
[Microsoft.OpenApi.Attributes.Display("simple")]
962987
Simple = 3,
988+
[Microsoft.OpenApi.Attributes.Display("spaceDelimited")]
963989
SpaceDelimited = 4,
990+
[Microsoft.OpenApi.Attributes.Display("pipeDelimited")]
964991
PipeDelimited = 5,
992+
[Microsoft.OpenApi.Attributes.Display("deepObject")]
965993
DeepObject = 6,
966994
}
967995
public enum ReferenceType
968996
{
997+
[Microsoft.OpenApi.Attributes.Display("schemas")]
969998
Schema = 0,
999+
[Microsoft.OpenApi.Attributes.Display("responses")]
9701000
Response = 1,
1001+
[Microsoft.OpenApi.Attributes.Display("parameters")]
9711002
Parameter = 2,
1003+
[Microsoft.OpenApi.Attributes.Display("examples")]
9721004
Example = 3,
1005+
[Microsoft.OpenApi.Attributes.Display("requestBodies")]
9731006
RequestBody = 4,
1007+
[Microsoft.OpenApi.Attributes.Display("headers")]
9741008
Header = 5,
1009+
[Microsoft.OpenApi.Attributes.Display("securitySchemes")]
9751010
SecurityScheme = 6,
1011+
[Microsoft.OpenApi.Attributes.Display("links")]
9761012
Link = 7,
1013+
[Microsoft.OpenApi.Attributes.Display("callbacks")]
9771014
Callback = 8,
1015+
[Microsoft.OpenApi.Attributes.Display("tags")]
9781016
Tag = 9,
9791017
}
9801018
public class RuntimeExpressionAnyWrapper : Microsoft.OpenApi.Interfaces.IOpenApiElement
@@ -987,9 +1025,13 @@ namespace Microsoft.OpenApi.Models
9871025
}
9881026
public enum SecuritySchemeType
9891027
{
1028+
[Microsoft.OpenApi.Attributes.Display("apiKey")]
9901029
ApiKey = 0,
1030+
[Microsoft.OpenApi.Attributes.Display("http")]
9911031
Http = 1,
1032+
[Microsoft.OpenApi.Attributes.Display("oauth2")]
9921033
OAuth2 = 2,
1034+
[Microsoft.OpenApi.Attributes.Display("openIdConnect")]
9931035
OpenIdConnect = 3,
9941036
}
9951037
}

0 commit comments

Comments
 (0)