Repository navigation
Expand file tree
/
Copy pathAsyncApiOAuthFlow.cs
More file actions
69 lines (55 loc) · 2.32 KB
/
Copy pathAsyncApiOAuthFlow.cs
File metadata and controls
69 lines (55 loc) · 2.32 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
59
60
61
62
63
64
65
66
67
68
69
// Copyright (c) The LEGO Group. All rights reserved.
namespace LEGO.AsyncAPI.Models
{
using System;
using System.Collections.Generic;
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Writers;
public class AsyncApiOAuthFlow : IAsyncApiSerializable, IAsyncApiExtensible
{
/// <summary>
/// REQUIRED. The authorization URL to be used for this flow.
/// Applies to implicit and authorizationCode OAuthFlow.
/// </summary>
public Uri AuthorizationUrl { get; set; }
/// <summary>
/// REQUIRED. The token URL to be used for this flow.
/// Applies to password, clientCredentials, and authorizationCode OAuthFlow.
/// </summary>
public Uri TokenUrl { get; set; }
/// <summary>
/// The URL to be used for obtaining refresh tokens.
/// </summary>
public Uri RefreshUrl { get; set; }
/// <summary>
/// REQUIRED. A map between the scope name and a short description for it.
/// </summary>
public IDictionary<string, string> Scopes { get; set; } = new Dictionary<string, string>();
/// <summary>
/// Specification Extensions.
/// </summary>
public IDictionary<string, IAsyncApiExtension> Extensions { get; set; } = new Dictionary<string, IAsyncApiExtension>();
/// <summary>
/// Serialize <see cref="AsyncApiOAuthFlow"/> to Async Api v2.4.
/// </summary>
public void SerializeV2(IAsyncApiWriter writer)
{
if (writer is null)
{
throw new ArgumentNullException(nameof(writer));
}
writer.WriteStartObject();
// authorizationUrl
writer.WriteOptionalProperty(AsyncApiConstants.AuthorizationUrl, this.AuthorizationUrl?.ToString());
// tokenUrl
writer.WriteOptionalProperty(AsyncApiConstants.TokenUrl, this.TokenUrl?.ToString());
// refreshUrl
writer.WriteOptionalProperty(AsyncApiConstants.RefreshUrl, this.RefreshUrl?.ToString());
// scopes
writer.WriteRequiredMap(AsyncApiConstants.Scopes, this.Scopes, (w, s) => w.WriteValue(s));
// extensions
writer.WriteExtensions(this.Extensions);
writer.WriteEndObject();
}
}
}