Skip to content

Commit c71b5de

Browse files
committed
refactor: rename annotations to metadata
1 parent 3385a0e commit c71b5de

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

44
using System.Collections.Generic;
@@ -9,11 +9,11 @@ namespace Microsoft.OpenApi.Interfaces
99
/// Represents an Open API element that can be annotated with
1010
/// non-serializable properties in a property bag.
1111
/// </summary>
12-
public interface IOpenApiAnnotatable
12+
public interface IMetadataContainer
1313
{
1414
/// <summary>
1515
/// A collection of properties associated with the current OpenAPI element.
1616
/// </summary>
17-
IDictionary<string, object> Annotations { get; set; }
17+
IDictionary<string, object> Metadata { get; set; }
1818
}
1919
}

src/Microsoft.OpenApi/Models/OpenApiDocument.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Microsoft.OpenApi.Models
2424
/// <summary>
2525
/// Describes an OpenAPI object (OpenAPI document). See: https://spec.openapis.org
2626
/// </summary>
27-
public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IOpenApiAnnotatable
27+
public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IMetadataContainer
2828
{
2929
/// <summary>
3030
/// Register components in the document to the workspace
@@ -109,7 +109,7 @@ public ISet<OpenApiTag>? Tags
109109
public IDictionary<string, IOpenApiExtension>? Extensions { get; set; } = new Dictionary<string, IOpenApiExtension>();
110110

111111
/// <inheritdoc />
112-
public IDictionary<string, object>? Annotations { get; set; }
112+
public IDictionary<string, object>? Metadata { get; set; }
113113

114114
/// <summary>
115115
/// Implements IBaseDocument
@@ -143,7 +143,7 @@ public OpenApiDocument(OpenApiDocument? document)
143143
Tags = document?.Tags != null ? new HashSet<OpenApiTag>(document.Tags, OpenApiTagComparer.Instance) : null;
144144
ExternalDocs = document?.ExternalDocs != null ? new(document?.ExternalDocs) : null;
145145
Extensions = document?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(document.Extensions) : null;
146-
Annotations = document?.Annotations != null ? new Dictionary<string, object>(document.Annotations) : null;
146+
Metadata = document?.Metadata != null ? new Dictionary<string, object>(document.Metadata) : null;
147147
BaseUri = document?.BaseUri != null ? document.BaseUri : new(OpenApiConstants.BaseRegistryUri + Guid.NewGuid());
148148
}
149149

src/Microsoft.OpenApi/Models/OpenApiOperation.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Microsoft.OpenApi.Models
1616
/// <summary>
1717
/// Operation Object.
1818
/// </summary>
19-
public class OpenApiOperation : IOpenApiSerializable, IOpenApiExtensible, IOpenApiAnnotatable
19+
public class OpenApiOperation : IOpenApiSerializable, IOpenApiExtensible, IMetadataContainer
2020
{
2121
/// <summary>
2222
/// Default value for <see cref="Deprecated"/>.
@@ -127,7 +127,7 @@ public ISet<OpenApiTagReference>? Tags
127127
public IDictionary<string, IOpenApiExtension>? Extensions { get; set; } = new Dictionary<string, IOpenApiExtension>();
128128

129129
/// <inheritdoc />
130-
public IDictionary<string, object>? Annotations { get; set; }
130+
public IDictionary<string, object>? Metadata { get; set; }
131131

132132
/// <summary>
133133
/// Parameterless constructor
@@ -153,7 +153,7 @@ public OpenApiOperation(OpenApiOperation operation)
153153
Security = operation.Security != null ? new List<OpenApiSecurityRequirement>(operation.Security) : null;
154154
Servers = operation.Servers != null ? new List<OpenApiServer>(operation.Servers) : null;
155155
Extensions = operation.Extensions != null ? new Dictionary<string, IOpenApiExtension>(operation.Extensions) : null;
156-
Annotations = operation.Annotations != null ? new Dictionary<string, object>(operation.Annotations) : null;
156+
Metadata = operation.Metadata != null ? new Dictionary<string, object>(operation.Metadata) : null;
157157
}
158158

159159
/// <summary>

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

+11-11
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public class OpenApiDocumentTests
9292
{
9393
Version = "1.0.0"
9494
},
95-
Annotations = new Dictionary<string, object> { { "key1", "value" } },
95+
Metadata = new Dictionary<string, object> { { "key1", "value" } },
9696
Components = TopLevelReferencingComponents
9797
};
9898

@@ -102,7 +102,7 @@ public class OpenApiDocumentTests
102102
{
103103
Version = "1.0.0"
104104
},
105-
Annotations = new Dictionary<string, object> { { "key1", "value" } },
105+
Metadata = new Dictionary<string, object> { { "key1", "value" } },
106106
Components = TopLevelSelfReferencingComponentsWithOtherProperties
107107
};
108108

@@ -112,7 +112,7 @@ public class OpenApiDocumentTests
112112
{
113113
Version = "1.0.0"
114114
},
115-
Annotations = new Dictionary<string, object> { { "key1", "value" } },
115+
Metadata = new Dictionary<string, object> { { "key1", "value" } },
116116
Components = TopLevelSelfReferencingComponents
117117
};
118118

@@ -489,7 +489,7 @@ public class OpenApiDocumentTests
489489
}
490490
}
491491
},
492-
Annotations = new Dictionary<string, object> { { "key1", "value" } },
492+
Metadata = new Dictionary<string, object> { { "key1", "value" } },
493493
Components = AdvancedComponentsWithReference
494494
};
495495

@@ -865,7 +865,7 @@ public class OpenApiDocumentTests
865865
}
866866
}
867867
},
868-
Annotations = new Dictionary<string, object> { { "key1", "value" } },
868+
Metadata = new Dictionary<string, object> { { "key1", "value" } },
869869
Components = AdvancedComponents
870870
};
871871

@@ -1024,7 +1024,7 @@ public class OpenApiDocumentTests
10241024
}
10251025
}
10261026
},
1027-
Annotations = new Dictionary<string, object> { { "key1", "value" } },
1027+
Metadata = new Dictionary<string, object> { { "key1", "value" } },
10281028
Components = AdvancedComponents
10291029
};
10301030

@@ -1324,7 +1324,7 @@ public class OpenApiDocumentTests
13241324
}
13251325
}
13261326
},
1327-
Annotations = new Dictionary<string, object> { { "key1", "value" } },
1327+
Metadata = new Dictionary<string, object> { { "key1", "value" } },
13281328
Components = AdvancedComponents
13291329
};
13301330

@@ -1830,7 +1830,7 @@ public void OpenApiDocumentCopyConstructorWithAnnotationsSucceeds()
18301830
{
18311831
var baseDocument = new OpenApiDocument
18321832
{
1833-
Annotations = new Dictionary<string, object>
1833+
Metadata = new Dictionary<string, object>
18341834
{
18351835
["key1"] = "value1",
18361836
["key2"] = 2
@@ -1839,11 +1839,11 @@ public void OpenApiDocumentCopyConstructorWithAnnotationsSucceeds()
18391839

18401840
var actualDocument = new OpenApiDocument(baseDocument);
18411841

1842-
Assert.Equal(baseDocument.Annotations["key1"], actualDocument.Annotations["key1"]);
1842+
Assert.Equal(baseDocument.Metadata["key1"], actualDocument.Metadata["key1"]);
18431843

1844-
baseDocument.Annotations["key1"] = "value2";
1844+
baseDocument.Metadata["key1"] = "value2";
18451845

1846-
Assert.NotEqual(baseDocument.Annotations["key1"], actualDocument.Annotations["key1"]);
1846+
Assert.NotEqual(baseDocument.Metadata["key1"], actualDocument.Metadata["key1"]);
18471847
}
18481848

18491849
[Fact]

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public class OpenApiOperationTests
8484
Description = "serverDescription"
8585
}
8686
},
87-
Annotations = new Dictionary<string, object> { { "key1", "value1" }, { "key2", 2 } },
87+
Metadata = new Dictionary<string, object> { { "key1", "value1" }, { "key2", 2 } },
8888
};
8989

9090
private static OpenApiOperation _advancedOperationWithTagsAndSecurity => new()
@@ -844,7 +844,7 @@ public void OpenApiOperationCopyConstructorWithAnnotationsSucceeds()
844844
{
845845
var baseOperation = new OpenApiOperation
846846
{
847-
Annotations = new Dictionary<string, object>
847+
Metadata = new Dictionary<string, object>
848848
{
849849
["key1"] = "value1",
850850
["key2"] = 2
@@ -853,11 +853,11 @@ public void OpenApiOperationCopyConstructorWithAnnotationsSucceeds()
853853

854854
var actualOperation = new OpenApiOperation(baseOperation);
855855

856-
Assert.Equal(baseOperation.Annotations["key1"], actualOperation.Annotations["key1"]);
856+
Assert.Equal(baseOperation.Metadata["key1"], actualOperation.Metadata["key1"]);
857857

858-
baseOperation.Annotations["key1"] = "value2";
858+
baseOperation.Metadata["key1"] = "value2";
859859

860-
Assert.NotEqual(baseOperation.Annotations["key1"], actualOperation.Annotations["key1"]);
860+
Assert.NotEqual(baseOperation.Metadata["key1"], actualOperation.Metadata["key1"]);
861861
}
862862
}
863863
}

test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ namespace Microsoft.OpenApi.Extensions
199199
namespace Microsoft.OpenApi.Interfaces
200200
{
201201
public interface IDiagnostic { }
202-
public interface IOpenApiAnnotatable
202+
public interface IMetadataContainer
203203
{
204-
System.Collections.Generic.IDictionary<string, object> Annotations { get; set; }
204+
System.Collections.Generic.IDictionary<string, object> Metadata { get; set; }
205205
}
206206
public interface IOpenApiElement { }
207207
public interface IOpenApiExtensible : Microsoft.OpenApi.Interfaces.IOpenApiElement
@@ -706,17 +706,17 @@ namespace Microsoft.OpenApi.Models
706706
public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { }
707707
public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { }
708708
}
709-
public class OpenApiDocument : Microsoft.OpenApi.Interfaces.IOpenApiAnnotatable, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable
709+
public class OpenApiDocument : Microsoft.OpenApi.Interfaces.IMetadataContainer, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable
710710
{
711711
public OpenApiDocument() { }
712712
public OpenApiDocument(Microsoft.OpenApi.Models.OpenApiDocument? document) { }
713-
public System.Collections.Generic.IDictionary<string, object>? Annotations { get; set; }
714713
public System.Uri BaseUri { get; }
715714
public Microsoft.OpenApi.Models.OpenApiComponents? Components { get; set; }
716715
public System.Collections.Generic.IDictionary<string, Microsoft.OpenApi.Interfaces.IOpenApiExtension>? Extensions { get; set; }
717716
public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; }
718717
public Microsoft.OpenApi.Models.OpenApiInfo Info { get; set; }
719718
public System.Uri? JsonSchemaDialect { get; set; }
719+
public System.Collections.Generic.IDictionary<string, object>? Metadata { get; set; }
720720
public Microsoft.OpenApi.Models.OpenApiPaths Paths { get; set; }
721721
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.OpenApiSecurityRequirement>? Security { get; set; }
722722
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.OpenApiServer>? Servers { get; set; }
@@ -894,17 +894,17 @@ namespace Microsoft.OpenApi.Models
894894
public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { }
895895
public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { }
896896
}
897-
public class OpenApiOperation : Microsoft.OpenApi.Interfaces.IOpenApiAnnotatable, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable
897+
public class OpenApiOperation : Microsoft.OpenApi.Interfaces.IMetadataContainer, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable
898898
{
899899
public const bool DeprecatedDefault = false;
900900
public OpenApiOperation() { }
901901
public OpenApiOperation(Microsoft.OpenApi.Models.OpenApiOperation operation) { }
902-
public System.Collections.Generic.IDictionary<string, object>? Annotations { get; set; }
903902
public System.Collections.Generic.IDictionary<string, Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback>? Callbacks { get; set; }
904903
public bool Deprecated { get; set; }
905904
public string? Description { get; set; }
906905
public System.Collections.Generic.IDictionary<string, Microsoft.OpenApi.Interfaces.IOpenApiExtension>? Extensions { get; set; }
907906
public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; }
907+
public System.Collections.Generic.IDictionary<string, object>? Metadata { get; set; }
908908
public string? OperationId { get; set; }
909909
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter>? Parameters { get; set; }
910910
public Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody? RequestBody { get; set; }

0 commit comments

Comments
 (0)