Skip to content

Commit 291d2ca

Browse files
committed
fix: marks deprecated properties from the specification as obsolete
1 parent f2b9aa5 commit 291d2ca

25 files changed

Lines changed: 51 additions & 3 deletions

src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Text.Json.Nodes;
34

45
namespace Microsoft.OpenApi;
@@ -42,6 +43,7 @@ public interface IOpenApiParameter : IOpenApiDescribedElement, IOpenApiReadOnlyE
4243
/// If style is used, and if behavior is n/a (cannot be serialized),
4344
/// the value of allowEmptyValue SHALL be ignored.
4445
/// </summary>
46+
[Obsolete("Use of AllowEmptyValue is not recommended and it is likely to be removed in a later revision.")]
4547
public bool AllowEmptyValue { get; }
4648

4749
/// <summary>

src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte
243243
/// You must use the <see cref="JsonNullSentinel.IsJsonNullSentinel(JsonNode?)"/> method to check whether Default was assigned a null value in the document.
244244
/// Assign <see cref="JsonNullSentinel.JsonNull"/> to use get null as a serialized value.
245245
/// </summary>
246+
[Obsolete("Use Examples instead.")]
246247
public JsonNode? Example { get; }
247248

248249
/// <summary>

src/Microsoft.OpenApi/Models/JsonSchemaReference.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
namespace Microsoft.OpenApi;
1010

11+
#pragma warning disable CS0618
12+
1113
/// <summary>
1214
/// Schema reference information that includes metadata annotations from JSON Schema 2020-12.
1315
/// This class extends OpenApiReference to provide schema-specific metadata override capabilities.
@@ -267,6 +269,7 @@ public string? Const
267269
/// A free-form property to include an example of an instance for this schema.
268270
/// Follow <see href="https://spec.openapis.org/oas/v3.1.1.html#schema-object">OpenAPI Schema Object definition</see>.
269271
/// </summary>
272+
[Obsolete("Use Examples instead.")]
270273
public JsonNode? Example { get; set; }
271274

272275
/// <summary>

src/Microsoft.OpenApi/Models/OpenApiParameter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace Microsoft.OpenApi
1010
{
11+
#pragma warning disable CS0618
1112
/// <summary>
1213
/// Parameter Object.
1314
/// </summary>
@@ -32,6 +33,7 @@ public class OpenApiParameter : IOpenApiExtensible, IOpenApiParameter
3233
public bool Deprecated { get; set; }
3334

3435
/// <inheritdoc/>
36+
[Obsolete("Use of AllowEmptyValue is not recommended and it is likely to be removed in a later revision.")]
3537
public bool AllowEmptyValue { get; set; }
3638

3739
/// <inheritdoc/>

src/Microsoft.OpenApi/Models/OpenApiSchema.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ public string? Minimum
251251
public OpenApiDiscriminator? Discriminator { get; set; }
252252

253253
/// <inheritdoc />
254+
[Obsolete("Use Examples instead.")]
254255
public JsonNode? Example { get; set; }
255256

256257
/// <inheritdoc />
@@ -959,7 +960,9 @@ private void SerializeAsV2(
959960
writer.WriteOptionalObject(OpenApiConstants.ExternalDocs, ExternalDocs, (w, s) => s.SerializeAsV2(w));
960961

961962
// example
963+
#pragma warning disable CS0618
962964
writer.WriteOptionalObject(OpenApiConstants.Example, Example, (w, e) => w.WriteAny(e));
965+
#pragma warning restore CS0618
963966

964967
// x-nullable extension
965968
SerializeNullable(writer, OpenApiSpecVersion.OpenApi2_0);

src/Microsoft.OpenApi/Models/OpenApiXml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class OpenApiXml : IOpenApiSerializable, IOpenApiExtensible
3030
/// Declares whether the property definition translates to an attribute instead of an element.
3131
/// Default value is false.
3232
/// </summary>
33-
[Obsolete("Use NodeType property instead. This property will be removed in a future version.")]
33+
[Obsolete("Use NodeType set to OpenApiXmlNodeType.Attribute instead. This property will be removed in a future version.")]
3434
internal bool Attribute
3535
{
3636
get
@@ -47,7 +47,7 @@ internal bool Attribute
4747
/// Signifies whether the array is wrapped.
4848
/// Default value is false.
4949
/// </summary>
50-
[Obsolete("Use NodeType property instead. This property will be removed in a future version.")]
50+
[Obsolete("Use NodeType set to OpenApiXmlNodeType.Element instead. This property will be removed in a future version.")]
5151
internal bool Wrapped
5252
{
5353
get

src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4+
using System;
45
using System.Collections.Generic;
56
using System.Text.Json.Nodes;
67

78
namespace Microsoft.OpenApi
89
{
10+
#pragma warning disable CS0618
911
/// <summary>
1012
/// Parameter Object Reference.
1113
/// </summary>
@@ -50,6 +52,7 @@ public string? Description
5052
public bool Deprecated { get => Target?.Deprecated ?? default; }
5153

5254
/// <inheritdoc/>
55+
[Obsolete("Use of AllowEmptyValue is not recommended and it is likely to be removed in a later revision.")]
5356
public bool AllowEmptyValue { get => Target?.AllowEmptyValue ?? default; }
5457

5558
/// <inheritdoc/>

src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ public bool WriteOnly
167167
/// <inheritdoc/>
168168
public OpenApiDiscriminator? Discriminator { get => Reference.Discriminator ?? Target?.Discriminator; set => Reference.Discriminator = value; }
169169
/// <inheritdoc/>
170+
[Obsolete("Use Examples instead.")]
170171
public JsonNode? Example { get => Reference.Example ?? Target?.Example; set => Reference.Example = value; }
171172
/// <inheritdoc/>
172173
public IList<JsonNode>? Examples

src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using System.Collections.Generic;
88
using System.Globalization;
99

10+
#pragma warning disable CS0618
11+
1012
namespace Microsoft.OpenApi.Reader.V2
1113
{
1214
/// <summary>

src/Microsoft.OpenApi/Reader/V2/OpenApiSchemaDeserializer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using System.Text.Json;
99
using System.Text.Json.Nodes;
1010

11+
#pragma warning disable CS0618
12+
1113
namespace Microsoft.OpenApi.Reader.V2
1214
{
1315
/// <summary>

0 commit comments

Comments
 (0)