Open casper2002casper opened 3 years ago
It looks weird, but its valid JSON schema. It indicates that the "properties" are independently available for use at that level, while the "oneOf" are exclusionary (its only valid if its only using ONE of the designated combinations of properties). Threw me off at first too.
Are your referring to https://github.com/actions-on-google/smart-home-schema/blob/master/traits/temperaturesetting/temperaturesetting.states.schema.json ?
@i8beef interpretation is correct, the properties
refer to the common properties while the oneOf
provide additional contraints for validating other properties
that depends on attributes. Maybe this could be made clearier with the usage of an additionalProperties
subschemas.
Alternatively because the oneOf
currently already duplicate some of the properties we would rely on a top-level oneOf and duplicate the common properties.
Other schema that uses a similar pattern are: https://github.com/actions-on-google/smart-home-schema/blob/3afb14dff2d5c2150e037b501e86ba9b2fdbc031/traits/colorsetting/colorabsolute.params.schema.json https://github.com/actions-on-google/smart-home-schema/blob/9ba20d2520e4639c7e0866df5543e215691f0a4e/traits/sensorstate/sensorstate.states.schema.json https://github.com/actions-on-google/smart-home-schema/blob/9ba20d2520e4639c7e0866df5543e215691f0a4e/traits/sensorstate/sensorstate.attributes.schema.json
action.devices.traits.TemperatureSetting has both properties and onOf, seeing as no other trait has this, this seems like a mistake.