From 3d415b69030bee1d4664fcc20dce3d2e3d2bf055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ben=C3=AD=C4=8Dek?= Date: Thu, 30 Nov 2023 16:46:33 +0100 Subject: [PATCH] Fix Api descriptions --- API_SequentMicrosystems.csproj | 9 +++++++++ Controllers/PointsController.cs | 16 +++++++++++++--- Controllers/RTDDataAcquisitionController.cs | 11 ++++++++--- Program.cs | 19 ++++++++++++++++--- Properties/launchSettings.json | 4 ++-- Services/PointsService.cs | 9 +++++++++ 6 files changed, 57 insertions(+), 11 deletions(-) diff --git a/API_SequentMicrosystems.csproj b/API_SequentMicrosystems.csproj index 4cac697..0dcdebb 100644 --- a/API_SequentMicrosystems.csproj +++ b/API_SequentMicrosystems.csproj @@ -5,6 +5,15 @@ enable enable true + True + + + + 1701;1702;1591 + + + + 1701;1702;1591 diff --git a/Controllers/PointsController.cs b/Controllers/PointsController.cs index 28e0078..f1e94db 100644 --- a/Controllers/PointsController.cs +++ b/Controllers/PointsController.cs @@ -50,7 +50,7 @@ namespace API_SequentMicrosystems.Controllers /// Read points from and to specified points positions /// /// limit of returned points (Maximum 1000) - /// id of start element + /// start element /// [HttpPost("{limit}")] public List Post(int limit, [FromBody] PointsModel pm) @@ -76,7 +76,6 @@ namespace API_SequentMicrosystems.Controllers /// /// Read points from first to specified number /// - /// max readed points /// [HttpGet("Count")] public int GetCount() @@ -94,6 +93,17 @@ namespace API_SequentMicrosystems.Controllers _PointsService.DeletePoints(); } + //DELETE api/points + /// + /// Delete Specified saved point + /// + /// Point ID + [HttpDelete("{id}")] + public void Delete(int id) + { + _PointsService.DeletePoint(id); + } + //GET api/points/save /// /// Save new point @@ -108,7 +118,7 @@ namespace API_SequentMicrosystems.Controllers /// /// Start timer to automatic saving points in specified interval /// - /// + /// [HttpGet("AutoSave/{msec}")] public void GetSaveSec(int msec) { diff --git a/Controllers/RTDDataAcquisitionController.cs b/Controllers/RTDDataAcquisitionController.cs index 32dd97a..1f1ca30 100644 --- a/Controllers/RTDDataAcquisitionController.cs +++ b/Controllers/RTDDataAcquisitionController.cs @@ -5,8 +5,9 @@ using Microsoft.AspNetCore.Mvc; namespace API_SequentMicrosystems.Controllers { + [Tags("RTD-8 Temperature Module")] - [Route("RTDDA")] + [Route("api/RTDDA")] [ApiController] public class RTDDataAcquisitionController : ControllerBase { @@ -74,7 +75,7 @@ namespace API_SequentMicrosystems.Controllers //GET api/RTDDA/Names/Preconfigured /// - /// Get preconfigured Names for chanels + /// Get preconfigured Names /// /// [HttpGet("Names/Preconfigured")] @@ -85,7 +86,7 @@ namespace API_SequentMicrosystems.Controllers //POST api/RTDDA/Names/Preconfigured /// - /// Post preconfigured names for chanels + /// Post preconfigured names /// /// [HttpPost("Names/Preconfigured")] @@ -106,6 +107,10 @@ namespace API_SequentMicrosystems.Controllers } //POST api/RTDDA/Calibration + /// + /// Post Calibration data + /// + /// [HttpPost("Calibration")] public void PostCalibration([FromBody] SortedList data) { diff --git a/Program.cs b/Program.cs index c32d6d6..bd7eb0f 100644 --- a/Program.cs +++ b/Program.cs @@ -1,4 +1,5 @@ using API_SequentMicrosystems.Services; +using System.Reflection; using System.Text.Json; using System.Text.Json.Serialization; @@ -19,15 +20,27 @@ namespace API_SequentMicrosystems // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle 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(); // Configure the HTTP request pipeline. if (true)//app.Environment.IsDevelopment()) { - app.UseSwagger(); - app.UseSwaggerUI(); + app.UseSwagger(c => + { + c.RouteTemplate = "api/{documentName}/swagger.json"; + }); + app.UseSwaggerUI(c => + { + c.SwaggerEndpoint("/api/v1/swagger.json", "V1"); + c.RoutePrefix = "api"; + }); } app.UseAuthorization(); diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index 170db4c..b80895a 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -13,7 +13,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "launchUrl": "swagger", + "launchUrl": "api", "applicationUrl": "http://localhost:5242", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" @@ -22,7 +22,7 @@ "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, - "launchUrl": "swagger", + "launchUrl": "api", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/Services/PointsService.cs b/Services/PointsService.cs index 01232a2..b01d3f2 100644 --- a/Services/PointsService.cs +++ b/Services/PointsService.cs @@ -106,6 +106,15 @@ namespace API_SequentMicrosystems.Services SavePoints(); } + /// + /// Delete Specified Point + /// + /// + public void DeletePoint(int id) + { + _points.RemoveAt(id); + } + /// /// Create actual point object ///