Skip to content

Minor changes on chapters 4 and 5 #231

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

Merged
merged 5 commits into from
Aug 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ <h2>The <dfn>ThingDescription</dfn> type</h2>
let res = await fetch('https://tds.mythings.biz/sensor11');
// ... additional checks possible on res.headers
let td = await res.json();
let thing = new ConsumedThing(td);
let thing = await WOT.consume(td);
console.log("Thing name: " + thing.getThingDescription().title);
} catch (err) {
console.log("Fetching TD failed", err.message);
Expand Down Expand Up @@ -350,21 +350,13 @@ <h2>The <dfn>ThingDescription</dfn> type</h2>
To <dfn>validate a TD</dfn> given |td:ThingDescription|, run the following steps:
Copy link
Contributor

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.

Copy link
Member Author

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.

<ol>
<li>
If |td| is not an object, [= exception/throw =] a
{{"TypeError"}} and abort these steps.
</li>
<li>
If any of the mandatory properties defined in [[!WOT-TD]] for
<a href="https://www.w3.org/TR/2019/CR-wot-thing-description-20190516/#thing">Thing</a>
that don't have <a href="https://www.w3.org/TR/2019/CR-wot-thing-description-20190516/#sec-default-values">default definitions</a>
are missing from |td|, [= exception/throw =] a
{{"TypeError"}} and abort these steps.
</li>
<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.
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>
Copy link
Member Author

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.

Copy link
Member Author

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:

  1. Check if it is an Object
  2. Check if any of the mandatory fields with no default are not defined.
  3. Fill mandatory fields with default
  4. Do JSONSchema validation

Copy link
Contributor

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.

</ol>
<p class="ednote" title="Handling default values">
Additional steps may be added to fill the default values of mandatory fields.
</p>
</div>
</section>
</section>
Expand Down