Skip to content

Commit 75f21b4

Browse files
Merge branch 'main' into fix/revert-to-IDictionary-and-allow-sorting
2 parents b7eeadd + 80f6993 commit 75f21b4

File tree

7 files changed

+270
-134
lines changed

7 files changed

+270
-134
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.0.0-preview.20"
2+
".": "2.0.0-preview.21"
33
}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## [2.0.0-preview.21](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.20...v2.0.0-preview.21) (2025-05-21)
4+
5+
6+
### Bug Fixes
7+
8+
* do not throw when operation tag is missing matching global tag ([fe133f2](https://github.com/microsoft/OpenAPI.NET/commit/fe133f2604e9b65cc1c7011aab7c62f44e649d19))
9+
* do not throw when operation tag is missing matching global tag ([2c5aa40](https://github.com/microsoft/OpenAPI.NET/commit/2c5aa40cbb8bf1e96c1ccce6273579e70b69ade2))
10+
311
## [2.0.0-preview.20](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.19...v2.0.0-preview.20) (2025-05-20)
412

513

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageProjectUrl>https://github.com/Microsoft/OpenAPI.NET</PackageProjectUrl>
1313
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1414
<PackageTags>OpenAPI .NET</PackageTags>
15-
<Version>2.0.0-preview.20</Version>
15+
<Version>2.0.0-preview.21</Version>
1616
</PropertyGroup>
1717
<!-- https://github.com/clairernovotny/DeterministicBuilds#deterministic-builds -->
1818
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">

src/Microsoft.OpenApi/Models/OpenApiOperation.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version
183183
// tags
184184
writer.WriteOptionalCollection(
185185
OpenApiConstants.Tags,
186-
VerifyTagReferences(Tags),
186+
Tags,
187187
callback);
188188

189189
// summary
@@ -237,7 +237,7 @@ public virtual void SerializeAsV2(IOpenApiWriter writer)
237237
// tags
238238
writer.WriteOptionalCollection(
239239
OpenApiConstants.Tags,
240-
VerifyTagReferences(Tags),
240+
Tags,
241241
(w, t) => t.SerializeAsV2(w));
242242

243243
// summary
@@ -356,21 +356,5 @@ public virtual void SerializeAsV2(IOpenApiWriter writer)
356356

357357
writer.WriteEndObject();
358358
}
359-
360-
private static ISet<OpenApiTagReference>? VerifyTagReferences(ISet<OpenApiTagReference>? tags)
361-
{
362-
if (tags?.Count > 0)
363-
{
364-
foreach (var tag in tags)
365-
{
366-
if (tag.Target is null)
367-
{
368-
throw new OpenApiException($"The OpenAPI tag reference '{tag.Reference.Id}' does not reference a valid tag.");
369-
}
370-
}
371-
}
372-
373-
return tags;
374-
}
375359
}
376360
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public string? Description
5959
public IDictionary<string, IOpenApiExtension>? Extensions { get => Target?.Extensions; }
6060

6161
/// <inheritdoc/>
62-
public string? Name { get => Target?.Name; }
62+
public string? Name { get => Target?.Name ?? Reference?.Id; }
6363
/// <inheritdoc/>
6464
public override IOpenApiTag CopyReferenceAsTargetElementWithOverrides(IOpenApiTag source)
6565
{

test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -860,34 +860,5 @@ public void OpenApiOperationCopyConstructorWithAnnotationsSucceeds()
860860

861861
Assert.NotEqual(baseOperation.Metadata["key1"], actualOperation.Metadata["key1"]);
862862
}
863-
864-
[Theory]
865-
[InlineData(OpenApiSpecVersion.OpenApi2_0)]
866-
[InlineData(OpenApiSpecVersion.OpenApi3_0)]
867-
[InlineData(OpenApiSpecVersion.OpenApi3_1)]
868-
public async Task SerializeAsJsonAsyncThrowsIfTagReferenceIsUnresolved(OpenApiSpecVersion version)
869-
{
870-
var document = new OpenApiDocument()
871-
{
872-
Tags = new HashSet<OpenApiTag>
873-
{
874-
new() { Name = "one" },
875-
new() { Name = "three" }
876-
}
877-
};
878-
879-
var operation = new OpenApiOperation()
880-
{
881-
Tags = new HashSet<OpenApiTagReference>
882-
{
883-
new("one", document),
884-
new("two", document),
885-
new("three", document)
886-
}
887-
};
888-
889-
var exception = await Assert.ThrowsAsync<OpenApiException>(() => operation.SerializeAsJsonAsync(version));
890-
Assert.Equal("The OpenAPI tag reference 'two' does not reference a valid tag.", exception.Message);
891-
}
892863
}
893864
}

0 commit comments

Comments
 (0)