-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2089 from microsoft/fix/example-reference
fix/example reference
- Loading branch information
Showing
57 changed files
with
466 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/Microsoft.OpenApi/Interfaces/IOpenApiReadOnlyExtensible.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.OpenApi.Interfaces; | ||
|
||
/// <summary> | ||
/// Represents an Extensible Open API element elements can be rad from. | ||
/// </summary> | ||
public interface IOpenApiReadOnlyExtensible | ||
{ | ||
/// <summary> | ||
/// Specification extensions. | ||
/// </summary> | ||
IDictionary<string, IOpenApiExtension> Extensions { get; } | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceHolder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using Microsoft.OpenApi.Models; | ||
|
||
namespace Microsoft.OpenApi.Interfaces | ||
{ | ||
/// <summary> | ||
/// A generic interface for OpenApiReferenceable objects that have a target. | ||
/// </summary> | ||
/// <typeparam name="T">Type of the target being referenced</typeparam> | ||
public interface IOpenApiReferenceHolder<out T> : IOpenApiReferenceHolder where T : IOpenApiReferenceable | ||
{ | ||
/// <summary> | ||
/// Gets the resolved target object. | ||
/// </summary> | ||
T Target { get; } | ||
} | ||
/// <summary> | ||
/// A generic interface for OpenApiReferenceable objects that have a target. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the target being referenced</typeparam> | ||
/// <typeparam name="V">The type of the interface implemented by both the target and the reference type</typeparam> | ||
public interface IOpenApiReferenceHolder<out T, V> : IOpenApiReferenceHolder<T> where T : IOpenApiReferenceable, V | ||
{ | ||
//TODO merge this interface with the previous once all implementations are updated | ||
/// <summary> | ||
/// Copy the reference as a target element with overrides. | ||
/// </summary> | ||
V CopyReferenceAsTargetElementWithOverrides(V source); | ||
} | ||
/// <summary> | ||
/// A generic interface for OpenApiReferenceable objects that have a target. | ||
/// </summary> | ||
public interface IOpenApiReferenceHolder : IOpenApiSerializable | ||
{ | ||
/// <summary> | ||
/// Indicates if object is populated with data or is just a reference to the data | ||
/// </summary> | ||
bool UnresolvedReference { get; set; } | ||
|
||
/// <summary> | ||
/// Reference object. | ||
/// </summary> | ||
OpenApiReference Reference { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using Microsoft.OpenApi.Models; | ||
|
||
namespace Microsoft.OpenApi.Interfaces | ||
{ | ||
/// <summary> | ||
/// Represents an Open API element is referenceable. | ||
/// </summary> | ||
public interface IOpenApiReferenceable : IOpenApiSerializable | ||
{ | ||
/// <summary> | ||
/// Indicates if object is populated with data or is just a reference to the data | ||
/// </summary> | ||
bool UnresolvedReference { get; set; } | ||
|
||
/// <summary> | ||
/// Reference object. | ||
/// </summary> | ||
OpenApiReference Reference { get; set; } | ||
} | ||
} |
17 changes: 0 additions & 17 deletions
17
src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceableWithTarget.cs
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
src/Microsoft.OpenApi/Models/Interfaces/IOpenApiDescribedElement.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.OpenApi.Interfaces; | ||
|
||
namespace Microsoft.OpenApi.Models.Interfaces; | ||
|
||
/// <summary> | ||
/// Describes an element that has a summary and description. | ||
/// </summary> | ||
public interface IOpenApiDescribedElement : IOpenApiElement | ||
{ | ||
/// <summary> | ||
/// Short description for the example. | ||
/// </summary> | ||
public string Summary { get; set; } | ||
|
||
/// <summary> | ||
/// Long description for the example. | ||
/// CommonMark syntax MAY be used for rich text representation. | ||
/// </summary> | ||
public string Description { get; set; } | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Microsoft.OpenApi/Models/Interfaces/IOpenApiExample.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Text.Json.Nodes; | ||
using Microsoft.OpenApi.Interfaces; | ||
|
||
namespace Microsoft.OpenApi.Models.Interfaces; | ||
|
||
/// <summary> | ||
/// Defines the base properties for the example object. | ||
/// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking. | ||
/// </summary> | ||
public interface IOpenApiExample : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible | ||
{ | ||
/// <summary> | ||
/// Embedded literal example. The value field and externalValue field are mutually | ||
/// exclusive. To represent examples of media types that cannot naturally represented | ||
/// in JSON or YAML, use a string value to contain the example, escaping where necessary. | ||
/// </summary> | ||
public JsonNode Value { get; } | ||
|
||
/// <summary> | ||
/// A URL that points to the literal example. | ||
/// This provides the capability to reference examples that cannot easily be | ||
/// included in JSON or YAML documents. | ||
/// The value field and externalValue field are mutually exclusive. | ||
/// </summary> | ||
public string ExternalValue { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.