Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

MDeLuise
Copy link
Contributor

@MDeLuise MDeLuise commented Oct 1, 2024

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
{
  "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
{
  "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
{
  "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"
}

…s/{datastoreMessageId}` to return `dataMessage`

Updated the OpenAPI schema to return `dataMessage` instead of `dataMessageListResult` for the `GET v1/{scopeId}/data/messages/{datastoreMessageId}` endpoint.
Copy link

codecov bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

@@            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

@Coduz Coduz changed the title 🐛 [REST] Correct response schema for GET data/messages/{datastoreMessageId} to return dataMessage 🐛 [REST API] Correct response schema for GET data/messages/{datastoreMessageId} to return dataMessage Oct 3, 2024
@Coduz Coduz added Bug This is a bug or an unexpected behaviour. Fix it! Documentation Doc... What?? Joke! We will write some! labels Oct 3, 2024
@Coduz Coduz merged commit 2fa91c0 into eclipse:develop Oct 3, 2024
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is a bug or an unexpected behaviour. Fix it! Documentation Doc... What?? Joke! We will write some!
Projects
Development

Successfully merging this pull request may close these issues.

2 participants