forked from MDCPS/DamageAssessment_Backend
Swagger Documentation Enhancement (273)
This commit is contained in:
@ -14,7 +14,10 @@ namespace DamageAssesment.Api.Locations.Controllers
|
||||
{
|
||||
this.LocationProvider = LocationsProvider;
|
||||
}
|
||||
// Get all Locations
|
||||
/// <summary>
|
||||
/// Get all locations.
|
||||
/// </summary>
|
||||
|
||||
[HttpGet("Locations")]
|
||||
public async Task<ActionResult> GetLocationsAsync()
|
||||
{
|
||||
@ -27,7 +30,10 @@ namespace DamageAssesment.Api.Locations.Controllers
|
||||
return NotFound();
|
||||
|
||||
}
|
||||
// Get all Location based on Id
|
||||
/// <summary>
|
||||
/// Get all locations based on locationdId.
|
||||
/// </summary>
|
||||
|
||||
[HttpGet("Locations/{id}")]
|
||||
public async Task<ActionResult> GetLocationByIdAsync(string id)
|
||||
{
|
||||
@ -40,7 +46,10 @@ namespace DamageAssesment.Api.Locations.Controllers
|
||||
return NotFound();
|
||||
|
||||
}
|
||||
// Update Location entity
|
||||
/// <summary>
|
||||
/// Update a Location.
|
||||
/// </summary>
|
||||
|
||||
[HttpPut("Locations")]
|
||||
public async Task<IActionResult> UpdateLocation(Db.Location Location)
|
||||
{
|
||||
@ -55,7 +64,10 @@ namespace DamageAssesment.Api.Locations.Controllers
|
||||
}
|
||||
return NotFound();
|
||||
}
|
||||
//save new location
|
||||
/// <summary>
|
||||
/// Save a new location.
|
||||
/// </summary>
|
||||
|
||||
[HttpPost("Locations")]
|
||||
public async Task<IActionResult> CreateLocation(Db.Location Location)
|
||||
{
|
||||
@ -70,7 +82,10 @@ namespace DamageAssesment.Api.Locations.Controllers
|
||||
}
|
||||
return CreatedAtRoute("DefaultApi", new { id = Location.Id }, Location);
|
||||
}
|
||||
//delete existing location
|
||||
/// <summary>
|
||||
/// Delete an existing location.
|
||||
/// </summary>
|
||||
|
||||
[HttpDelete("Locations/{id}")]
|
||||
public async Task<IActionResult> DeleteLocation(string id)
|
||||
{
|
||||
|
@ -13,8 +13,10 @@ namespace DamageAssesment.Api.Locations.Controllers
|
||||
{
|
||||
this.regionProvider = regionProvider;
|
||||
}
|
||||
/// <summary>
|
||||
/// Get all regions.
|
||||
/// </summary>
|
||||
|
||||
// Get all Regions
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetRegionsAsync()
|
||||
{
|
||||
@ -25,6 +27,9 @@ namespace DamageAssesment.Api.Locations.Controllers
|
||||
}
|
||||
return NoContent();
|
||||
}
|
||||
/// <summary>
|
||||
/// GET request for retrieving a region by its ID.
|
||||
/// </summary>
|
||||
|
||||
[HttpGet("{Id}")]
|
||||
public async Task<ActionResult> GetRegionAsync(string Id)
|
||||
@ -36,6 +41,9 @@ namespace DamageAssesment.Api.Locations.Controllers
|
||||
}
|
||||
return NotFound();
|
||||
}
|
||||
/// <summary>
|
||||
/// POST request for creating a new region.
|
||||
/// </summary>
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> PostRegionAsync(Models.Region region)
|
||||
@ -47,6 +55,9 @@ namespace DamageAssesment.Api.Locations.Controllers
|
||||
}
|
||||
return BadRequest(result.ErrorMessage);
|
||||
}
|
||||
/// <summary>
|
||||
/// PUT request for updating an existing region.
|
||||
/// </summary>
|
||||
|
||||
[HttpPut]
|
||||
public async Task<ActionResult> PutRegionAsync(Models.Region region)
|
||||
@ -61,6 +72,10 @@ namespace DamageAssesment.Api.Locations.Controllers
|
||||
|
||||
return BadRequest(result.ErrorMessage);
|
||||
}
|
||||
/// <summary>
|
||||
/// DELETE request for deleting a region based on ID.
|
||||
/// </summary>
|
||||
|
||||
|
||||
[HttpDelete("{Id}")]
|
||||
public async Task<ActionResult> DeleteRegionAsync(string Id)
|
||||
|
@ -4,6 +4,7 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -2,6 +2,7 @@ using DamageAssesment.Api.Locations.Db;
|
||||
using DamageAssesment.Api.Locations.Interfaces;
|
||||
using DamageAssesment.Api.Locations.Providers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Reflection;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@ -10,8 +11,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<ILocationsProvider, LocationsProvider>();
|
||||
builder.Services.AddScoped<IRegionsProvider, RegionsProvider>();
|
||||
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
|
||||
|
Reference in New Issue
Block a user