Skip to content

Commit 08cc754

Browse files
committed
chore: merge main into current branch
2 parents 796d49c + b4877f6 commit 08cc754

26 files changed

+152
-56
lines changed

src/Microsoft.OpenApi.Hidi/OpenApiService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,10 @@ private static async Task<ReadResult> ParseOpenApiAsync(string openApiFile, bool
438438
var sb = new StringBuilder();
439439
document.SerializeAsV3(new OpenApiYamlWriter(new StringWriter(sb)));
440440

441-
var doc = OpenApiDocument.Parse(sb.ToString(), format).Document;
441+
var settings = new OpenApiReaderSettings();
442+
settings.AddYamlReader();
443+
444+
var doc = OpenApiDocument.Parse(sb.ToString(), format, settings).Document;
442445

443446
return doc;
444447
}

src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs

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

4-
#nullable enable
5-
64
// This collection of attribute definitions are helpers for accessing trim-related attributes in
75
// projects targeting .NET 6 or lower. Since the trimmer queries for these attributes by name, having
86
// these attributes source included is sufficient for the trimmer to recognize them. For more information

src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ namespace Microsoft.OpenApi.Extensions
1414
/// </summary>
1515
public static class OpenApiTypeMapper
1616
{
17-
#nullable enable
1817
/// <summary>
1918
/// Maps a JsonSchema data type to an identifier.
2019
/// </summary>
@@ -75,8 +74,6 @@ internal static string ToSingleIdentifier(this JsonSchemaType schemaType)
7574
return schemaType.ToIdentifiersInternal().Single();
7675
}
7776

78-
#nullable restore
79-
8077
/// <summary>
8178
/// Converts a schema type's identifier into the enum equivalent
8279
/// </summary>

src/Microsoft.OpenApi/Models/OpenApiComponents.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
using Microsoft.OpenApi.Models.References;
1010
using Microsoft.OpenApi.Writers;
1111

12-
#nullable enable
13-
1412
namespace Microsoft.OpenApi.Models
1513
{
1614
/// <summary>

src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System.Collections.Generic;
55
using Microsoft.OpenApi.Interfaces;
6+
using Microsoft.OpenApi.Models.References;
67
using Microsoft.OpenApi.Writers;
78

89
namespace Microsoft.OpenApi.Models
@@ -20,7 +21,7 @@ public class OpenApiDiscriminator : IOpenApiSerializable, IOpenApiExtensible
2021
/// <summary>
2122
/// An object to hold mappings between payload values and schema names or references.
2223
/// </summary>
23-
public IDictionary<string, string>? Mapping { get; set; } = new Dictionary<string, string>();
24+
public IDictionary<string, OpenApiSchemaReference>? Mapping { get; set; } = new Dictionary<string, OpenApiSchemaReference>();
2425

2526
/// <summary>
2627
/// This object MAY be extended with Specification Extensions.
@@ -38,7 +39,7 @@ public OpenApiDiscriminator() { }
3839
public OpenApiDiscriminator(OpenApiDiscriminator discriminator)
3940
{
4041
PropertyName = discriminator?.PropertyName ?? PropertyName;
41-
Mapping = discriminator?.Mapping != null ? new Dictionary<string, string>(discriminator.Mapping) : null;
42+
Mapping = discriminator?.Mapping != null ? new Dictionary<string, OpenApiSchemaReference>(discriminator.Mapping) : null;
4243
Extensions = discriminator?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(discriminator.Extensions) : null;
4344
}
4445

@@ -80,7 +81,13 @@ private void SerializeInternal(IOpenApiWriter writer)
8081
writer.WriteProperty(OpenApiConstants.PropertyName, PropertyName);
8182

8283
// mapping
83-
writer.WriteOptionalMap(OpenApiConstants.Mapping, Mapping, (w, s) => w.WriteValue(s));
84+
writer.WriteOptionalMap(OpenApiConstants.Mapping, Mapping, (w, s) =>
85+
{
86+
if (!string.IsNullOrEmpty(s.Reference.ReferenceV3) && s.Reference.ReferenceV3 is not null)
87+
{
88+
w.WriteValue(s.Reference.ReferenceV3);
89+
}
90+
});
8491
}
8592

8693
/// <summary>

src/Microsoft.OpenApi/Models/OpenApiDocument.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
using Microsoft.OpenApi.Services;
1818
using Microsoft.OpenApi.Writers;
1919

20-
#nullable enable
21-
2220
namespace Microsoft.OpenApi.Models
2321
{
2422
/// <summary>

src/Microsoft.OpenApi/Models/OpenApiMediaType.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
using Microsoft.OpenApi.Models.Interfaces;
1111
using Microsoft.OpenApi.Writers;
1212

13-
#nullable enable
14-
1513
namespace Microsoft.OpenApi.Models
1614
{
1715
/// <summary>

src/Microsoft.OpenApi/Models/OpenApiOperation.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
using Microsoft.OpenApi.Models.References;
1010
using Microsoft.OpenApi.Writers;
1111

12-
#nullable enable
13-
1412
namespace Microsoft.OpenApi.Models
1513
{
1614
/// <summary>

src/Microsoft.OpenApi/Models/OpenApiReference.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,8 @@ internal void EnsureHostDocumentIsSet(OpenApiDocument currentDocument)
281281
Utils.CheckArgumentNull(currentDocument);
282282
hostDocument ??= currentDocument;
283283
}
284-
#nullable enable
285284
private static string? GetPropertyValueFromNode(JsonObject jsonObject, string key) =>
286285
jsonObject.TryGetPropertyValue(key, out var valueNode) && valueNode is JsonValue valueCast && valueCast.TryGetValue<string>(out var strValue) ? strValue : null;
287-
#nullable restore
288286
internal void SetSummaryAndDescriptionFromMapNode(MapNode mapNode)
289287
{
290288
var (description, summary) = mapNode.JsonNode switch {

src/Microsoft.OpenApi/OpenApiTagComparer.cs

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

55
namespace Microsoft.OpenApi;
66

7-
#nullable enable
87
/// <summary>
98
/// This comparer is used to maintain a globally unique list of tags encountered
109
/// in a particular OpenAPI document.
@@ -44,4 +43,3 @@ public bool Equals(IOpenApiTag? x, IOpenApiTag? y)
4443
/// <inheritdoc/>
4544
public int GetHashCode(IOpenApiTag obj) => string.IsNullOrEmpty(obj?.Name) ? 0 : StringComparer.GetHashCode(obj!.Name);
4645
}
47-
#nullable restore

0 commit comments

Comments
 (0)