Skip to content

Commit e366101

Browse files
authored
Deprecated feature implementation (Azure#329)
1 parent fa5b175 commit e366101

File tree

8 files changed

+27
-3
lines changed

8 files changed

+27
-3
lines changed

src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Attributes/OpenApiPropertyAttribute.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,10 @@ public class OpenApiPropertyAttribute : Attribute
2323
/// Gets or sets the description.
2424
/// </summary>
2525
public virtual string Description { get; set; }
26+
27+
/// <summary>
28+
/// Gets or sets the deprecated flag.
29+
/// </summary>
30+
public virtual bool Deprecated { get; set; }
2631
}
2732
}

src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int16EnumTypeVisitor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type,
6767
schema.Nullable = this.GetOpenApiPropertyNullable(attr as OpenApiPropertyAttribute);
6868
schema.Default = this.GetOpenApiPropertyDefault<short>(attr as OpenApiPropertyAttribute);
6969
schema.Description = this.GetOpenApiPropertyDescription(attr as OpenApiPropertyAttribute);
70+
schema.Deprecated = this.GetOpenApiPropertyDeprecated(attr as OpenApiPropertyAttribute);
7071
}
7172

7273
attr = attributes.OfType<OpenApiSchemaVisibilityAttribute>().SingleOrDefault();

src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int32EnumTypeVisitor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type,
6767
schema.Nullable = this.GetOpenApiPropertyNullable(attr as OpenApiPropertyAttribute);
6868
schema.Default = this.GetOpenApiPropertyDefault<int>(attr as OpenApiPropertyAttribute);
6969
schema.Description = this.GetOpenApiPropertyDescription(attr as OpenApiPropertyAttribute);
70+
schema.Deprecated = this.GetOpenApiPropertyDeprecated(attr as OpenApiPropertyAttribute);
7071
}
7172

7273
attr = attributes.OfType<OpenApiSchemaVisibilityAttribute>().SingleOrDefault();

src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int64EnumTypeVisitor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type,
6767
schema.Nullable = this.GetOpenApiPropertyNullable(attr as OpenApiPropertyAttribute);
6868
schema.Default = this.GetOpenApiPropertyDefault<long>(attr as OpenApiPropertyAttribute);
6969
schema.Description = this.GetOpenApiPropertyDescription(attr as OpenApiPropertyAttribute);
70+
schema.Deprecated = this.GetOpenApiPropertyDeprecated(attr as OpenApiPropertyAttribute);
7071
}
7172

7273
attr = attributes.OfType<OpenApiSchemaVisibilityAttribute>().SingleOrDefault();

src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/NullableObjectTypeVisitor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type,
7171
schema.Nullable = this.GetOpenApiPropertyNullable(attr as OpenApiPropertyAttribute);
7272
schema.Default = this.GetOpenApiPropertyDefault(attr as OpenApiPropertyAttribute);
7373
schema.Description = this.GetOpenApiPropertyDescription(attr as OpenApiPropertyAttribute);
74+
schema.Deprecated = this.GetOpenApiPropertyDeprecated(attr as OpenApiPropertyAttribute);
7475
}
7576

7677
attr = attributes.OfType<OpenApiSchemaVisibilityAttribute>().SingleOrDefault();

src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/StringEnumTypeVisitor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type,
6666
schema.Nullable = this.GetOpenApiPropertyNullable(attr as OpenApiPropertyAttribute);
6767
schema.Default = this.GetOpenApiPropertyDefault<string>(attr as OpenApiPropertyAttribute);
6868
schema.Description = this.GetOpenApiPropertyDescription(attr as OpenApiPropertyAttribute);
69+
schema.Deprecated = this.GetOpenApiPropertyDeprecated(attr as OpenApiPropertyAttribute);
6970
}
7071

7172
attr = attributes.OfType<OpenApiSchemaVisibilityAttribute>().SingleOrDefault();

src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/TypeVisitor.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ protected string Visit(IAcceptor acceptor, string name, string title, string dat
152152
schema.Default = this.GetOpenApiPropertyDefault(attr as OpenApiPropertyAttribute);
153153
}
154154
schema.Description = this.GetOpenApiPropertyDescription(attr as OpenApiPropertyAttribute);
155+
schema.Deprecated = this.GetOpenApiPropertyDeprecated(attr as OpenApiPropertyAttribute);
155156
}
156157

157158
attr = attributes.OfType<OpenApiSchemaVisibilityAttribute>().SingleOrDefault();
@@ -368,5 +369,16 @@ protected string GetOpenApiPropertyDescription(OpenApiPropertyAttribute attr)
368369
{
369370
return attr.Description;
370371
}
372+
373+
374+
/// <summary>
375+
/// Gets the property deprecated.
376+
/// </summary>
377+
/// <param name="attr"><see cref="OpenApiPropertyAttribute"/> instance.</param>
378+
/// <returns>Returns the property deprecated.</returns>
379+
protected bool GetOpenApiPropertyDeprecated(OpenApiPropertyAttribute attr)
380+
{
381+
return attr.Deprecated;
382+
}
371383
}
372384
}

test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Attributes/OpenApiPropertyAttributeTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@ namespace Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Attributes
99
public class OpenApiPropertyAttributeTests
1010
{
1111
[DataTestMethod]
12-
[DataRow(true, 1, "hello world")]
13-
public void Given_Value_Property_Should_Return_Value(bool nullable, object @default, string description)
12+
[DataRow(true, 1, "hello world", false)]
13+
public void Given_Value_Property_Should_Return_Value(bool nullable, object @default, string description, bool deprecated)
1414
{
1515
var attribute = new OpenApiPropertyAttribute()
1616
{
1717
Nullable = nullable,
1818
Default = @default,
19-
Description = description
19+
Description = description,
20+
Deprecated = deprecated
2021
};
2122

2223
attribute.Nullable.Should().Be(nullable);
2324
attribute.Default.Should().Be(@default);
2425
attribute.Description.Should().Be(description);
26+
attribute.Deprecated.Should().Be(deprecated);
2527
}
2628
}
2729
}

0 commit comments

Comments
 (0)