From 6cb9e3b5fdbae88ad0e24cc18f92556b1198fb22 Mon Sep 17 00:00:00 2001 From: Meik Date: Wed, 1 Jul 2026 09:44:48 +0200 Subject: [PATCH] fix: return native web api responses --- F4SDM42WebApi/F4SD - M42WebApi.csproj | 2 +- F4SDM42WebApi/F4SDM42WebApiController.cs | 18 +++++++++++------- ...C4IT-F4SD-M42WebApi.postman_collection.json | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/F4SDM42WebApi/F4SD - M42WebApi.csproj b/F4SDM42WebApi/F4SD - M42WebApi.csproj index 31a6d7b..cbd4869 100644 --- a/F4SDM42WebApi/F4SD - M42WebApi.csproj +++ b/F4SDM42WebApi/F4SD - M42WebApi.csproj @@ -13,7 +13,7 @@ false 6673a25d-33d6-4072-91d9-abed4be1a966 C4ITF4SD*.* - 1.4.0.36 + 1.4.0.37 true diff --git a/F4SDM42WebApi/F4SDM42WebApiController.cs b/F4SDM42WebApi/F4SDM42WebApiController.cs index 9549eed..d9e2196 100644 --- a/F4SDM42WebApi/F4SDM42WebApiController.cs +++ b/F4SDM42WebApi/F4SDM42WebApiController.cs @@ -210,7 +210,7 @@ namespace C4IT.F4SD */ [Route("getPickup/{name}"), HttpGet] //[CacheOutput(UseETAG = true)] - public async Task getPickup(string name, EntityEnumerationVisibilityMode mode = EntityEnumerationVisibilityMode.None, Int32 group = -1) + public async Task getPickup(string name, EntityEnumerationVisibilityMode mode = EntityEnumerationVisibilityMode.None, Int32 group = -1) { await Task.Delay(0); EntityEnumeration enumerationTemp = GetEnumeration(name, mode); @@ -233,7 +233,7 @@ namespace C4IT.F4SD Values = vals.ToArray() }; //CacheOutputAttribute.RegisterResponseEtag($"enum_{enumeration.Name}_{(int)mode}", $"{enumeration.Name}_{(int)mode}", cultureInvariant: false, userInvariant: true, val); - return Matrix42.WebApi.Contracts.HttpResponseExtensions.CreateResponse(Request, HttpStatusCode.OK, enumeration); + return enumeration; } [Route("getMyRoleMemberships"), HttpGet] @@ -395,9 +395,9 @@ namespace C4IT.F4SD } [Route("isAlive"), HttpGet] - public HttpResponseMessage isAlive() + public IHttpActionResult isAlive() { - return new HttpResponseMessage(HttpStatusCode.NoContent); + return new StatusCodeResult(HttpStatusCode.NoContent); } [Route("loglevel"), HttpGet] @@ -423,16 +423,20 @@ namespace C4IT.F4SD } [Route("log"), HttpGet] - public HttpResponseMessage getLog(string download = "0", int count = 50, string filter = "") + public IHttpActionResult getLog(string download = "0", int count = 50, string filter = "") { try { - return _f4stHelperService.privGetLog(download, count, Request, filter); + var response = _f4stHelperService.privGetLog(download, count, Request, filter); + if (response == null) + return new StatusCodeResult(HttpStatusCode.NoContent); + + return new ResponseMessageResult(response); } catch (Exception E) { LogException(E); - return null; + return new StatusCodeResult(HttpStatusCode.InternalServerError); } } } diff --git a/docs/postman/C4IT-F4SD-M42WebApi.postman_collection.json b/docs/postman/C4IT-F4SD-M42WebApi.postman_collection.json index 84f1ec7..fe7b86d 100644 --- a/docs/postman/C4IT-F4SD-M42WebApi.postman_collection.json +++ b/docs/postman/C4IT-F4SD-M42WebApi.postman_collection.json @@ -37,6 +37,20 @@ " pm.response.to.be.json;", " }", " });", + "", + " const contentType = pm.response.headers.get(\"Content-Type\") || \"\";", + " if (contentType.toLowerCase().includes(\"json\")) {", + " const json = pm.response.json();", + " const isSerializedHttpResponse = json && !Array.isArray(json) &&", + " Object.prototype.hasOwnProperty.call(json, \"Version\") &&", + " Object.prototype.hasOwnProperty.call(json, \"Content\") &&", + " Object.prototype.hasOwnProperty.call(json, \"StatusCode\") &&", + " Object.prototype.hasOwnProperty.call(json, \"IsSuccessStatusCode\");", + "", + " pm.test(\"Response is not a serialized HttpResponseMessage\", function () {", + " pm.expect(isSerializedHttpResponse).to.equal(false);", + " });", + " }", "}" ] }