Skip to content

Commit abc5301

Browse files
committed
fix: marks deprecated properties from the specification as obsolete
chore: adds missing suppressions due to merge Signed-off-by: Vincent Biret <vibiret@microsoft.com>
1 parent 8f5bd7e commit abc5301

20 files changed

Lines changed: 50 additions & 1 deletion

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: 8 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 />
@@ -958,7 +959,10 @@ private void SerializeAsV2(
958959
writer.WriteOptionalObject(OpenApiConstants.ExternalDocs, ExternalDocs, (w, s) => s.SerializeAsV2(w));
959960

960961
// example
962+
#pragma warning disable CS0618
961963
writer.WriteOptionalObject(OpenApiConstants.Example, GetCompatibilityExample(), (w, e) => w.WriteAny(e));
964+
writer.WriteOptionalObject(OpenApiConstants.Example, Example, (w, e) => w.WriteAny(e));
965+
#pragma warning restore CS0618
962966

963967
// x-nullable extension
964968
SerializeNullable(writer, OpenApiSpecVersion.OpenApi2_0);
@@ -1027,7 +1031,9 @@ private bool TrySerializeTypeProperty(IOpenApiWriter writer, OpenApiSpecVersion
10271031

10281032
private JsonNode? GetCompatibilityExample()
10291033
{
1034+
#pragma warning disable CS0618 // Type or member is obsolete
10301035
return Example ?? Examples?.FirstOrDefault();
1036+
#pragma warning restore CS0618 // Type or member is obsolete
10311037
}
10321038

10331039
private IEnumerable<JsonNode>? GetCompatibilityExamplesExtension()
@@ -1037,10 +1043,12 @@ private bool TrySerializeTypeProperty(IOpenApiWriter writer, OpenApiSpecVersion
10371043
return null;
10381044
}
10391045

1046+
#pragma warning disable CS0618 // Type or member is obsolete
10401047
if (Example is not null)
10411048
{
10421049
return Examples;
10431050
}
1051+
#pragma warning restore CS0618 // Type or member is obsolete
10441052

10451053
return Examples.Count > 1 ? Examples.Skip(1) : null;
10461054
}

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>

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

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

66
using System;
77

8+
#pragma warning disable CS0618
9+
810
namespace Microsoft.OpenApi.Reader.V3
911
{
1012
/// <summary>

0 commit comments

Comments
 (0)