forked from MDCPS/DamageAssessment_Backend
Swagger Documentation Enhancement (273)
This commit is contained in:
@ -14,6 +14,9 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
||||
{
|
||||
this.surveyProvider = surveyProvider;
|
||||
}
|
||||
/// <summary>
|
||||
/// GET request for retrieving surveys.
|
||||
/// </summary>
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetSurveysAsync()
|
||||
@ -25,6 +28,10 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
||||
}
|
||||
return NoContent();
|
||||
}
|
||||
/// <summary>
|
||||
/// GET request for retrieving surveys by ID.
|
||||
/// </summary>
|
||||
|
||||
[HttpGet("{Id}")]
|
||||
public async Task<ActionResult> GetSurveysAsync(int Id)
|
||||
{
|
||||
@ -35,6 +42,9 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
||||
}
|
||||
return NotFound();
|
||||
}
|
||||
/// <summary>
|
||||
/// POST request for creating a new survey.
|
||||
/// </summary>
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> PostSurveysAsync(Models.Survey survey)
|
||||
@ -46,6 +56,10 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
||||
}
|
||||
return BadRequest(result.ErrorMessage);
|
||||
}
|
||||
/// <summary>
|
||||
/// PUT request for updating an existing survey (surveyId,Updated Survey data).
|
||||
/// </summary>
|
||||
|
||||
|
||||
[HttpPut("{Id}")]
|
||||
public async Task<ActionResult> PutSurveysAsync(int Id, Models.Survey survey)
|
||||
@ -60,7 +74,10 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
||||
|
||||
return BadRequest(result.ErrorMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DELETE request for deleting a survey by ID.
|
||||
/// </summary>
|
||||
|
||||
[HttpDelete("{Id}")]
|
||||
public async Task<ActionResult> DeleteSurveysAsync(int Id)
|
||||
{
|
||||
|
@ -1,9 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -2,6 +2,7 @@ using DamageAssesment.Api.Surveys.Db;
|
||||
using DamageAssesment.Api.Surveys.Interfaces;
|
||||
using DamageAssesment.Api.Surveys.Providers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Reflection;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@ -12,7 +13,14 @@ builder.Services.AddControllers();
|
||||
builder.Services.AddScoped<ISurveyProvider, SurveysProvider>();
|
||||
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
||||
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.AddDbContext<SurveysDbContext>(option =>
|
||||
{
|
||||
option.UseInMemoryDatabase("Surveys");
|
||||
|
Reference in New Issue
Block a user