-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathOpenApiAny.cs
More file actions
53 lines (46 loc) · 1.6 KB
/
OpenApiAny.cs
File metadata and controls
53 lines (46 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System.Text.Json.Nodes;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Writers;
namespace Microsoft.OpenApi.Any
{
/// <summary>
/// A wrapper class for JsonNode
/// </summary>
public class OpenApiAny : IOpenApiElement, IOpenApiExtension
{
private readonly JsonNode jsonNode;
/// <summary>
/// Initializes the <see cref="OpenApiAny"/> class.
/// </summary>
/// <param name="jsonNode"></param>
public OpenApiAny(JsonNode jsonNode)
{
this.jsonNode = jsonNode;
}
/// <summary>
/// Gets the underlying JsonNode.
/// </summary>
public JsonNode Node { get { return jsonNode; } }
/// <summary>
/// Writes out the OpenApiAny type.
/// </summary>
/// <param name="writer"></param>
/// <param name="specVersion"></param>
public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
{
writer.WriteAny(Node);
}
/// <summary>
/// Implicit conversion from JsonNode to an OpenApiAny.
/// </summary>
/// <param name="jsonNode"></param>
public static implicit operator OpenApiAny(JsonNode jsonNode) => new(jsonNode);
/// <summary>
/// Implicit conversion from OpenApiAny to a JsonNode.
/// </summary>
/// <param name="openApiAny"></param>
public static implicit operator JsonNode(OpenApiAny openApiAny) => openApiAny.Node;
}
}