Repository navigation
Expand file tree
/
Copy pathAsyncApiContact.cs
More file actions
55 lines (44 loc) · 1.71 KB
/
Copy pathAsyncApiContact.cs
File metadata and controls
55 lines (44 loc) · 1.71 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
namespace ByteBard.AsyncAPI.Models
{
using System;
using System.Collections.Generic;
using ByteBard.AsyncAPI.Models.Interfaces;
using ByteBard.AsyncAPI.Writers;
/// <summary>
/// Contact information for the exposed API.
/// </summary>
public class AsyncApiContact : IAsyncApiSerializable, IAsyncApiExtensible
{
/// <summary>
/// Gets or sets the identifying name of the contact person/organization.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Gets or sets the URL pointing to the contact information. MUST be in the format of a URL.
/// </summary>
public Uri Url { get; set; }
/// <summary>
/// Gets or sets the email address of the contact person/organization. MUST be in the format of an email address.
/// </summary>
public string Email { get; set; }
/// <inheritdoc/>
public IDictionary<string, IAsyncApiExtension> Extensions { get; set; } = new Dictionary<string, IAsyncApiExtension>();
public void SerializeV2(IAsyncApiWriter writer)
{
if (writer is null)
{
throw new ArgumentNullException(nameof(writer));
}
writer.WriteStartObject();
// name
writer.WriteOptionalProperty(AsyncApiConstants.Name, this.Name);
// url
writer.WriteOptionalProperty(AsyncApiConstants.Url, this.Url?.OriginalString);
// email
writer.WriteOptionalProperty(AsyncApiConstants.Email, this.Email);
// extensions
writer.WriteExtensions(this.Extensions);
writer.WriteEndObject();
}
}
}