From e693e1ea332e6a4635c0c74334e177e0d9d8da4b Mon Sep 17 00:00:00 2001 From: Detlef Runde Date: Thu, 2 Jun 2022 11:51:40 +0200 Subject: [PATCH] version 1.0.0 --- readme.md | 4 +-- .../ControllersImpl/DefaultApiImpl.cs | 4 +-- .../ControllersImpl/TrackablesApiImpl.cs | 34 +++++++++++++++++-- .../ControllersImpl/WorldAnchorsApiImpl.cs | 34 ++++++++++++++++++- .../ControllersImpl/WorldLinksApiImpl.cs | 32 ++++++++++++++++- server/src/Org.OpenAPITools/Startup.cs | 8 ++--- server/src/Org.OpenAPITools/appsettings.json | 2 +- 7 files changed, 105 insertions(+), 13 deletions(-) diff --git a/readme.md b/readme.md index d8e60a6..1e37de1 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# Description of version 0.0.6 +# Description of version 1.0.0 auto-generated ASP.NET server code @@ -75,7 +75,7 @@ and at the value that is to become the MongoDB ID, add: ### folder `Services` the folder `Services` should contain one common class with the DatabaseSettings (`DatabaseSettings.cs`) and one with the database-access-methods (create, get, update, remove) for each API. If some are missing create them like the ones you find there. Be aware to add the reference to these in the file `startup.cs` in this case. -the naming in the DatabaseSettings is the same as defined in `appsettings.json`, which you have to extend when creating new classes in this folder. changed `appsettings.json` in the folder `docker` accordingly. Make sure that the ConnectionString for the database contains the correct IP address as specified in `docker-compose.yml`. +the naming in the DatabaseSettings is the same as defined in `appsettings.json`, which you have to extend when creating new classes in this folder. Change `appsettings.json` in the folder `docker` accordingly. Make sure that the ConnectionString for the database contains the correct IP address as specified in `docker-compose.yml`. ### folder `wwwroot` add in `openapi-original.json` in section `servers` the urls of the servers you want to use with swagger-ui diff --git a/server/src/Org.OpenAPITools/ControllersImpl/DefaultApiImpl.cs b/server/src/Org.OpenAPITools/ControllersImpl/DefaultApiImpl.cs index 5d7c9fa..05d7b2c 100644 --- a/server/src/Org.OpenAPITools/ControllersImpl/DefaultApiImpl.cs +++ b/server/src/Org.OpenAPITools/ControllersImpl/DefaultApiImpl.cs @@ -3,7 +3,7 @@ * * API ensuring interoperability between an authoring tool and a World Storage service * - * The version of the OpenAPI document: 0.0.6 + * The version of the OpenAPI document: 1.0.0 * * Generated by: https://openapi-generator.tech */ @@ -72,7 +72,7 @@ namespace Org.OpenAPITools.Controllers [SwaggerResponse(statusCode: 200, type: typeof(string), description: "Current version.")] public override IActionResult GetVersion() { - string version = "0.0.6"; + string version = "1.0.0"; return new ObjectResult(version); //return StatusCode(200, new ObjectResult(version)); } diff --git a/server/src/Org.OpenAPITools/ControllersImpl/TrackablesApiImpl.cs b/server/src/Org.OpenAPITools/ControllersImpl/TrackablesApiImpl.cs index 4068462..8564cff 100644 --- a/server/src/Org.OpenAPITools/ControllersImpl/TrackablesApiImpl.cs +++ b/server/src/Org.OpenAPITools/ControllersImpl/TrackablesApiImpl.cs @@ -3,7 +3,7 @@ * * API ensuring interoperability between an authoring tool and a World Storage service * - * The version of the OpenAPI document: 0.0.6 + * The version of the OpenAPI document: 1.0.0 * * Generated by: https://openapi-generator.tech */ @@ -70,7 +70,7 @@ namespace Org.OpenAPITools.Controllers return new ObjectResult(mytrackable); } catch (Exception e) - { + { return StatusCode(400, e.Message); } } @@ -150,5 +150,35 @@ namespace Org.OpenAPITools.Controllers List trackablelist = _trackableService.Get(); return new ObjectResult(trackablelist); } + + + + /// + /// Modify a Trackable. + /// + /// Modify an existing Trackable given a json object containing all the required informations. <br> **Please note that ID of the object is required in the JSON** + /// The Trackable to be modified in the world storage. + /// OK, return the UUID of the modified Trackable. + /// Bad request. + /// Not found, could not find UUID in database. + /// Unexpected error. + [HttpPut] + [Route("/trackables")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("ModifyTrackable")] + [SwaggerResponse(statusCode: 0, type: typeof(Error), description: "Unexpected error.")] + public override IActionResult ModifyTrackable([FromBody] Trackable trackable) + { + ReplaceOneResult result = _trackableService.Update(trackable.UUID, trackable); + if (result.MatchedCount == 0) + { + return StatusCode(404, "Not found, could not find UUID in database."); + } + else + { + return StatusCode(200, trackable.UUID); + } + } } } diff --git a/server/src/Org.OpenAPITools/ControllersImpl/WorldAnchorsApiImpl.cs b/server/src/Org.OpenAPITools/ControllersImpl/WorldAnchorsApiImpl.cs index 003a748..890aebd 100644 --- a/server/src/Org.OpenAPITools/ControllersImpl/WorldAnchorsApiImpl.cs +++ b/server/src/Org.OpenAPITools/ControllersImpl/WorldAnchorsApiImpl.cs @@ -3,7 +3,7 @@ * * API ensuring interoperability between an authoring tool and a World Storage service * - * The version of the OpenAPI document: 0.0.6 + * The version of the OpenAPI document: 1.0.0 * * Generated by: https://openapi-generator.tech */ @@ -150,5 +150,37 @@ namespace Org.OpenAPITools.Controllers List worldanchorlist = _worldAnchorService.Get(); return new ObjectResult(worldanchorlist); } + + + + /// + /// Modify a World Anchor. + /// + /// Modify an existing World Anchor given a json object containing all the required informations. <br> **Please note that ID of the object is required in the JSON** + /// The World Anchor to be modified in the world storage. + /// OK, return the UUID of the modified World Anchor. + /// Bad request. + /// Not found, could not find UUID in database. + /// Unexpected error. + [HttpPut] + [Route("/worldAnchors")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("ModifyWorldAnchor")] + [SwaggerResponse(statusCode: 0, type: typeof(Error), description: "Unexpected error.")] + public override IActionResult ModifyWorldAnchor([FromBody] WorldAnchor worldAnchor) + { + ReplaceOneResult result = _worldAnchorService.Update(worldAnchor.UUID, worldAnchor); + if (result.MatchedCount == 0) + { + return StatusCode(404, "Not found, could not find UUID in database."); + } + else + { + return StatusCode(200, worldAnchor.UUID); + } + } + + } } diff --git a/server/src/Org.OpenAPITools/ControllersImpl/WorldLinksApiImpl.cs b/server/src/Org.OpenAPITools/ControllersImpl/WorldLinksApiImpl.cs index 14cb079..60d1335 100644 --- a/server/src/Org.OpenAPITools/ControllersImpl/WorldLinksApiImpl.cs +++ b/server/src/Org.OpenAPITools/ControllersImpl/WorldLinksApiImpl.cs @@ -3,7 +3,7 @@ * * API ensuring interoperability between an authoring tool and a World Storage service * - * The version of the OpenAPI document: 0.0.6 + * The version of the OpenAPI document: 1.0.0 * * Generated by: https://openapi-generator.tech */ @@ -201,5 +201,35 @@ namespace Org.OpenAPITools.Controllers } return new ObjectResult(worldlinklist); } + + + + /// + /// Modify a World Link. + /// + /// Modify an existing World Link given a json object containing all the required informations. <br> **Please note that ID of the object is required in the JSON** + /// The World Link to be modified in the world storage. + /// OK, return the UUID of the modified World Link. + /// Bad request. + /// Not found, could not find UUID in database. + /// Unexpected error. + [HttpPut] + [Route("/worldLinks")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("ModifyWorldLink")] + [SwaggerResponse(statusCode: 0, type: typeof(Error), description: "Unexpected error.")] + public override IActionResult ModifyWorldLink([FromBody] WorldLink worldLink) + { + ReplaceOneResult result = _worldLinkService.Update(worldLink.UUID, worldLink); + if (result.MatchedCount == 0) + { + return StatusCode(404, "Not found, could not find UUID in database."); + } + else + { + return StatusCode(200, worldLink.UUID); + } + } } } diff --git a/server/src/Org.OpenAPITools/Startup.cs b/server/src/Org.OpenAPITools/Startup.cs index c9e1470..02e91fd 100644 --- a/server/src/Org.OpenAPITools/Startup.cs +++ b/server/src/Org.OpenAPITools/Startup.cs @@ -3,7 +3,7 @@ * * API ensuring interoperability between an authoring tool and a World Storage service * - * The version of the OpenAPI document: 0.0.6 + * The version of the OpenAPI document: 1.0.0 * * Generated by: https://openapi-generator.tech */ @@ -88,7 +88,7 @@ namespace Org.OpenAPITools services .AddSwaggerGen(c => { - c.SwaggerDoc("0.0.6", new OpenApiInfo + c.SwaggerDoc("1.0.0", new OpenApiInfo { Title = "World Storage API", Description = "World Storage API (ASP.NET Core 3.1)", @@ -104,7 +104,7 @@ namespace Org.OpenAPITools Name = "NoLicense", Url = new Uri("https://opensource.org/licenses/BSD-3-Clause") }, - Version = "0.0.6", + Version = "1.0.0", }); c.CustomSchemaIds(type => type.FriendlyId(true)); c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{Assembly.GetEntryAssembly().GetName().Name}.xml"); @@ -145,7 +145,7 @@ namespace Org.OpenAPITools // set route prefix to openapi, e.g. http://localhost:8080/openapi/index.html c.RoutePrefix = "openapi"; //TODO: Either use the SwaggerGen generated OpenAPI contract (generated from C# classes) - //c.SwaggerEndpoint("/openapi/0.0.6/openapi.json", "World Storage API"); + //c.SwaggerEndpoint("/openapi/1.0.0/openapi.json", "World Storage API"); //TODO: Or alternatively use the original OpenAPI contract that's included in the static files c.SwaggerEndpoint("/openapi-original.json", "World Storage API Original"); diff --git a/server/src/Org.OpenAPITools/appsettings.json b/server/src/Org.OpenAPITools/appsettings.json index 05ce266..aebd1bb 100644 --- a/server/src/Org.OpenAPITools/appsettings.json +++ b/server/src/Org.OpenAPITools/appsettings.json @@ -3,7 +3,7 @@ "CollectionNameWorldLink": "WorldLink", "CollectionNameTrackables": "Trackables", "CollectionNameWorldAnchor": "WorldAnchor", - "ConnectionString": "mongodb://vm009254.fe.hhi.de:27017", + "ConnectionString": "mongodb://localhost:27017", "DatabaseName": "WorldStorageAPI" }, "Logging": { -- GitLab