Swagger Documentation Enhancement (273)

This commit is contained in:
Santhosh S
2023-08-24 21:25:38 -04:00
parent 9345ee2ca5
commit e56ffae1a4
22 changed files with 288 additions and 49 deletions

View File

@ -19,7 +19,10 @@ namespace DamageAssesment.Api.Attachments.Controllers
this.AttachmentProvider = AttachmentsProvider;
this.UploadService = uploadService;
}
//get all Attachments
/// <summary>
/// Get all attachments.
/// </summary>
[HttpGet("Attachments")]
public async Task<ActionResult> GetAttachmentsAsync()
{
@ -32,7 +35,9 @@ namespace DamageAssesment.Api.Attachments.Controllers
return NoContent();
}
//get all Attachment by Id
/// <summary>
/// Get all attachments by attachmentId.
/// </summary>
[HttpGet("Attachments/{id}")]
public async Task<ActionResult> GetAttachmentbyIdAsync(int id)
{
@ -73,7 +78,10 @@ namespace DamageAssesment.Api.Attachments.Controllers
// }
//}
//Save new Attachment
/// <summary>
/// Save new Attachment(s)
/// </summary>
[HttpPost("Attachments"), DisableRequestSizeLimit]
public async Task<IActionResult> UploadAttachmentAsync(AttachmentInfo attachmentInfo)
{
@ -97,8 +105,10 @@ namespace DamageAssesment.Api.Attachments.Controllers
return BadRequest($"Internal server error: {ex}");
}
}
/// <summary>
/// Modify an new attachment.
/// </summary>
//Save new Attachment
[HttpPut("Attachments"), DisableRequestSizeLimit]
public async Task<IActionResult> UpdateAttachmentAsync(AttachmentInfo attachmentInfo)
{
@ -126,7 +136,9 @@ namespace DamageAssesment.Api.Attachments.Controllers
return BadRequest($"Internal server error: {ex}");
}
}
//delete existing Attachment
/// <summary>
/// Delete an existing attachment.
/// </summary>
[HttpDelete("Delete")]
public async Task<IActionResult> DeleteAttachment(int Id)
{

View File

@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>

View File

@ -4,6 +4,7 @@ using DamageAssesment.Api.Attachments.Providers;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.FileProviders;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
@ -12,7 +13,14 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
//builder.Services.AddSwaggerGen();
builder.Services.AddSwaggerGen(c =>
{
// Include XML comments from your assembly
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
builder.Services.AddScoped<IAttachmentsProvider, AttachmentsProvider>();
builder.Services.AddScoped<IUploadService, UploadService>();
builder.Services.AddScoped<IAzureBlobService,AzureBlobService>();