alexa-samples / alexa-smarthome

Resources for Alexa Smart Home developers.
https://alexa.design/smarthome
Other
679 stars 336 forks source link

Validation schema rejects StateReport/ChangeReport examples #159

Closed paolobelluticm closed 1 year ago

paolobelluticm commented 3 years ago

Validation error returned by JSON Schema Validator while validating both the official StateReport event example and the ChangeReport event example from the documentation:

Message:
    Invalid type. Expected Number but got String.
Schema path:
    #/definitions/state.properties/items/anyOf/31/properties/value/type

The issue is that the schema expects RangeController's rangeValue property to be a number, while in the examples it's a string. Who's at fault here?

Relevant fragment of the event:

          {
            "namespace": "Alexa.RangeController",
            "instance": "Fan.Speed",
            "name": "rangeValue",
            "value": "10",
            "timeOfSample": "2017-02-03T16:20:50.52Z",
            "uncertaintyInMilliseconds": 500
          },

Relevant fragment of the validation schema (lines 1723-1740):

                        "properties": {
                            "namespace": {
                                "enum": [
                                    "Alexa.RangeController"
                                ]
                            },
                            "name": {
                                "enum": [
                                    "rangeValue"
                                ]
                            },
                            "instance": {
                                "type": "string"
                            },
                            "value": {
                                "type": "number",
                                "additionalProperties": false,
                                "format": "double"
                            },

If I change "type" to "string", the validation obviously succeeds.

I've been responding with a string for some time, and it seems to work. Should I bother switching to a number to please the validation schema?

UniSnake commented 3 years ago

The official documentation's examples currently show range values as numbers instead of strings. Perhaps the documentation was updated.

sumitdang commented 1 year ago

Technical documentation is now updated. Closing this issue now.