SDF vs. TD

Example Comparison for switch-enum-type.sdf.json

SDF TD
		
{
  "info": {
    "title": "Example file for ODM Simple JSON Definition Format", 
    "version": "20190424", 
    "copyright": "Copyright 2019 Example Corp. All rights reserved.", 
    "license": "http://example.com/license"
  },
		
{
    "title": "Example file for ODM Simple JSON Definition Format",
    // do not think this version is meant to be the same
    "version":{
        "instance": "20190424"
    },
    // copyright --> description/support?
    "description": "Copyright 2019 Example Corp. All rights reserved.",
    // license --> link?
    "links": [ { rel: "license", "href": "http://example.com/license" } ],
		
  "namespace": {
    "st": "http://example.com/capability/odm"
  },
  "defaultnamespace": "st", 

    "@context": [
        "https://www.w3.org/2019/wot/td/v1",	// default namespace
        { "st": "http://example.com/capability/odm" }  // other namespaces
    ],
		
  "odmObject": {
    "Switch": {

    // name "switch" as part of property/action/event
		
      "odmAction": {
        "On": { "description": "Action to turn the switch on" }, 
        "Off": { "description": "Action to turn the switch off" }
      },

    "actions": {
        "SwitchOn": {
            "description": "Action to turn the switch on",
            // forms optional in TD template
            "forms": [{
                "href": "https://mylamp.example.com/switchOn"
            }]
        },
        "SwitchOff": {
            "description": "Action to turn the switch off",
            // forms optional in TD template
            "forms": [{
                "href": "https://mylamp.example.com/switchOff"
            }]
        }
    },
		
      "odmProperty": {
        "State": {
          "description": "The state of the switch, whether on or off",
          "odmRef": "#/odmObject/Switch/odmData/StateData"
        }
      }, 

    "properties": {
        "SwitchState": {
            "description": "The state of the switch, whether on or off",
            "type": "string",
            "oneOf": [
                { "type": "string", "const": "on", "description": "The on state"},
                { "type": "string", "const": "off", "description": "The off state"}
            ],
            // forms optional in TD template
            "forms": [{
                "href": "https://mylamp.example.com/switchState"
            }]
        }
    }
		
      "odmData": {
        "StateData": {
          "odmEnum": {
            "On": {
                "type": "string",
                "const": "on",
                "description": "The on state"
            },
            "Off": {
                "type": "string",
                "const": "off",
                "description": "The off state"
            }
          }
        }
      }

    // "data" part of property/action/event
    // Note: TD plans to provide global definitions to allow references
		
    }
  }

  }

Features

A SDF definition file has two sections, the information block and the definitions section.

Information block

Quality Type Required Description TD
title string yes A short summary to be displayed in search results, etc.
version string yes The incremental version of the definition, format TBD
copyright string yes Link to text or embedded text containing a copyright notice
license string yes Link to text or embedded text containing license terms

Definitions block

Quality Type Required Description TD
namespace map no Defines short names mapped to namespace URIs, to be used as identifier prefixes @context
defaultnamespace string no Identifies one of the prefixes in the namespace map to be used as a default in resolving identifiers @context

odmObject

Quality Type Required Description Default TD
name string no human readable name N/A
description string no human readable description N/A
title string no human readable title to display N/A
$comment string no explanatory comments N/A
odmRef object no reference to a definition to be used as a template for a new definition N/A
odmRequired array no Array of JSON Pointers to mandatory items in a valid definition N/A

odmProperty

Quality Type Required Description Default TD
name string no human readable name N/A
description string no human readable description N/A
title string no human readable title to display N/A
$comment string no explanatory comments N/A
odmRequired array no Array of JSON Pointers to mandatory items in a valid definition N/A
odmRef object no reference to a definition to be used as a template for a new definition N/A
readable boolean no Reads are allowed true
writable boolean no Writes are allowed true
observable boolean no flag to indicate asynchronous notification is available true
contentFormat string no IANA media type string N/A
subtype string no subtype enumeration N/A
widthInBits integer no hint for protocol binding N/A
units string no SenML unit code N/A
nullable boolean no indicates a null value is available for this type true
scaleMinimum number no lower limit of value in units N/A
scaleMaximum number no upper limit of value in units N/A
type string, enum no JSON data type N/A
minimum number no lower limit of value in the representation format N/A
maximum number no upper limit of value in the representation format N/A
multipleOf number no indicates the resolution of the number in representation format N/A
enum array no enumeration constraint N/A
pattern string no regular expression to constrain a string pattern N/A
format string no JSON Schema formats N/A
minLength integer no shortest length string in octets N/A
maxLength integer no longest length string in octets N/A
default number, boolean, string no specifies the default value for initialization N/A
const number, boolean, string no specifies a constant value for a data item or property N/A

odmAction

Quality Type Required Description TD
name string no human readable name
description string no human readable description
title string no human readable title to display
$comment string no explanatory comments
odmRequired array no Array of JSON Pointers to mandatory items in a valid action definition
odmInputData array no Array of JSON Pointers to mandatory items in a valid action definition
odmRequiredInputData array no Array of JSON Pointers to mandatory items in a valid action definition
odmOutputData array no Array of JSON Pointers to mandatory items in a valid action definition
odmRef object no reference to a definition to be used as a template for a new definition

odmEvent

Quality Type Required Description TD
name string no human readable name
description string no human readable description
title string no human readable title to display
$comment string no explanatory comments
odmOutputData array no Array of JSON Pointers to output items in a valid definition
odmRequired array no Array of JSON Pointers to mandatory items in a valid definition
odmRef object no reference to a definition to be used as a template for a new definition

odmData

Quality Type Required Description TD
name string no human readable name
description string no human readable description
title string no human readable title to display
$comment string no explanatory comments
required array no list of references to mandatory items in a valid definition
odmRef object no reference to a definition to be used as a template for a new definition
type object no reference to a definition to be used as a template for a new definition
subtype string no subtype enumeration
widthInBits integer no hint for protocol binding
units string no SenML unit code
nullable boolean no indicates a null value is available for this type
scaleMinimum number no lower limit of value in units
scaleMaximum number no upper limit of value in units
type string, enum yes JSON data type
minimum number no lower limit of value in the representation format
maximum number no upper limit of value in the representation format
multipleOf number no indicates the resolution of the number in representation format
enum array of any type no enumeration constraint
pattern string no regular expression to constrain a string pattern
format string no JSON Schema formats
minLength integer no shortest length string in octets
maxLength integer no longest length string in octets
default number, boolean, string no specifies the default value for initialization
const number, boolean, string no specifies a constant value for a data item or property

odmThing

Quality Type Required Description TD
name string no human readable name
description string no human readable description
title string no human readable title to display
$comment string no explanatory comments
odmRequired array no Array of JSON Pointers to mandatory items in a valid definition
odmRef object no reference to a definition to be used as a template for a new definition

odmProduct

Quality Type Required Description TD
name string no human readable name
description string no human readable description
title string no human readable title to display
$comment string no explanatory comments
odmRequired array no Array of JSON Pointers to mandatory items in a valid definition
odmRef object no reference to a definition to be used as a template for a new definition

Open Questions