forked from MDCPS/DamageAssessment_Backend
Swagger Documentation Enhancement (273)
This commit is contained in:
@ -19,7 +19,10 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
this.questionsProvider = questionsProvider;
|
||||
|
||||
}
|
||||
// get all questions
|
||||
/// <summary>
|
||||
/// GET request for retrieving questions.
|
||||
/// </summary>
|
||||
|
||||
[HttpGet("Questions")]
|
||||
public async Task<IActionResult> GetQuestionsAsync()
|
||||
{
|
||||
@ -30,7 +33,10 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
}
|
||||
return NoContent();
|
||||
}
|
||||
//Get questions based on question id
|
||||
/// <summary>
|
||||
/// GET request for retrieving a question by ID.
|
||||
/// </summary>
|
||||
|
||||
[HttpGet("Questions/{id}")]
|
||||
public async Task<IActionResult> GetQuestionAsync(int id)
|
||||
{
|
||||
@ -41,7 +47,11 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
}
|
||||
return NotFound();
|
||||
}
|
||||
//get all questions based on survey id
|
||||
/// <summary>
|
||||
/// GET request for retrieving survey questions based on a survey ID.
|
||||
/// Uri: {Optional language}/GetSurveyQuestions/{surveyId} :Default returns question in all languages
|
||||
/// </summary>
|
||||
|
||||
[HttpGet("GetSurveyQuestions/{surveyId}")]
|
||||
public async Task<IActionResult> GetSurveyQuestions(int surveyId,string? Language)
|
||||
{
|
||||
@ -53,7 +63,10 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
}
|
||||
return NotFound();
|
||||
}
|
||||
//update existing question
|
||||
/// <summary>
|
||||
/// PUT request for updating a question (multilingual).
|
||||
/// </summary>
|
||||
|
||||
[HttpPut("Questions")]
|
||||
public async Task<IActionResult> UpdateQuestion(Models.Question question)
|
||||
{
|
||||
@ -71,7 +84,10 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
}
|
||||
return CreatedAtRoute("DefaultApi", new { id = question.Id }, question);
|
||||
}
|
||||
//save new question
|
||||
/// <summary>
|
||||
/// POST request for creating a new question (multilingual).
|
||||
/// </summary>
|
||||
|
||||
[HttpPost("Questions")]
|
||||
public async Task<IActionResult> CreateQuestion(Models.Question question)
|
||||
{
|
||||
@ -86,7 +102,10 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
}
|
||||
return CreatedAtRoute("DefaultApi", new { id = question.Id }, question);
|
||||
}
|
||||
// delete existing question
|
||||
/// <summary>
|
||||
/// DELETE request for deleting a question based on ID.
|
||||
/// </summary>
|
||||
|
||||
[HttpDelete("Questions/{id}")]
|
||||
public async Task<IActionResult> DeleteQuestion(int id)
|
||||
{
|
||||
@ -99,7 +118,10 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
}
|
||||
|
||||
|
||||
// get all questions
|
||||
/// <summary>
|
||||
/// GET request for retrieving question categories.
|
||||
/// </summary>
|
||||
|
||||
[HttpGet("QuestionCategories")]
|
||||
public async Task<IActionResult> GetQuestionCategoriesAsync()
|
||||
{
|
||||
@ -110,7 +132,10 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
}
|
||||
return NoContent();
|
||||
}
|
||||
//Get questions based on question id
|
||||
/// <summary>
|
||||
/// GET request for retrieving a question category by ID.
|
||||
/// </summary>
|
||||
|
||||
[HttpGet("QuestionCategories/{id}")]
|
||||
public async Task<IActionResult> GetQuestionCategoryAsync(int id)
|
||||
{
|
||||
@ -123,7 +148,10 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
}
|
||||
|
||||
|
||||
//update existing question
|
||||
/// <summary>
|
||||
/// PUT request for updating a question category.
|
||||
/// </summary>
|
||||
|
||||
[HttpPut("QuestionCategories")]
|
||||
public async Task<IActionResult> UpdateQuestionCategory(Models.QuestionCategory questionCategory)
|
||||
{
|
||||
@ -141,7 +169,10 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
}
|
||||
return CreatedAtRoute("DefaultApi", new { id = questionCategory.Id }, questionCategory);
|
||||
}
|
||||
//save new question
|
||||
/// <summary>
|
||||
/// POST request for creating a new question category.
|
||||
/// </summary>
|
||||
|
||||
[HttpPost("QuestionCategories")]
|
||||
public async Task<IActionResult> CreateQuestionCategory(Models.QuestionCategory questionCategory)
|
||||
{
|
||||
@ -156,7 +187,10 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
}
|
||||
return CreatedAtRoute("DefaultApi", new { id = questionCategory.Id }, questionCategory);
|
||||
}
|
||||
// delete existing question
|
||||
/// <summary>
|
||||
/// DELETE request for deleting a question category based on ID.
|
||||
/// </summary>
|
||||
|
||||
[HttpDelete("QuestionCategories/{id}")]
|
||||
public async Task<IActionResult> DeleteQuestionCategory(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>
|
||||
|
@ -3,6 +3,7 @@ using DamageAssesment.Api.Questions.Interfaces;
|
||||
using DamageAssesment.Api.Questions.Providers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Reflection;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@ -17,7 +18,14 @@ 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<QuestionDbContext>(option =>
|
||||
{
|
||||
option.UseInMemoryDatabase("Questions");
|
||||
|
Reference in New Issue
Block a user