diff --git a/readme.md b/readme.md index d8e60a65343310bfc697ea051150366a57e3669a..1e37de1831e5a895fb4049e5297fa8abc7554187 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 5d7c9faf64a7d2a3667956c532ad7429adf9682c..05d7b2cd24a949d4da4d10e3ecc74f5648789e01 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 4068462bc6cb7ae726aaf498924a47a0f040504f..8564cffbde63601e4863c7d0e29850381a97b7b8 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 003a74823a1fbb26aa4e87cd44f3480a94eb5819..890aebdc6745be412bb3b251654e226ec8b4a904 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 14cb0790ba211435bc97cea63838dfd4e2b7c94d..60d1335c93a7589a8dd10b4e9b7f10ec1053b976 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 c9e1470fcf3352e099e9d5f8a249732184d504c1..02e91fd2fbf211dc82c724e36f197f9785cf928c 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 05ce266d1e7b3666249a7e36a51671506f9912b3..aebd1bbadc56a6c987a8359d0c6ffc87d5760f89 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": {