forked from microsoft/semantic-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestApiServer.cs
More file actions
58 lines (51 loc) · 2.21 KB
/
RestApiServer.cs
File metadata and controls
58 lines (51 loc) · 2.21 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
54
55
56
57
58
// Copyright (c) Microsoft. All rights reserved.
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Microsoft.SemanticKernel.Plugins.OpenApi;
/// <summary>
/// REST API server.
/// </summary>
public sealed class RestApiServer
{
/// <summary>
/// Description of the server.
/// </summary>
public string? Description { get; }
/// <summary>
/// A URL to the target host. This URL supports Server Variables and MAY be relative,
/// to indicate that the host location is relative to the location where the OpenAPI document is being served.
/// Variable substitutions will be made when a variable is named in {brackets}.
/// </summary>
#pragma warning disable CA1056 // URI-like properties should not be strings
public string? Url { get; }
#pragma warning restore CA1056 // URI-like properties should not be strings
/// <summary>
/// A map between a variable name and its value. The value is used for substitution in the server's URL template.
/// </summary>
public IDictionary<string, RestApiServerVariable> Variables { get; private set; }
/// <summary>
/// Construct a new <see cref="RestApiServer"/> object.
/// </summary>
/// <param name="url">URL to the target host</param>
/// <param name="variables">Substitution variables for the server's URL template</param>
/// <param name="description">Description of the server</param>
#pragma warning disable CA1054 // URI-like parameters should not be strings
internal RestApiServer(string? url = null, IDictionary<string, RestApiServerVariable>? variables = null, string? description = null)
#pragma warning restore CA1054 // URI-like parameters should not be strings
{
this.Url = string.IsNullOrEmpty(url) ? null : url;
this.Variables = variables ?? new Dictionary<string, RestApiServerVariable>();
this.Description = description;
}
/// <summary>
/// Makes the current instance unmodifiable.
/// </summary>
internal void Freeze()
{
this.Variables = new ReadOnlyDictionary<string, RestApiServerVariable>(this.Variables);
foreach (var variable in this.Variables.Values)
{
variable.Freeze();
}
}
}