Repository navigation
Expand file tree
/
Copy pathAsyncApiOAuthFlows.cs
More file actions
76 lines (62 loc) · 2.39 KB
/
Copy pathAsyncApiOAuthFlows.cs
File metadata and controls
76 lines (62 loc) · 2.39 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
70
71
72
73
74
75
76
// 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;
/// <summary>
/// OAuth Flows Object.
/// </summary>
public class AsyncApiOAuthFlows : IAsyncApiSerializable, IAsyncApiExtensible
{
/// <summary>
/// Configuration for the OAuth Implicit flow.
/// </summary>
public AsyncApiOAuthFlow Implicit { get; set; }
/// <summary>
/// Configuration for the OAuth Resource Owner Password flow.
/// </summary>
public AsyncApiOAuthFlow Password { get; set; }
/// <summary>
/// Configuration for the OAuth Client Credentials flow.
/// </summary>
public AsyncApiOAuthFlow ClientCredentials { get; set; }
/// <summary>
/// Configuration for the OAuth Authorization Code flow.
/// </summary>
public AsyncApiOAuthFlow AuthorizationCode { get; set; }
/// <summary>
/// Specification Extensions.
/// </summary>
public IDictionary<string, IAsyncApiExtension> Extensions { get; set; } = new Dictionary<string, IAsyncApiExtension>();
/// <summary>
/// Serialize <see cref="AsyncApiOAuthFlows"/> to Async Api v2.4.
/// </summary>
public void SerializeV2(IAsyncApiWriter writer)
{
if (writer is null)
{
throw new ArgumentNullException(nameof(writer));
}
writer.WriteStartObject();
// implicit
writer.WriteOptionalObject(AsyncApiConstants.Implicit, this.Implicit, (w, o) => o.SerializeV2(w));
// password
writer.WriteOptionalObject(AsyncApiConstants.Password, this.Password, (w, o) => o.SerializeV2(w));
// clientCredentials
writer.WriteOptionalObject(
AsyncApiConstants.ClientCredentials,
this.ClientCredentials,
(w, o) => o.SerializeV2(w));
// authorizationCode
writer.WriteOptionalObject(
AsyncApiConstants.AuthorizationCode,
this.AuthorizationCode,
(w, o) => o.SerializeV2(w));
// extensions
writer.WriteExtensions(this.Extensions);
writer.WriteEndObject();
}
}
}