Skip to content

Commit 27bf18f

Browse files
Merge pull request #2338 from microsoft/chore/rename-openApiAny
chore: rename OpenApiAny to JsonNodeExtension
2 parents 40e2681 + 5c40b33 commit 27bf18f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+137
-175
lines changed

docs/upgrade-guide-2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ var openApiObject = new OpenApiObject
203203
}
204204
};
205205
var parameter = new OpenApiParameter();
206-
parameter.Extensions.Add("x-foo", new OpenApiAny(openApiObject));
206+
parameter.Extensions.Add("x-foo", openApiObject);
207207

208208
```
209209

@@ -223,7 +223,7 @@ var openApiObject = new JsonObject
223223
}
224224
};
225225
var parameter = new OpenApiParameter();
226-
parameter.Extensions.Add("x-foo", new OpenApiAny(openApiObject));
226+
parameter.Extensions.Add("x-foo", new JsonNodeExtension(openApiObject));
227227

228228
```
229229

src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.OpenApi.Any;
1+
using Microsoft.OpenApi.Extensions;
22
using Microsoft.OpenApi.Interfaces;
33
using System.Collections.Generic;
44
using System.Text.Json.Nodes;
@@ -15,7 +15,7 @@ internal static class OpenApiExtensibleExtensions
1515
/// <returns>A <see cref="string"/> value matching the provided extensionKey. Return null when extensionKey is not found. </returns>
1616
internal static string GetExtension(this Dictionary<string, IOpenApiExtension> extensions, string extensionKey)
1717
{
18-
if (extensions.TryGetValue(extensionKey, out var value) && value is OpenApiAny { Node: JsonValue castValue } && castValue.TryGetValue<string>(out var stringValue))
18+
if (extensions.TryGetValue(extensionKey, out var value) && value is JsonNodeExtension { Node: JsonValue castValue } && castValue.TryGetValue<string>(out var stringValue))
1919
{
2020
return stringValue;
2121
}

src/Microsoft.OpenApi/Any/OpenApiAny.cs renamed to src/Microsoft.OpenApi/Extensions/JsonNodeExtension.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
using Microsoft.OpenApi.Interfaces;
66
using Microsoft.OpenApi.Writers;
77

8-
namespace Microsoft.OpenApi.Any
8+
namespace Microsoft.OpenApi.Extensions
99
{
1010
/// <summary>
1111
/// A wrapper class for JsonNode
1212
/// </summary>
13-
public class OpenApiAny : IOpenApiElement, IOpenApiExtension
13+
public class JsonNodeExtension : IOpenApiElement, IOpenApiExtension
1414
{
1515
private readonly JsonNode jsonNode;
1616

1717
/// <summary>
18-
/// Initializes the <see cref="OpenApiAny"/> class.
18+
/// Initializes the <see cref="JsonNodeExtension"/> class.
1919
/// </summary>
2020
/// <param name="jsonNode"></param>
21-
public OpenApiAny(JsonNode jsonNode)
21+
public JsonNodeExtension(JsonNode jsonNode)
2222
{
2323
this.jsonNode = jsonNode;
2424
}
@@ -29,7 +29,7 @@ public OpenApiAny(JsonNode jsonNode)
2929
public JsonNode Node { get { return jsonNode; } }
3030

3131
/// <summary>
32-
/// Writes out the OpenApiAny type.
32+
/// Writes out the JsonNodeExtension type.
3333
/// </summary>
3434
/// <param name="writer"></param>
3535
/// <param name="specVersion"></param>

src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiDeprecationExtension.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
using System;
77
using Microsoft.OpenApi.Extensions;
8-
using Microsoft.OpenApi.Any;
98
using Microsoft.OpenApi.Interfaces;
109
using Microsoft.OpenApi.Writers;
1110
using System.Text.Json.Nodes;
@@ -103,7 +102,7 @@ jsonNode is not JsonValue jsonValue ||
103102
return null;
104103
}
105104
/// <summary>
106-
/// Parses the <see cref="OpenApiAny"/> to <see cref="OpenApiDeprecationExtension"/>.
105+
/// Parses the <see cref="JsonNodeExtension"/> to <see cref="OpenApiDeprecationExtension"/>.
107106
/// </summary>
108107
/// <param name="source">The source object.</param>
109108
/// <returns>The <see cref="OpenApiDeprecationExtension"/>.</returns>

src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs

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

66
using System;
77
using System.Text.Json.Nodes;
8-
using Microsoft.OpenApi.Any;
8+
using Microsoft.OpenApi.Extensions;
99
using Microsoft.OpenApi.Interfaces;
1010
using Microsoft.OpenApi.Writers;
1111

@@ -34,7 +34,7 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
3434
public bool IsPrimaryErrorMessage { get; set; }
3535

3636
/// <summary>
37-
/// Parses the <see cref="OpenApiAny"/> to <see cref="OpenApiPrimaryErrorMessageExtension"/>.
37+
/// Parses the <see cref="JsonNodeExtension"/> to <see cref="OpenApiPrimaryErrorMessageExtension"/>.
3838
/// </summary>
3939
/// <param name="source">The source object.</param>
4040
/// <returns>The <see cref="OpenApiPrimaryErrorMessageExtension"/>.</returns>

src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiReservedParameterExtension.cs

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

66
using System;
77
using System.Text.Json.Nodes;
8-
using Microsoft.OpenApi.Any;
8+
using Microsoft.OpenApi.Extensions;
99
using Microsoft.OpenApi.Interfaces;
1010
using Microsoft.OpenApi.Writers;
1111

@@ -35,7 +35,7 @@ public bool? IsReserved
3535
get; set;
3636
}
3737
/// <summary>
38-
/// Parses the <see cref="OpenApiAny"/> to <see cref="OpenApiReservedParameterExtension"/>.
38+
/// Parses the <see cref="JsonNodeExtension"/> to <see cref="OpenApiReservedParameterExtension"/>.
3939
/// </summary>
4040
/// <param name="source">The source object.</param>
4141
/// <returns>The <see cref="OpenApiReservedParameterExtension"/>.</returns>

src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Linq;
7-
using Microsoft.OpenApi.Any;
87
using Microsoft.OpenApi.Extensions;
98
using Microsoft.OpenApi.Interfaces;
109
using Microsoft.OpenApi.Models.Interfaces;
@@ -110,7 +109,7 @@ public IOpenApiParameter ConvertToBodyParameter(IOpenApiWriter writer)
110109
// Clone extensions so we can remove the x-bodyName extensions from the output V2 model.
111110
if (bodyParameter.Extensions is not null &&
112111
bodyParameter.Extensions.TryGetValue(OpenApiConstants.BodyName, out var bodyNameExtension) &&
113-
bodyNameExtension is OpenApiAny bodyName)
112+
bodyNameExtension is JsonNodeExtension bodyName)
114113
{
115114
bodyParameter.Name = string.IsNullOrEmpty(bodyName.Node.ToString()) ? "body" : bodyName.Node.ToString();
116115
bodyParameter.Extensions.Remove(OpenApiConstants.BodyName);

src/Microsoft.OpenApi/Models/OpenApiSchema.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Linq;
77
using System.Text.Json;
88
using System.Text.Json.Nodes;
9-
using Microsoft.OpenApi.Any;
109
using Microsoft.OpenApi.Extensions;
1110
using Microsoft.OpenApi.Helpers;
1211
using Microsoft.OpenApi.Interfaces;
@@ -755,7 +754,7 @@ private void SerializeTypeProperty(JsonSchemaType? type, IOpenApiWriter writer,
755754
var isNullable = (Type.HasValue && Type.Value.HasFlag(JsonSchemaType.Null)) ||
756755
Extensions is not null &&
757756
Extensions.TryGetValue(OpenApiConstants.NullableExtension, out var nullExtRawValue) &&
758-
nullExtRawValue is OpenApiAny { Node: JsonNode jsonNode } &&
757+
nullExtRawValue is JsonNodeExtension { Node: JsonNode jsonNode } &&
759758
jsonNode.GetValueKind() is JsonValueKind.True;
760759
if (type is null)
761760
{

src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public AnyMapFieldMapParameter(
2727
}
2828

2929
/// <summary>
30-
/// Function to retrieve the property that is a map from string to an inner element containing IOpenApiAny.
30+
/// Function to retrieve the property that is a map from string to an inner element.
3131
/// </summary>
3232
public Func<T, Dictionary<string, U>?> PropertyMapGetter { get; }
3333

src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
using System.Text.Json;
1010
using System.Text.Json.Nodes;
1111
using System.Text.Json.Serialization;
12-
using Microsoft.OpenApi.Any;
1312
using Microsoft.OpenApi.Exceptions;
13+
using Microsoft.OpenApi.Extensions;
1414
using Microsoft.OpenApi.Models;
1515

1616
namespace Microsoft.OpenApi.Reader.ParseNodes
@@ -191,7 +191,7 @@ public override string GetRaw()
191191
}
192192

193193
/// <summary>
194-
/// Create an <see cref="OpenApiAny"/>
194+
/// Create an <see cref="JsonNodeExtension"/>
195195
/// </summary>
196196
/// <returns>The created Json object.</returns>
197197
public override JsonNode CreateAny()

0 commit comments

Comments
 (0)