Skip to content

Commit b5f68c9

Browse files
authored
Merge pull request #2111 from microsoft/fix/references-cleanup
fix/references cleanup
2 parents c637cc4 + e09fb38 commit b5f68c9

Some content is hidden

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

47 files changed

+468
-269
lines changed

src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceHolder.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,14 @@ namespace Microsoft.OpenApi.Interfaces
88
/// <summary>
99
/// A generic interface for OpenApiReferenceable objects that have a target.
1010
/// </summary>
11-
/// <typeparam name="T">Type of the target being referenced</typeparam>
12-
public interface IOpenApiReferenceHolder<out T> : IOpenApiReferenceHolder where T : IOpenApiReferenceable
11+
/// <typeparam name="T">The type of the target being referenced</typeparam>
12+
/// <typeparam name="V">The type of the interface implemented by both the target and the reference type</typeparam>
13+
public interface IOpenApiReferenceHolder<out T, V> : IOpenApiReferenceHolder where T : IOpenApiReferenceable, V
1314
{
1415
/// <summary>
1516
/// Gets the resolved target object.
1617
/// </summary>
1718
T Target { get; }
18-
}
19-
/// <summary>
20-
/// A generic interface for OpenApiReferenceable objects that have a target.
21-
/// </summary>
22-
/// <typeparam name="T">The type of the target being referenced</typeparam>
23-
/// <typeparam name="V">The type of the interface implemented by both the target and the reference type</typeparam>
24-
public interface IOpenApiReferenceHolder<out T, V> : IOpenApiReferenceHolder<T> where T : IOpenApiReferenceable, V
25-
{
26-
//TODO merge this interface with the previous once all implementations are updated
2719
/// <summary>
2820
/// Copy the reference as a target element with overrides.
2921
/// </summary>
@@ -37,8 +29,7 @@ public interface IOpenApiReferenceHolder : IOpenApiSerializable
3729
/// <summary>
3830
/// Indicates if object is populated with data or is just a reference to the data
3931
/// </summary>
40-
bool UnresolvedReference { get; set; }
41-
//TODO the UnresolvedReference property setter should be removed and a default implementation that checks whether the target is null for the getter should be provided instead
32+
bool UnresolvedReference { get; }
4233

4334
/// <summary>
4435
/// Reference object.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Microsoft.OpenApi.Interfaces;
2+
/// <summary>
3+
/// Interface for shallow copyable objects.
4+
/// </summary>
5+
/// <typeparam name="T">The type of the resulting object</typeparam>
6+
public interface IShallowCopyable<out T>
7+
{
8+
/// <summary>
9+
/// Create a shallow copy of the current instance.
10+
/// </summary>
11+
T CreateShallowCopy();
12+
}

src/Microsoft.OpenApi/Models/Interfaces/IOpenApiCallback.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.OpenApi.Models.Interfaces;
99
/// Defines the base properties for the callback object.
1010
/// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking.
1111
/// </summary>
12-
public interface IOpenApiCallback : IOpenApiSerializable, IOpenApiReadOnlyExtensible
12+
public interface IOpenApiCallback : IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable<IOpenApiCallback>
1313
{
1414
/// <summary>
1515
/// A Path Item Object used to define a callback request and expected responses.

src/Microsoft.OpenApi/Models/Interfaces/IOpenApiExample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Microsoft.OpenApi.Models.Interfaces;
77
/// Defines the base properties for the example object.
88
/// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking.
99
/// </summary>
10-
public interface IOpenApiExample : IOpenApiDescribedElement, IOpenApiSummarizedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible
10+
public interface IOpenApiExample : IOpenApiDescribedElement, IOpenApiSummarizedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable<IOpenApiExample>
1111
{
1212
/// <summary>
1313
/// Embedded literal example. The value field and externalValue field are mutually

src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.OpenApi.Models.Interfaces;
99
/// Defines the base properties for the headers object.
1010
/// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking.
1111
/// </summary>
12-
public interface IOpenApiHeader : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible
12+
public interface IOpenApiHeader : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable<IOpenApiHeader>
1313
{
1414
/// <summary>
1515
/// Determines whether this header is mandatory.

src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Microsoft.OpenApi.Models.Interfaces;
77
/// Defines the base properties for the link object.
88
/// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking.
99
/// </summary>
10-
public interface IOpenApiLink : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible
10+
public interface IOpenApiLink : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable<IOpenApiLink>
1111
{
1212
/// <summary>
1313
/// A relative or absolute reference to an OAS operation.

src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Microsoft.OpenApi.Models.Interfaces;
88
/// Defines the base properties for the parameter object.
99
/// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking.
1010
/// </summary>
11-
public interface IOpenApiParameter : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible
11+
public interface IOpenApiParameter : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable<IOpenApiParameter>
1212
{
1313
/// <summary>
1414
/// REQUIRED. The name of the parameter. Parameter names are case sensitive.

src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Microsoft.OpenApi.Models.Interfaces;
88
/// Defines the base properties for the path item object.
99
/// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking.
1010
/// </summary>
11-
public interface IOpenApiPathItem : IOpenApiDescribedElement, IOpenApiSummarizedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible
11+
public interface IOpenApiPathItem : IOpenApiDescribedElement, IOpenApiSummarizedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable<IOpenApiPathItem>
1212
{
1313
/// <summary>
1414
/// Gets the definition of operations on this path.

src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Microsoft.OpenApi.Models.Interfaces;
88
/// Defines the base properties for the request body object.
99
/// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking.
1010
/// </summary>
11-
public interface IOpenApiRequestBody : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible
11+
public interface IOpenApiRequestBody : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable<IOpenApiRequestBody>
1212
{
1313
/// <summary>
1414
/// Determines if the request body is required in the request. Defaults to false.

src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Microsoft.OpenApi.Models.Interfaces;
77
/// Defines the base properties for the response object.
88
/// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking.
99
/// </summary>
10-
public interface IOpenApiResponse : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible
10+
public interface IOpenApiResponse : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable<IOpenApiResponse>
1111
{
1212
/// <summary>
1313
/// Maps a header name to its definition.

0 commit comments

Comments
 (0)