From 75c83ff9b16c9b481b4363ce1b2b13ce176ea346 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Wed, 14 Apr 2021 12:07:57 +0100 Subject: [PATCH] Minor swagger updates --- ...essagingService.DataTransferObjects.csproj | 6 +- .../MessagingService.DataTransferObjects.xml | 125 +++++++ .../Controllers/DomainEventController.cs | 1 + .../Controllers/EmailController.cs | 10 +- MessagingService/Controllers/SMSController.cs | 9 +- MessagingService/MessagingService.csproj | 4 + MessagingService/MessagingService.xml | 353 ++++++++++++++++++ MessagingService/Startup.cs | 10 + 8 files changed, 506 insertions(+), 12 deletions(-) create mode 100644 MessagingService.DataTransferObjects/MessagingService.DataTransferObjects.xml create mode 100644 MessagingService/MessagingService.xml diff --git a/MessagingService.DataTransferObjects/MessagingService.DataTransferObjects.csproj b/MessagingService.DataTransferObjects/MessagingService.DataTransferObjects.csproj index 7792513..48bbc79 100644 --- a/MessagingService.DataTransferObjects/MessagingService.DataTransferObjects.csproj +++ b/MessagingService.DataTransferObjects/MessagingService.DataTransferObjects.csproj @@ -1,9 +1,13 @@ - + net5.0;netstandard2.0 + + D:\Projects\StuartFerguson\Messaging\MessagingService.DataTransferObjects\MessagingService.DataTransferObjects.xml + + diff --git a/MessagingService.DataTransferObjects/MessagingService.DataTransferObjects.xml b/MessagingService.DataTransferObjects/MessagingService.DataTransferObjects.xml new file mode 100644 index 0000000..89a957a --- /dev/null +++ b/MessagingService.DataTransferObjects/MessagingService.DataTransferObjects.xml @@ -0,0 +1,125 @@ + + + + MessagingService.DataTransferObjects + + + + + Gets or sets the message identifier. + + + The message identifier. + + + + + Gets or sets the body. + + + The body. + + + + + Gets or sets the connection identifier. + + + The connection identifier. + + + + + Gets or sets from address. + + + From address. + + + + + Gets or sets a value indicating whether this instance is HTML. + + + true if this instance is HTML; otherwise, false. + + + + + Gets or sets the subject. + + + The subject. + + + + + Gets or sets to addresses. + + + To addresses. + + + + + + + + + + Gets or sets the message identifier. + + + The message identifier. + + + + + Gets or sets the connection identifier. + + + The connection identifier. + + + + + Gets or sets the destination. + + + The destination. + + + + + Gets or sets the message. + + + The message. + + + + + Gets or sets the message identifier. + + + The message identifier. + + + + + Gets or sets the sender. + + + The sender. + + + + + Gets or sets the message identifier. + + + The message identifier. + + + + diff --git a/MessagingService/Controllers/DomainEventController.cs b/MessagingService/Controllers/DomainEventController.cs index 6f65db4..3ca43f1 100644 --- a/MessagingService/Controllers/DomainEventController.cs +++ b/MessagingService/Controllers/DomainEventController.cs @@ -22,6 +22,7 @@ [Route(DomainEventController.ControllerRoute)] [ApiController] [ExcludeFromCodeCoverage] + [ApiExplorerSettings(IgnoreApi = true)] public class DomainEventController : ControllerBase { #region Fields diff --git a/MessagingService/Controllers/EmailController.cs b/MessagingService/Controllers/EmailController.cs index dddafe5..666b42e 100644 --- a/MessagingService/Controllers/EmailController.cs +++ b/MessagingService/Controllers/EmailController.cs @@ -49,19 +49,17 @@ public EmailController(IMediator mediator) #endregion #region Methods - + /// - /// Posts the email. + /// Sends the email. /// /// The send email request. /// The cancellation token. /// [HttpPost] [Route("")] - [SwaggerResponse(201, "Created", typeof(SendEmailResponseDTO))] - [SwaggerResponseExample(201, typeof(SendEmailResponseExample))] - - public async Task PostEmail([FromBody] SendEmailRequestDTO sendEmailRequest, + [ProducesResponseType(typeof(SendEmailResponseDTO), 201)] + public async Task SendEmail([FromBody] SendEmailRequestDTO sendEmailRequest, CancellationToken cancellationToken) { // Reject password tokens diff --git a/MessagingService/Controllers/SMSController.cs b/MessagingService/Controllers/SMSController.cs index aee6efb..e9b89fa 100644 --- a/MessagingService/Controllers/SMSController.cs +++ b/MessagingService/Controllers/SMSController.cs @@ -42,18 +42,17 @@ public SMSController(IMediator mediator) #endregion #region Methods - + /// - /// Posts the sms. + /// Sends the SMS. /// /// The send SMS request. /// The cancellation token. /// [HttpPost] [Route("")] - [SwaggerResponse(201, "Created", typeof(SendSMSResponse))] - [SwaggerResponseExample(201, typeof(SendSMSResponseExample))] - public async Task PostSMS([FromBody] SendSMSRequest sendSMSRequest, + [ProducesResponseType(typeof(SendSMSResponse), 201)] + public async Task SendSMS([FromBody] SendSMSRequest sendSMSRequest, CancellationToken cancellationToken) { // Reject password tokens diff --git a/MessagingService/MessagingService.csproj b/MessagingService/MessagingService.csproj index b3b37f8..5055e76 100644 --- a/MessagingService/MessagingService.csproj +++ b/MessagingService/MessagingService.csproj @@ -5,6 +5,10 @@ Linux + + D:\Projects\StuartFerguson\Messaging\MessagingService\MessagingService.xml + + diff --git a/MessagingService/MessagingService.xml b/MessagingService/MessagingService.xml new file mode 100644 index 0000000..1fec977 --- /dev/null +++ b/MessagingService/MessagingService.xml @@ -0,0 +1,353 @@ + + + + MessagingService + + + + + Gets the user claims. + + The user. + Type of the custom claim. + The default value. + + No claim [{customClaimType}] found for user id [{userIdClaim.Value} + + + + Determines whether [is client token] [the specified user]. + + The user. + + true if [is client token] [the specified user]; otherwise, false. + + + + + Validates the route parameter. + + + The route parameter. + The user claim. + + + + Determines whether [is user roles valid] [the specified user]. + + The user. + The allowed roles. + + true if [is user roles valid] [the specified user]; otherwise, false. + + + + + + + + + + The connection identifier + + + + + The email message from address + + + + + The email message HTML body + + + + + The email message identifier + + + + + The email message is HTML + + + + + The email message plain text body + + + + + The email message plain text is HTML + + + + + The email message subject + + + + + The email message to address1 + + + + + The email message to address2 + + + + + The SMS message destination + + + + + The SMS message identifier + + + + + The SMS message message + + + + + The SMS message sender + + + + + + + + + + + Gets the examples. + + + + + + + + + + + + Gets the examples. + + + + + + + + + + + + Gets the examples. + + + + + + + + + + + + Gets the examples. + + + + + + Represents the Swagger/Swashbuckle operation filter used to document the implicit API version parameter. + + This is only required due to bugs in the . + Once they are fixed and published, this class can be removed. + + + + Applies the filter to the specified operation using the given context. + + The operation to apply the filter to. + The current operation filter context. + + + + + + + + + + Gets a value indicating whether this can read JSON. + + + true if this can read JSON; otherwise, false. + + + + + Determines whether this instance can convert the specified object type. + + Type of the object. + + true if this instance can convert the specified object type; otherwise, false. + + + + + Reads the JSON representation of the object. + + The to read from. + Type of the object. + The existing value of object being read. + The calling serializer. + + The object value. + + + + + + + Writes the JSON representation of the object. + + The to write to. + The value. + The calling serializer. + + + + + + + + + + The domain event handler resolver + + + + + Initializes a new instance of the class. + + The domain event handler resolver. + + + + Posts the event asynchronous. + + The domain event. + The cancellation token. + + + + + Callbacks the specified cancellation token. + + The cancellation token. + The event identifier. + + + + Gets the domain event. + + The domain event. + + + + + The controller name + + + + + The controller route + + + + + + + + + + + The mediator + + + + + Initializes a new instance of the class. + + The mediator. + + + + Sends the email. + + The send email request. + The cancellation token. + + + + + The controller name + + + + + The controller route + + + + + The mediator + + + + + Initializes a new instance of the class. + + The mediator. + + + + Sends the SMS. + + The send SMS request. + The cancellation token. + + + + + The controller name + + + + + The controller route + + + + + Workers the trace generated. + + The trace. + The log level. + + + + Registers the email proxy. + + The services. + + + diff --git a/MessagingService/Startup.cs b/MessagingService/Startup.cs index 7e4e28c..5ab0a32 100644 --- a/MessagingService/Startup.cs +++ b/MessagingService/Startup.cs @@ -249,6 +249,16 @@ private void ConfigureMiddlewareServices(IServiceCollection services) // add a custom operation filter which sets default values c.OperationFilter(); c.ExampleFilters(); + + //Locate the XML files being generated by ASP.NET... + var directory = new DirectoryInfo(AppContext.BaseDirectory); + var xmlFiles = directory.GetFiles("*.xml"); + + //... and tell Swagger to use those XML comments. + foreach (FileInfo fileInfo in xmlFiles) + { + c.IncludeXmlComments(fileInfo.FullName); + } }); services.AddSwaggerExamplesFromAssemblyOf();