-
Notifications
You must be signed in to change notification settings - Fork 1
[JSON Schema] Express Time resource as custom type 'time' #23
Comments
How to represent date in Json Schema?Using the keyword {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"$id": "https://github.com/NordicSemiconductor/lwm2m-types-js/blob/saga/LwM2MDocument.schema.json",
"title": "LwM2M JSON Schema",
"description": "JSON schema for expressing LwM2M resources as JSON",
"properties": {
"6": {
"properties": {
"5": {
"type": "string",
"format": "date-time",
"title": "Timestamp",
},
},
},
},
} What is the expected value according to LwM2M XML definition?2 examples: <Item ID="5">
<Name>Timestamp</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Mandatory</Mandatory>
<Type>Time</Type>
<RangeEnumeration></RangeEnumeration>
<Units></Units>
<Description><![CDATA[The timestamp of when the location measurement was performed.]]></Description>
</Item> <Item ID="5518">
<Name>Timestamp</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Optional</Mandatory>
<Type>Time</Type>
<RangeEnumeration></RangeEnumeration>
<Units></Units>
<Description>The timestamp of when the measurement was performed.</Description>
</Item> What is the LwM2M definition of Time type ?
How does the provided value look like in the shadow?Object 3303 prop 5518: Temperature {
"Timestamp": "2022-10-07T13:33:22Z"
} Object 6, prop 5: Location {
"Timestamp": "1970-01-01T00:00:00Z",
} ProblemThe expected format according to the standard is |
How to represent UNIX TIME in Json Schema ?{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"$id": "https://github.com/NordicSemiconductor/lwm2m-types-js/blob/saga/LwM2MDocument.schema.json",
"title": "LwM2M JSON Schema",
"description": "JSON schema for expressing LwM2M resources as JSON",
"properties": {
"6": {
"properties": {
"5": {
"type": "integer",
"minimum": -864e12,
"maximum": 864e12,
"title": "Timestamp",
},
},
},
},
} Because UNIX TIME definition says: Other alternative could be add {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"$id": "https://github.com/NordicSemiconductor/lwm2m-types-js/blob/saga/LwM2MDocument.schema.json",
"title": "LwM2M JSON Schema",
"description": "JSON schema for expressing LwM2M resources as JSON",
"properties": {
"6": {
"properties": {
"5": {
"type": "integer",
"minimum": -864e12,
"maximum": 864e12,
"title": "Timestamp",
"format": "date-time",
},
},
},
},
} However, this is not a real solution because "format": "date-time" only work on string type and LwM2M described value as integer: here is described another alternative using |
🎉 This issue has been resolved in version 2.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This is not relevant for this project. |
Time Unix Time. A signed integer
representing the number of seconds since
Jan 1st, 1970 in the UTC time zone.
Represented as an ASCII
integer.
For example, 1476186613
seconds since Jan 01 1970,
which represents Tuesday,
11-Oct-16 11:50:13 UTC,
are represented as the
ASCII string
"1476186613", which has
10 characters/bytes.
Same representation as Integer.
Page 96 http://www.openmobilealliance.org/release/lightweightm2m/V1_0-20170208-A/OMA-TS-LightweightM2M-V1_0-20170208-A.pdf
Example
add
type
:time
, user-defined keywords are supported in AJV: https://ajv.js.org/keywords.htmlThe text was updated successfully, but these errors were encountered: