Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Text.Json.Nodes;

namespace Microsoft.OpenApi;
Expand Down Expand Up @@ -42,6 +43,7 @@
/// If style is used, and if behavior is n/a (cannot be serialized),
/// the value of allowEmptyValue SHALL be ignored.
/// </summary>
[Obsolete("Use of AllowEmptyValue is not recommended and it is likely to be removed in a later revision.")]

Check warning on line 46 in src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET&issues=AZ-FSKMgI4bRIMOOt5sn&open=AZ-FSKMgI4bRIMOOt5sn&pullRequest=2984
public bool AllowEmptyValue { get; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
/// You must use the <see cref="JsonNullSentinel.IsJsonNullSentinel(JsonNode?)"/> method to check whether Default was assigned a null value in the document.
/// Assign <see cref="JsonNullSentinel.JsonNull"/> to use get null as a serialized value.
/// </summary>
[Obsolete("Use Examples instead.")]

Check warning on line 246 in src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET&issues=AZ-FSKT7I4bRIMOOt5so&open=AZ-FSKT7I4bRIMOOt5so&pullRequest=2984
public JsonNode? Example { get; }

/// <summary>
Expand All @@ -265,7 +266,7 @@
/// <remarks>
/// NOTE: This property differs from the naming pattern of AdditionalPropertiesAllowed for binary compatibility reasons.
/// In the next major version, this will be renamed to UnevaluatedPropertiesAllowed.
/// TODO: Rename to UnevaluatedPropertiesAllowed in the next major version.

Check warning on line 269 in src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment.
/// </remarks>
public bool UnevaluatedProperties { get; }

Expand Down
3 changes: 3 additions & 0 deletions src/Microsoft.OpenApi/Models/JsonSchemaReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace Microsoft.OpenApi;

#pragma warning disable CS0618

/// <summary>
/// Schema reference information that includes metadata annotations from JSON Schema 2020-12.
/// This class extends OpenApiReference to provide schema-specific metadata override capabilities.
Expand Down Expand Up @@ -267,6 +269,7 @@
/// A free-form property to include an example of an instance for this schema.
/// Follow <see href="https://spec.openapis.org/oas/v3.1.1.html#schema-object">OpenAPI Schema Object definition</see>.
/// </summary>
[Obsolete("Use Examples instead.")]

Check warning on line 272 in src/Microsoft.OpenApi/Models/JsonSchemaReference.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET&issues=AZ-FSKVHI4bRIMOOt5sr&open=AZ-FSKVHI4bRIMOOt5sr&pullRequest=2984
public JsonNode? Example { get; set; }

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.OpenApi/Models/OpenApiParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Microsoft.OpenApi
{
#pragma warning disable CS0618
/// <summary>
/// Parameter Object.
/// </summary>
Expand All @@ -32,6 +33,7 @@
public bool Deprecated { get; set; }

/// <inheritdoc/>
[Obsolete("Use of AllowEmptyValue is not recommended and it is likely to be removed in a later revision.")]

Check warning on line 36 in src/Microsoft.OpenApi/Models/OpenApiParameter.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET&issues=AZ-FSKXJI4bRIMOOt5st&open=AZ-FSKXJI4bRIMOOt5st&pullRequest=2984
public bool AllowEmptyValue { get; set; }

/// <inheritdoc/>
Expand Down
8 changes: 8 additions & 0 deletions src/Microsoft.OpenApi/Models/OpenApiSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
public OpenApiDiscriminator? Discriminator { get; set; }

/// <inheritdoc />
[Obsolete("Use Examples instead.")]

Check warning on line 254 in src/Microsoft.OpenApi/Models/OpenApiSchema.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET&issues=AZ-FSKWHI4bRIMOOt5ss&open=AZ-FSKWHI4bRIMOOt5ss&pullRequest=2984
public JsonNode? Example { get; set; }

/// <inheritdoc />
Expand Down Expand Up @@ -958,7 +959,10 @@
writer.WriteOptionalObject(OpenApiConstants.ExternalDocs, ExternalDocs, (w, s) => s.SerializeAsV2(w));

// example
#pragma warning disable CS0618
writer.WriteOptionalObject(OpenApiConstants.Example, GetCompatibilityExample(), (w, e) => w.WriteAny(e));
writer.WriteOptionalObject(OpenApiConstants.Example, Example, (w, e) => w.WriteAny(e));
#pragma warning restore CS0618

// x-nullable extension
SerializeNullable(writer, OpenApiSpecVersion.OpenApi2_0);
Expand Down Expand Up @@ -1027,7 +1031,9 @@

private JsonNode? GetCompatibilityExample()
{
#pragma warning disable CS0618 // Type or member is obsolete
return Example ?? Examples?.FirstOrDefault();
#pragma warning restore CS0618 // Type or member is obsolete
}

private IEnumerable<JsonNode>? GetCompatibilityExamplesExtension()
Expand All @@ -1037,10 +1043,12 @@
return null;
}

#pragma warning disable CS0618 // Type or member is obsolete
if (Example is not null)
{
return Examples;
}
#pragma warning restore CS0618 // Type or member is obsolete

return Examples.Count > 1 ? Examples.Skip(1) : null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
using System.Collections.Generic;
using System.Text.Json.Nodes;

namespace Microsoft.OpenApi
{
#pragma warning disable CS0618
/// <summary>
/// Parameter Object Reference.
/// </summary>
Expand Down Expand Up @@ -50,6 +52,7 @@
public bool Deprecated { get => Target?.Deprecated ?? default; }

/// <inheritdoc/>
[Obsolete("Use of AllowEmptyValue is not recommended and it is likely to be removed in a later revision.")]

Check warning on line 55 in src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET&issues=AZ-FSKUVI4bRIMOOt5sp&open=AZ-FSKUVI4bRIMOOt5sp&pullRequest=2984
public bool AllowEmptyValue { get => Target?.AllowEmptyValue ?? default; }

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
/// <inheritdoc/>
public OpenApiDiscriminator? Discriminator { get => Reference.Discriminator ?? Target?.Discriminator; set => Reference.Discriminator = value; }
/// <inheritdoc/>
[Obsolete("Use Examples instead.")]

Check warning on line 170 in src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET&issues=AZ-FSKUuI4bRIMOOt5sq&open=AZ-FSKUuI4bRIMOOt5sq&pullRequest=2984
public JsonNode? Example { get => Reference.Example ?? Target?.Example; set => Reference.Example = value; }
/// <inheritdoc/>
public IList<JsonNode>? Examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using System.Collections.Generic;
using System.Globalization;

#pragma warning disable CS0618

namespace Microsoft.OpenApi.Reader.V2
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using System.Text.Json;
using System.Text.Json.Nodes;

#pragma warning disable CS0618

namespace Microsoft.OpenApi.Reader.V2
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

using System;

#pragma warning disable CS0618

namespace Microsoft.OpenApi.Reader.V3
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using System.Text.Json;
using System.Text.Json.Nodes;

#pragma warning disable CS0618

namespace Microsoft.OpenApi.Reader.V3
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Text.Json.Nodes;

#pragma warning disable CS0618

namespace Microsoft.OpenApi.Reader.V31
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using System.Text.Json;
using System.Text.Json.Nodes;

#pragma warning disable CS0618

namespace Microsoft.OpenApi.Reader.V31;

internal static partial class OpenApiV31Deserializer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Microsoft.OpenApi
{
#pragma warning disable CS0618
/// <summary>
/// Defines a non-default set of rules for validating examples in header, media type and parameter objects against the schema
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using Microsoft.OpenApi.Tests;
using Xunit;

#pragma warning disable CS0618

namespace Microsoft.OpenApi.Readers.Tests.V2Tests
{
[Collection("DefaultSettings")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using System;
using System.Net.Http;

#pragma warning disable CS0618

namespace Microsoft.OpenApi.Readers.Tests.V31Tests
{
public class OpenApiDocumentTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
using Microsoft.OpenApi.Tests;
using Xunit;

#pragma warning disable CS0618

namespace Microsoft.OpenApi.Readers.Tests.V31Tests
{
public class OpenApiSchemaTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
using SharpYaml.Serialization;
using Xunit;

#pragma warning disable CS0618

namespace Microsoft.OpenApi.Readers.Tests.V3Tests
{
[Collection("DefaultSettings")]
Expand Down
6 changes: 6 additions & 0 deletions test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ public static TheoryData<JsonNode> SchemaExamples()

[Theory]
[MemberData(nameof(SchemaExamples))]
#pragma warning disable CS0618
public void CloningSchemaExamplesWorks(JsonNode example)
{
// Arrange
Expand All @@ -638,6 +639,7 @@ public void CloningSchemaExamplesWorks(JsonNode example)
.IgnoringCyclicReferences()
.Excluding(x => x.Options));
}
#pragma warning restore CS0618

[Fact]
public void CloningSchemaExtensionsWorks()
Expand Down Expand Up @@ -1938,7 +1940,9 @@ public void DeserializeExamplesExtensionInV2AssignsExamplesProperty()

Assert.Empty(readResult.Diagnostic.Errors);
var schema = readResult.Document.Components.Schemas["TestSchema"];
#pragma warning disable CS0618 // Type or member is obsolete
Assert.Equal("primary example", schema.Example?.GetValue<string>());
#pragma warning restore CS0618 // Type or member is obsolete
Assert.NotNull(schema.Examples);
Assert.Collection(
schema.Examples,
Expand Down Expand Up @@ -1974,7 +1978,9 @@ public void DeserializeExamplesExtensionInV3AssignsExamplesProperty()

Assert.Empty(readResult.Diagnostic.Errors);
var schema = readResult.Document.Components.Schemas["TestSchema"];
#pragma warning disable CS0618 // Type or member is obsolete
Assert.Equal("primary example", schema.Example?.GetValue<string>());
#pragma warning restore CS0618 // Type or member is obsolete
Assert.NotNull(schema.Examples);
Assert.Collection(
schema.Examples,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForSimpleSchema()
}

[Fact]
#pragma warning disable CS0618
public void ValidateExampleAndDefaultShouldNotHaveDataTypeMismatchForSimpleSchema()
{
// Arrange
Expand All @@ -58,6 +59,7 @@ public void ValidateExampleAndDefaultShouldNotHaveDataTypeMismatchForSimpleSchem
// Assert
Assert.True(result);
}
#pragma warning restore CS0618

[Fact]
public void ValidateEnumShouldNotHaveDataTypeMismatchForSimpleSchema()
Expand Down
Loading