-
Notifications
You must be signed in to change notification settings - Fork 28
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
Consider to add one or more validation steps to assure TD consistency #238
Comments
I did a quick check with the playground which as far as I know uses JSON schema validation only. The following snippet fails with "op should be equal to one of the allowed values"
Note sure if there are other cases that currently are not properly handled.... |
Correct, I checked and this is properly modeled in the TD JSONSchema: "form_element_property": {
"type": "object",
"properties": {
"op": {
"oneOf": [{
"type": "string",
"enum": [
"readproperty",
"writeproperty",
"observeproperty",
"unobserveproperty"
]
},
{
"type": "array",
"items": {
"type": "string",
"enum": [
"readproperty",
"writeproperty",
"observeproperty",
"unobserveproperty"
]
}
}
]
},
"href": {
"$ref": "#/definitions/anyUri"
},
"contentType": {
"type": "string"
},
"contentCoding": {
"type": "string"
},
"subprotocol": {
"$ref": "#/definitions/subprotocol"
},
"security": {
"$ref": "#/definitions/security"
},
"scopes": {
"$ref": "#/definitions/scopes"
},
"response": {
"type": "object",
"properties": {
"contentType": {
"type": "string"
}
}
}
}, Now I am wondering if we can cover also the oAuth validation... which basically constraint some fields only if another has a particular value: {
//.....
"flow": "client",
"authorization": "....", //this field is not allowed
"token": "...."
} |
It is possible: {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"type": "object",
"oauth_code":{
"type": "object",
"properties":{
"flow": {
"type": "string",
"enum": [ "code"]
},
"authorization":{"type":"string"},
"token":{"type":"string"},
},
"required":["authorization","flow","token"]
},
"oauth_client":{
"type": "object",
"properties":{
"flow": {
"type": "string",
"enum": [ "client"]
},
"token":{"type":"string"},
"authorization":{"type":"null"}
},
"required":["token"]
},
"properties":{
"securityScheme": {
"oneOf": [{"$ref": "#/oauth_code"},{"$ref": "#/oauth_client"}]
},
}
} There might be also alternative ways to achieve the same behavior using dependencies or patternProperties |
This seems to be an improvement that could (should?) go into the TD spec. |
This would work. dependencies may not work here since it is not possible to specify that something is not allowed. using |
Another validation step that came to mind is to verify that the servient actually can serve the TD. For example, TD may specify a |
I would also say that it should be in the expose. There could be the binding but the broker might be down at that moment of trying to expose |
@egekorkan From 23/11/2020 call. Could you please provide a list of the additional validation steps that the playground does? |
The additional checks are "documented" here: https://github.com/thingweb/thingweb-playground/blob/24cb71d465755d1c361bdb7c50b96963e80b3608/packages/playground-core/index.js#L54 Basically some simple static checks are done, nothing like checking whether the broker is available or whether the thing is available:
Other checks can be added quite simply into this list. |
A related TD issue w3c/wot-thing-description#1043 has been closed by mentioning
I don't think this has ever really happened. At the moment the TD provides the following section https://w3c.github.io/wot-thing-description/#validation-serialization-json. When it comes to security only there is a corresponding TD issue, see w3c/wot-thing-description#954. |
In #231 we simplified the validation algorithm to just one step. This step leverage on the JSONSchema defined in the TD specs. However, to the best of my knowledge, JSONSchema does not handle complex constraints between fields. For example, if a particular value of the field is only admitted if another field as a specific value.
Currently, we do not check if a form of an affordance has the correct
op
values. For example, a property might have a form with"op": ["invokeAction"]
and still be a valid TD for the current JSONSchema. We should look in those use cases (and maybe find some more) and update the validation algorithm consequently.The text was updated successfully, but these errors were encountered: