-
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
Minor changes on chapters 4 and 5 #231
Conversation
Introduce @egekorkan review changes specified in the following pdf document: https://github.com/w3c/wot-scripting-api/files/5017322/ScriptingAPI-review-egekorkan.pdf
index.html
Outdated
@@ -332,7 +332,7 @@ <h2>The <dfn>ThingDescription</dfn> type</h2> | |||
<a>TD</a>. | |||
</p> | |||
<div> | |||
To <dfn>expand a TD</dfn> given |td:ThingDescription|, run the following steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why to remove the algorithm name?
@@ -347,23 +347,24 @@ <h2>The <dfn>ThingDescription</dfn> type</h2> | |||
Therefore, this API expects the {{ThingDescription}} objects be validated before used as parameters. This specification defines a basic <a>TD</a> validation as follows. | |||
</p> | |||
<div> | |||
To <dfn>validate a TD</dfn> given |td:ThingDescription|, run the following steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same: I don't think algorithm names and params should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, see my review.
index.html
Outdated
@@ -332,7 +332,7 @@ <h2>The <dfn>ThingDescription</dfn> type</h2> | |||
<a>TD</a>. | |||
</p> | |||
<div> | |||
To <dfn>expand a TD</dfn> given |td:ThingDescription|, run the following steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this element should be kept, is it @zolkis?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
<li> | ||
If <a href="https://www.w3.org/TR/2019/CR-wot-thing-description-20190516/#json-schema-for-validation">JSON schema validation</a> fails on |td|, [= exception/throw =] a | ||
{{"TypeError"}} and abort these steps. | ||
</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@egekorkan comment on this change:
The JSON Schema validation should be before step 2 and that way if something fails the schema validation, it must have values for terms that do not have defaults. The schema validation does not expect a TD with defaults filled in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave as it was. As far as I understand if a property is marked as required in JSONSchema even if it has a default value, it must appear in the validating object. However, I'd add a step to make the process a little bit clearer:
- Check if it is an Object
- Check if any of the mandatory fields with no default are not defined.
- Fill mandatory fields with default
- Do JSONSchema validation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the sequence proposed above.
I added a filling default step in the validation algorithm. This is because AFAIK JSONschema validation fails if a required property is not present even if it has a default value. @egekorkan could you check this? |
It seems there is a relevant discussion about this topic in eclipse-thingweb/node-wot#302 |
The thing is that the values that have a default value are not required in the official validation schema, i.e. if a property form does not have an |
index.html
Outdated
@@ -360,6 +360,10 @@ <h2>The <dfn>ThingDescription</dfn> type</h2> | |||
are missing from |td|, [= exception/throw =] a | |||
{{"TypeError"}} and abort these steps. | |||
</li> | |||
<li> | |||
Fill any missing mandatory property defined in [[!WOT-TD]] that have a | |||
<a href="https://www.w3.org/TR/2019/CR-wot-thing-description-20190516/#sec-default-values">default definition</a> with its default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: usually these complex steps should be more detailed, e.g. using sub-steps with a loop, or an explicit loop, for instance
For each mandatory property defined in [[!WOT-TD]] that have default definitions, add the property to |td| if it's missing and set its value to the default value specified in [[!WOT-TD]].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there are no mandatory properties in the TD spec that would have default values, so this text needs updating. We need an initialization policy for the default values of mandatory TD properties. I suggest we create a separate issue about that in the TD repo, then link it here and also in a new issue in this repo. Then we can resolve this and merge this PR.
The thing here is that if it has a default, it probably does not need to be defined.... I agree with @danielpeintner here:
|
Meanwhile, I updated the validation algorithm to have a really basic starting point. I removed the following steps:
They are both covered by the JSONSchema validation process. The only difference is that JSONSchema is more restrictive on point 2. It fails even if the mandatory property has a default assigned. However, since |
Simplify so that we can build more complex steps from this solid ground
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include an editor's note mentioning that more steps are going to be included for filling the mandatory properties defined in the TD spec, once the default values are specified in the TD spec (and please file an issue on the TD spec for this).
This PR reports @egekorkan review changes in chapters 4 and 5 (no comments were left on chapter 3). See the related #230 (comment) and the pdf document
Preview | Diff