Skip to content

Commit 7069446

Browse files
committed
Implement an interface for IOpenApiReferenceable items with a target object
1 parent 962e929 commit 7069446

12 files changed

+28
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
namespace Microsoft.OpenApi.Interfaces
5+
{
6+
/// <summary>
7+
/// A generic interface for OpenApiReferenceable objects that have a target.
8+
/// </summary>
9+
/// <typeparam name="T"></typeparam>
10+
public interface IOpenApiReferenceableWithTarget<T> : IOpenApiReferenceable
11+
{
12+
/// <summary>
13+
/// Gets the resolved target object.
14+
/// </summary>
15+
T Target { get; }
16+
}
17+
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.OpenApi.Models.References
1212
/// <summary>
1313
/// Callback Object Reference: A reference to a map of possible out-of band callbacks related to the parent operation.
1414
/// </summary>
15-
public class OpenApiCallbackReference : OpenApiCallback, IOpenApiReferenceable
15+
public class OpenApiCallbackReference : OpenApiCallback, IOpenApiReferenceableWithTarget<OpenApiCallback>
1616
{
1717
#nullable enable
1818
internal OpenApiCallback _target;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.OpenApi.Models.References
1212
/// <summary>
1313
/// Example Object Reference.
1414
/// </summary>
15-
public class OpenApiExampleReference : OpenApiExample, IOpenApiReferenceable
15+
public class OpenApiExampleReference : OpenApiExample, IOpenApiReferenceableWithTarget<OpenApiExample>
1616
{
1717
internal OpenApiExample _target;
1818
private readonly OpenApiReference _reference;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.OpenApi.Models.References
1212
/// <summary>
1313
/// Header Object Reference.
1414
/// </summary>
15-
public class OpenApiHeaderReference : OpenApiHeader, IOpenApiReferenceable
15+
public class OpenApiHeaderReference : OpenApiHeader, IOpenApiReferenceableWithTarget<OpenApiHeader>
1616
{
1717
internal OpenApiHeader _target;
1818
private readonly OpenApiReference _reference;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Microsoft.OpenApi.Models.References
1111
/// <summary>
1212
/// Link Object Reference.
1313
/// </summary>
14-
public class OpenApiLinkReference : OpenApiLink, IOpenApiReferenceable
14+
public class OpenApiLinkReference : OpenApiLink, IOpenApiReferenceableWithTarget<OpenApiLink>
1515
{
1616
internal OpenApiLink _target;
1717
private readonly OpenApiReference _reference;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.OpenApi.Models.References
1212
/// <summary>
1313
/// Parameter Object Reference.
1414
/// </summary>
15-
public class OpenApiParameterReference : OpenApiParameter, IOpenApiReferenceable
15+
public class OpenApiParameterReference : OpenApiParameter, IOpenApiReferenceableWithTarget<OpenApiParameter>
1616
{
1717
internal OpenApiParameter _target;
1818
private readonly OpenApiReference _reference;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Microsoft.OpenApi.Models.References
1111
/// <summary>
1212
/// Path Item Object Reference: to describe the operations available on a single path.
1313
/// </summary>
14-
public class OpenApiPathItemReference : OpenApiPathItem, IOpenApiReferenceable
14+
public class OpenApiPathItemReference : OpenApiPathItem, IOpenApiReferenceableWithTarget<OpenApiPathItem>
1515
{
1616
internal OpenApiPathItem _target;
1717
private readonly OpenApiReference _reference;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Microsoft.OpenApi.Models.References
1111
/// <summary>
1212
/// Request Body Object Reference.
1313
/// </summary>
14-
public class OpenApiRequestBodyReference : OpenApiRequestBody, IOpenApiReferenceable
14+
public class OpenApiRequestBodyReference : OpenApiRequestBody, IOpenApiReferenceableWithTarget<OpenApiRequestBody>
1515
{
1616
internal OpenApiRequestBody _target;
1717
private readonly OpenApiReference _reference;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Microsoft.OpenApi.Models.References
1111
/// <summary>
1212
/// Response Object Reference.
1313
/// </summary>
14-
public class OpenApiResponseReference : OpenApiResponse, IOpenApiReferenceable
14+
public class OpenApiResponseReference : OpenApiResponse, IOpenApiReferenceableWithTarget<OpenApiResponse>
1515
{
1616
internal OpenApiResponse _target;
1717
private readonly OpenApiReference _reference;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.OpenApi.Models.References
1212
/// <summary>
1313
/// Schema reference object
1414
/// </summary>
15-
public class OpenApiSchemaReference : OpenApiSchema, IOpenApiReferenceable
15+
public class OpenApiSchemaReference : OpenApiSchema, IOpenApiReferenceableWithTarget<OpenApiSchema>
1616
{
1717
#nullable enable
1818
private OpenApiSchema? _target;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Microsoft.OpenApi.Models.References
1111
/// <summary>
1212
/// Security Scheme Object Reference.
1313
/// </summary>
14-
public class OpenApiSecuritySchemeReference : OpenApiSecurityScheme, IOpenApiReferenceable
14+
public class OpenApiSecuritySchemeReference : OpenApiSecurityScheme, IOpenApiReferenceableWithTarget<OpenApiSecurityScheme>
1515
{
1616
internal OpenApiSecurityScheme _target;
1717
private readonly OpenApiReference _reference;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.OpenApi.Models.References
1212
/// <summary>
1313
/// Tag Object Reference
1414
/// </summary>
15-
public class OpenApiTagReference : OpenApiTag, IOpenApiReferenceable
15+
public class OpenApiTagReference : OpenApiTag, IOpenApiReferenceableWithTarget<OpenApiTag>
1616
{
1717
internal OpenApiTag _target;
1818

0 commit comments

Comments
 (0)