Skip to content

Commit c4d4aeb

Browse files
Merge pull request #50 from TransactionProcessing/documentation/#47_swaggerpages
Swagger documentation updated
2 parents ba829e5 + 5a1b946 commit c4d4aeb

17 files changed

+290
-11
lines changed

MessagingService.DataTransferObjects/MessagingService.DataTransferObjects.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@
44
<TargetFrameworks>net5.0;netstandard2.0</TargetFrameworks>
55
</PropertyGroup>
66

7+
<ItemGroup>
8+
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
9+
</ItemGroup>
10+
711
</Project>

MessagingService.DataTransferObjects/SendEmailRequest.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Diagnostics.CodeAnalysis;
6+
using Newtonsoft.Json;
67

78
[ExcludeFromCodeCoverage]
89
public class SendEmailRequest
@@ -15,6 +16,7 @@ public class SendEmailRequest
1516
/// <value>
1617
/// The message identifier.
1718
/// </value>
19+
[JsonProperty("message_id")]
1820
public Guid? MessageId { get; set; }
1921

2022
/// <summary>
@@ -23,6 +25,7 @@ public class SendEmailRequest
2325
/// <value>
2426
/// The body.
2527
/// </value>
28+
[JsonProperty("body")]
2629
public String Body { get; set; }
2730

2831
/// <summary>
@@ -31,6 +34,7 @@ public class SendEmailRequest
3134
/// <value>
3235
/// The connection identifier.
3336
/// </value>
37+
[JsonProperty("connection_identifier")]
3438
public Guid ConnectionIdentifier { get; set; }
3539

3640
/// <summary>
@@ -39,6 +43,7 @@ public class SendEmailRequest
3943
/// <value>
4044
/// From address.
4145
/// </value>
46+
[JsonProperty("from_address")]
4247
public String FromAddress { get; set; }
4348

4449
/// <summary>
@@ -47,6 +52,7 @@ public class SendEmailRequest
4752
/// <value>
4853
/// <c>true</c> if this instance is HTML; otherwise, <c>false</c>.
4954
/// </value>
55+
[JsonProperty("is_html")]
5056
public Boolean IsHtml { get; set; }
5157

5258
/// <summary>
@@ -55,6 +61,7 @@ public class SendEmailRequest
5561
/// <value>
5662
/// The subject.
5763
/// </value>
64+
[JsonProperty("subject")]
5865
public String Subject { get; set; }
5966

6067
/// <summary>
@@ -63,6 +70,7 @@ public class SendEmailRequest
6370
/// <value>
6471
/// To addresses.
6572
/// </value>
73+
[JsonProperty("to_addresses")]
6674
public List<String> ToAddresses { get; set; }
6775

6876
#endregion

MessagingService.DataTransferObjects/SendEmailResponse.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
using System;
44
using System.Diagnostics.CodeAnalysis;
5+
using Newtonsoft.Json;
56

67
/// <summary>
78
///
@@ -17,6 +18,7 @@ public class SendEmailResponse
1718
/// <value>
1819
/// The message identifier.
1920
/// </value>
21+
[JsonProperty("message_id")]
2022
public Guid MessageId { get; set; }
2123

2224
#endregion

MessagingService.DataTransferObjects/SendSMSRequest.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
namespace MessagingService.DataTransferObjects
22
{
3+
using Newtonsoft.Json;
34
using System;
45
using System.Diagnostics.CodeAnalysis;
5-
6+
67
[ExcludeFromCodeCoverage]
78
public class SendSMSRequest
89
{
@@ -14,6 +15,7 @@ public class SendSMSRequest
1415
/// <value>
1516
/// The connection identifier.
1617
/// </value>
18+
[JsonProperty("connection_identifier")]
1719
public Guid ConnectionIdentifier { get; set; }
1820

1921
/// <summary>
@@ -22,6 +24,7 @@ public class SendSMSRequest
2224
/// <value>
2325
/// The destination.
2426
/// </value>
27+
[JsonProperty("destination")]
2528
public String Destination { get; set; }
2629

2730
/// <summary>
@@ -30,6 +33,7 @@ public class SendSMSRequest
3033
/// <value>
3134
/// The message.
3235
/// </value>
36+
[JsonProperty("message")]
3337
public String Message { get; set; }
3438

3539
/// <summary>
@@ -38,6 +42,7 @@ public class SendSMSRequest
3842
/// <value>
3943
/// The message identifier.
4044
/// </value>
45+
[JsonProperty("message_id")]
4146
public Guid? MessageId { get; set; }
4247

4348
/// <summary>
@@ -46,6 +51,7 @@ public class SendSMSRequest
4651
/// <value>
4752
/// The sender.
4853
/// </value>
54+
[JsonProperty("sender")]
4955
public String Sender { get; set; }
5056

5157
#endregion

MessagingService.DataTransferObjects/SendSMSResponse.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
using System;
44
using System.Diagnostics.CodeAnalysis;
5+
using Newtonsoft.Json;
56

67
[ExcludeFromCodeCoverage]
78
public class SendSMSResponse
@@ -14,6 +15,7 @@ public class SendSMSResponse
1415
/// <value>
1516
/// The message identifier.
1617
/// </value>
18+
[JsonProperty("message_id")]
1719
public Guid MessageId { get; set; }
1820

1921
#endregion

MessagingService.Tests/General/BootstrapperTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ private IConfigurationRoot SetupMemoryConfiguration()
5656
configuration.Add("SecurityConfiguration:Authority", "http://localhost");
5757
configuration.Add("AppSettings:EmailProxy", "UnitTest");
5858
configuration.Add("AppSettings:SMSProxy", "UnitTest");
59+
configuration.Add("AppSettings:ApiVersion", "1.0.0");
5960

6061
builder.AddInMemoryCollection(configuration);
6162

MessagingService/Common/ConfigureSwaggerOptions.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,13 @@ private static OpenApiInfo CreateInfoForApiVersion(ApiVersionDescription descrip
6363
{
6464
OpenApiInfo info = new OpenApiInfo
6565
{
66-
Title = "Golf Handicapping API",
66+
Title = "Messaging API",
6767
Version = description.ApiVersion.ToString(),
68-
Description = "A REST Api to manage the golf club handicapping system.",
68+
Description = "A REST Api to manage sending of various messages over different formats, currently only Email and SMS are supported.",
6969
Contact = new OpenApiContact
7070
{
7171
Name = "Stuart Ferguson",
7272
73-
},
74-
License = new OpenApiLicense
75-
{
76-
Name = "TODO"
7773
}
7874
};
7975

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
namespace MessagingService.Common.RequestExamples
2+
{
3+
using System;
4+
using System.Diagnostics.CodeAnalysis;
5+
6+
/// <summary>
7+
///
8+
/// </summary>
9+
[ExcludeFromCodeCoverage]
10+
internal static class ExampleData
11+
{
12+
#region Fields
13+
14+
/// <summary>
15+
/// The connection identifier
16+
/// </summary>
17+
internal static Guid ConnectionIdentifier = Guid.Parse("A6080219-E243-48F8-A6C3-D79610A74A5B");
18+
19+
/// <summary>
20+
/// The email message from address
21+
/// </summary>
22+
internal static String EmailMessageFromAddress = "[email protected]";
23+
24+
/// <summary>
25+
/// The email message HTML body
26+
/// </summary>
27+
internal static String EmailMessageHtmlBody = "<p>This is a test message body</p>";
28+
29+
/// <summary>
30+
/// The email message identifier
31+
/// </summary>
32+
internal static Guid EmailMessageId = Guid.Parse("63BDE20F-28E0-4698-AF46-923A08198994");
33+
34+
/// <summary>
35+
/// The email message is HTML
36+
/// </summary>
37+
internal static Boolean EmailMessageIsHtml = true;
38+
39+
/// <summary>
40+
/// The email message plain text body
41+
/// </summary>
42+
internal static String EmailMessagePlainTextBody = "This is a test message body";
43+
44+
/// <summary>
45+
/// The email message plain text is HTML
46+
/// </summary>
47+
internal static Boolean EmailMessagePlainTextIsHtml = false;
48+
49+
/// <summary>
50+
/// The email message subject
51+
/// </summary>
52+
internal static String EmailMessageSubject = "Email Subject";
53+
54+
/// <summary>
55+
/// The email message to address1
56+
/// </summary>
57+
internal static String EmailMessageToAddress1 = "[email protected]";
58+
59+
/// <summary>
60+
/// The email message to address2
61+
/// </summary>
62+
internal static String EmailMessageToAddress2 = "[email protected]";
63+
64+
/// <summary>
65+
/// The SMS message destination
66+
/// </summary>
67+
internal static String SMSMessageDestination = "07123456789";
68+
69+
/// <summary>
70+
/// The SMS message identifier
71+
/// </summary>
72+
internal static Guid SMSMessageId = Guid.Parse("D38E20B1-64F1-4217-B192-24123862FE10");
73+
74+
/// <summary>
75+
/// The SMS message message
76+
/// </summary>
77+
internal static String SMSMessageMessage = "Test SMS Message";
78+
79+
/// <summary>
80+
/// The SMS message sender
81+
/// </summary>
82+
internal static String SMSMessageSender = "07000000001";
83+
84+
#endregion
85+
}
86+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
namespace MessagingService.Common.RequestExamples
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Diagnostics.CodeAnalysis;
6+
using DataTransferObjects;
7+
using Swashbuckle.AspNetCore.Filters;
8+
9+
/// <summary>
10+
///
11+
/// </summary>
12+
/// <seealso cref="Swashbuckle.AspNetCore.Filters.IMultipleExamplesProvider{MessagingService.DataTransferObjects.SendEmailRequest}" />
13+
[ExcludeFromCodeCoverage]
14+
public class SendEmailRequestExample : IMultipleExamplesProvider<SendEmailRequest>
15+
{
16+
#region Methods
17+
18+
/// <summary>
19+
/// Gets the examples.
20+
/// </summary>
21+
/// <returns></returns>
22+
public IEnumerable<SwaggerExample<SendEmailRequest>> GetExamples()
23+
{
24+
SendEmailRequest htmlEmailRequest = new SendEmailRequest
25+
{
26+
Body = ExampleData.EmailMessageHtmlBody,
27+
ConnectionIdentifier = ExampleData.ConnectionIdentifier,
28+
FromAddress = ExampleData.EmailMessageFromAddress,
29+
ToAddresses = new List<String>
30+
{
31+
ExampleData.EmailMessageToAddress1,
32+
ExampleData.EmailMessageToAddress2
33+
},
34+
IsHtml = ExampleData.EmailMessageIsHtml,
35+
MessageId = ExampleData.EmailMessageId,
36+
Subject = ExampleData.EmailMessageSubject
37+
};
38+
39+
SendEmailRequest plainTextEmailRequest = new SendEmailRequest
40+
{
41+
Body = ExampleData.EmailMessagePlainTextBody,
42+
ConnectionIdentifier = ExampleData.ConnectionIdentifier,
43+
FromAddress = ExampleData.EmailMessageFromAddress,
44+
ToAddresses = new List<String>
45+
{
46+
ExampleData.EmailMessageToAddress1,
47+
ExampleData.EmailMessageToAddress2
48+
},
49+
IsHtml = ExampleData.EmailMessagePlainTextIsHtml,
50+
MessageId = ExampleData.EmailMessageId,
51+
Subject = ExampleData.EmailMessageSubject
52+
};
53+
List<SwaggerExample<SendEmailRequest>> examples = new List<SwaggerExample<SendEmailRequest>>();
54+
examples.Add(new SwaggerExample<SendEmailRequest>
55+
{
56+
Name = "Html Email Request",
57+
Value = htmlEmailRequest
58+
});
59+
examples.Add(new SwaggerExample<SendEmailRequest>
60+
{
61+
Name = "Plan Text Email Request",
62+
Value = plainTextEmailRequest
63+
});
64+
return examples;
65+
}
66+
67+
#endregion
68+
}
69+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace MessagingService.Common.RequestExamples
2+
{
3+
using System.Diagnostics.CodeAnalysis;
4+
using DataTransferObjects;
5+
using Swashbuckle.AspNetCore.Filters;
6+
7+
/// <summary>
8+
///
9+
/// </summary>
10+
/// <seealso cref="Swashbuckle.AspNetCore.Filters.IExamplesProvider{MessagingService.DataTransferObjects.SendEmailResponse}" />
11+
[ExcludeFromCodeCoverage]
12+
public class SendEmailResponseExample : IExamplesProvider<SendEmailResponse>
13+
{
14+
#region Methods
15+
16+
/// <summary>
17+
/// Gets the examples.
18+
/// </summary>
19+
/// <returns></returns>
20+
public SendEmailResponse GetExamples()
21+
{
22+
return new SendEmailResponse
23+
{
24+
MessageId = ExampleData.EmailMessageId
25+
};
26+
}
27+
28+
#endregion
29+
}
30+
}

0 commit comments

Comments
 (0)