eclipse / kapua

Eclipse Public License 2.0
227 stars 160 forks source link

🐛 [REST API] Correct response schema for GET `data/messages/{datastoreMessageId}` to return `dataMessage` #4111

Closed MDeLuise closed 1 month ago

MDeLuise commented 1 month ago

Summary

This PR fixes the response schema for the GET {scopeId}/data/messages/{datastoreMessageId} endpoint in the Kapua API. Previously, the OpenAPI schema incorrectly documented the response as dataMessageListResult when it should have returned a dataMessage.

What was fixed

The OpenAPI documentation previously showed the following response:

Old example ```json { "type": "storableListResult", "limitExceeded": true, "size": 2, "items": [ { "type": "jsonDatastoreMessage", "capturedOn": "2019-09-12T09:35:04.383Z", "channel": { "type": "kapuaDataChannel", "semanticParts": [ "heater", "data" ] }, "clientId": "Client-Id-1", "deviceId": "WyczTs_GuDM", "payload": { "metrics": [ { "valueType": "string", "value": 5, "name": "temperatureExternal" }, { "valueType": "string", "value": 20.25, "name": "temperatureInternal" }, { "valueType": "string", "value": 30, "name": "temperatureExhaust" }, { "valueType": "string", "value": -441478528, "name": "errorCode" } ] }, "receivedOn": "2019-09-12T09:35:04.389Z", "scopeId": "AQ", "sentOn": "2019-09-12T09:35:04.383Z", "datastoreId": "6349cec8-396b-4aac-bc2f-8fca9fe0c67c", "timestamp": "2019-09-12T09:35:04.383Z" }, { "type": "jsonDatastoreMessage", "capturedOn": "2019-09-12T09:25:05.096Z", "channel": { "type": "kapuaDataChannel", "semanticParts": [ "heater", "data" ] }, "clientId": "Client-Id-1", "deviceId": "WyczTs_GuDM", "payload": { "metrics": [ { "valueType": "string", "value": 5, "name": "temperatureExternal" }, { "valueType": "string", "value": 20, "name": "temperatureInternal" }, { "valueType": "string", "value": 30, "name": "temperatureExhaust" }, { "valueType": "string", "value": 0, "name": "errorCode" } ] }, "receivedOn": "2019-09-12T09:25:05.102Z", "scopeId": "AQ", "sentOn": "2019-09-12T09:25:05.096Z", "datastoreId": "bb07d7fc-dc62-492f-b8da-7e28df69e112", "timestamp": "2019-09-12T09:25:05.096Z" } ], "totalCount": 61 } ```

However, the correct response format should be a dataMessage, as seen here:

New example ```json { "type": "jsonDatastoreMessage", "capturedOn": "2019-09-12T09:25:05.096Z", "channel": { "type": "kapuaDataChannel", "semanticParts": [ "heater", "data" ] }, "clientId": "Client-Id-1", "deviceId": "WyczTs_GuDM", "payload": { "metrics": [ { "valueType": "string", "value": 5, "name": "temperatureExternal" }, { "valueType": "string", "value": 20, "name": "temperatureInternal" }, { "valueType": "string", "value": 30, "name": "temperatureExhaust" }, { "valueType": "string", "value": 0, "name": "errorCode" } ] }, "receivedOn": "2019-09-12T09:25:05.102Z", "scopeId": "AQ", "sentOn": "2019-09-12T09:25:05.096Z", "datastoreId": "bb07d7fc-dc62-492f-b8da-7e28df69e112", "timestamp": "2019-09-12T09:25:05.096Z" } ```

A real response example:

Real response example ```json { "type": "jsonDatastoreMessage", "channel": { "semanticParts": [ "genericMetric" ] }, "clientId": "pahoClient", "deviceId": "T5mpNWpOcdY", "payload": { "metrics": [ { "valueType": "string", "value": "GeneriMetricHere", "name": "genericMetric" } ] }, "receivedOn": "1970-01-20T23:56:28.576Z", "scopeId": "AQ", "datastoreId": "9f55aa27-e3c4-4709-8bee-091466d04f18", "timestamp": "2024-10-01T13:16:16.611Z" } ```
codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 16.81%. Comparing base (ce975f4) to head (3983105). Report is 9 commits behind head on develop.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/eclipse/kapua/pull/4111/graphs/tree.svg?width=650&height=150&src=pr&token=1P4N4CApH8&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse)](https://app.codecov.io/gh/eclipse/kapua/pull/4111?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse) ```diff @@ Coverage Diff @@ ## develop #4111 +/- ## ========================================== Coverage 16.80% 16.81% Complexity 22 22 ========================================== Files 2019 2019 Lines 52410 52411 +1 Branches 4417 4417 ========================================== + Hits 8810 8812 +2 Misses 43202 43202 + Partials 398 397 -1 ``` [see 2 files with indirect coverage changes](https://app.codecov.io/gh/eclipse/kapua/pull/4111/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse)