Fix Api descriptions

master
Jan Beníček 2023-11-30 16:46:33 +01:00
parent 4944df9c8a
commit 3d415b6903
6 changed files with 57 additions and 11 deletions

View File

@ -5,6 +5,15 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization> <InvariantGlobalization>true</InvariantGlobalization>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -50,7 +50,7 @@ namespace API_SequentMicrosystems.Controllers
/// Read points from and to specified points positions /// Read points from and to specified points positions
/// </summary> /// </summary>
/// <param name="limit">limit of returned points (Maximum 1000)</param> /// <param name="limit">limit of returned points (Maximum 1000)</param>
/// <param name="start">id of start element</param> /// <param name="pm">start element</param>
/// <returns></returns> /// <returns></returns>
[HttpPost("{limit}")] [HttpPost("{limit}")]
public List<PointsModel> Post(int limit, [FromBody] PointsModel pm) public List<PointsModel> Post(int limit, [FromBody] PointsModel pm)
@ -76,7 +76,6 @@ namespace API_SequentMicrosystems.Controllers
/// <summary> /// <summary>
/// Read points from first to specified number /// Read points from first to specified number
/// </summary> /// </summary>
/// <param name="max">max readed points</param>
/// <returns></returns> /// <returns></returns>
[HttpGet("Count")] [HttpGet("Count")]
public int GetCount() public int GetCount()
@ -94,6 +93,17 @@ namespace API_SequentMicrosystems.Controllers
_PointsService.DeletePoints(); _PointsService.DeletePoints();
} }
//DELETE api/points
/// <summary>
/// Delete Specified saved point
/// </summary>
/// <param name="id">Point ID</param>
[HttpDelete("{id}")]
public void Delete(int id)
{
_PointsService.DeletePoint(id);
}
//GET api/points/save //GET api/points/save
/// <summary> /// <summary>
/// Save new point /// Save new point
@ -108,7 +118,7 @@ namespace API_SequentMicrosystems.Controllers
/// <summary> /// <summary>
/// Start timer to automatic saving points in specified interval /// Start timer to automatic saving points in specified interval
/// </summary> /// </summary>
/// <param name="sec"></param> /// <param name="msec"></param>
[HttpGet("AutoSave/{msec}")] [HttpGet("AutoSave/{msec}")]
public void GetSaveSec(int msec) public void GetSaveSec(int msec)
{ {

View File

@ -5,8 +5,9 @@ using Microsoft.AspNetCore.Mvc;
namespace API_SequentMicrosystems.Controllers namespace API_SequentMicrosystems.Controllers
{ {
[Tags("RTD-8 Temperature Module")] [Tags("RTD-8 Temperature Module")]
[Route("RTDDA")] [Route("api/RTDDA")]
[ApiController] [ApiController]
public class RTDDataAcquisitionController : ControllerBase public class RTDDataAcquisitionController : ControllerBase
{ {
@ -74,7 +75,7 @@ namespace API_SequentMicrosystems.Controllers
//GET api/RTDDA/Names/Preconfigured //GET api/RTDDA/Names/Preconfigured
/// <summary> /// <summary>
/// Get preconfigured Names for chanels /// Get preconfigured Names
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpGet("Names/Preconfigured")] [HttpGet("Names/Preconfigured")]
@ -85,7 +86,7 @@ namespace API_SequentMicrosystems.Controllers
//POST api/RTDDA/Names/Preconfigured //POST api/RTDDA/Names/Preconfigured
/// <summary> /// <summary>
/// Post preconfigured names for chanels /// Post preconfigured names
/// </summary> /// </summary>
/// <param name="data"></param> /// <param name="data"></param>
[HttpPost("Names/Preconfigured")] [HttpPost("Names/Preconfigured")]
@ -106,6 +107,10 @@ namespace API_SequentMicrosystems.Controllers
} }
//POST api/RTDDA/Calibration //POST api/RTDDA/Calibration
/// <summary>
/// Post Calibration data
/// </summary>
/// <param name="data"></param>
[HttpPost("Calibration")] [HttpPost("Calibration")]
public void PostCalibration([FromBody] SortedList<byte, float[]> data) public void PostCalibration([FromBody] SortedList<byte, float[]> data)
{ {

View File

@ -1,4 +1,5 @@
using API_SequentMicrosystems.Services; using API_SequentMicrosystems.Services;
using System.Reflection;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@ -19,15 +20,27 @@ namespace API_SequentMicrosystems
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(); builder.Services.AddSwaggerGen(c =>
{
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
var app = builder.Build(); var app = builder.Build();
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (true)//app.Environment.IsDevelopment()) if (true)//app.Environment.IsDevelopment())
{ {
app.UseSwagger(); app.UseSwagger(c =>
app.UseSwaggerUI(); {
c.RouteTemplate = "api/{documentName}/swagger.json";
});
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/api/v1/swagger.json", "V1");
c.RoutePrefix = "api";
});
} }
app.UseAuthorization(); app.UseAuthorization();

View File

@ -13,7 +13,7 @@
"commandName": "Project", "commandName": "Project",
"dotnetRunMessages": true, "dotnetRunMessages": true,
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "swagger", "launchUrl": "api",
"applicationUrl": "http://localhost:5242", "applicationUrl": "http://localhost:5242",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
@ -22,7 +22,7 @@
"IIS Express": { "IIS Express": {
"commandName": "IISExpress", "commandName": "IISExpress",
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "swagger", "launchUrl": "api",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@ -106,6 +106,15 @@ namespace API_SequentMicrosystems.Services
SavePoints(); SavePoints();
} }
/// <summary>
/// Delete Specified Point
/// </summary>
/// <param name="id"></param>
public void DeletePoint(int id)
{
_points.RemoveAt(id);
}
/// <summary> /// <summary>
/// Create actual point object /// Create actual point object
/// </summary> /// </summary>