Skip to content
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

Allow for more TM fields to be optional #2042

Open
JKRhb opened this issue Aug 19, 2024 · 0 comments
Open

Allow for more TM fields to be optional #2042

JKRhb opened this issue Aug 19, 2024 · 0 comments
Labels
Forms Topics related to the forms container Has Use Case Potential The use case can be extracted and explained Thing Model Topic related to Thing Models

Comments

@JKRhb
Copy link
Member

JKRhb commented Aug 19, 2024

In the context of w3c/wot-binding-templates#258, one result of the discussion was that there might be cases where information within a Thing Model is primarily aimed at implementors of Things, indicating that they should support certain features or extensions of a protocol, like CoAP's Echo option. In this particular case, a consumer does not benefit that much from receiving this information in a TD, while implementors could use this information as a set of constraints for the Thing's behavior. However, at the moment it is required to take over all definitions (expect affordances labelled optional via tm:optional) into the resulting TD, which is why having vocabulary that is only used by Thing implementors is not really possible at the moment.

I was therefore wondering if we could either expand the scope of tm:optional to other levels of a TM or whether it could be possible to label vocabulary terms as optional during instantiation in general (e.g., in a Binding Template document where a vocabulary term is introduced). I guess the former approach would be a bit more flexible and would also cause less burden for specification authors, although it could make TMs a bit more verbose in certain scenarios.

When it comes to the example use case mentioned above, this could lead to the definition of a form like the following, where we use a JSON pointer to indicate that the cov:usesEcho member is optional via a tm:optional at the form level:

{
    "@context": [
      "https://www.w3.org/2022/wot/td/v1.1",
      {
        "cov": "http://www.example.org/coap-binding#"
      }
    ],
    "title": "ExampleThing",
    "securityDefinitions": {
        "nosec_sc": {"scheme": "nosec"}
    },
    "security": "nosec_sc",
    "properties": {
        "example": {
            "forms": [
              {
                "href": "coap://example.com/example",
                "cov:usesEcho": true, // Note: Only a placeholder
                "tm:optional": [
                  "/properties/status/forms/0/cov:usesEcho"
                ]
              }
           ]
        }
    },
}

Alternatively, we could also consider supporting JSON Path expressions, using the respective JSON object of the form as the root node.
This would make the tm:optional array entry a bit more concise:

{
    "@context": [
      "https://www.w3.org/2022/wot/td/v1.1",
      {
        "cov": "http://www.example.org/coap-binding#"
      }
    ],
    "title": "ExampleThing",
    "securityDefinitions": {
        "nosec_sc": {"scheme": "nosec"}
    },
    "security": "nosec_sc",
    "properties": {
        "example": {
            "forms": [
              {
                "href": "coap://example.com/example",
                "cov:usesEcho": true, // Note: Only a placeholder
                "tm:optional": [
                  "$['cov:usesEcho']"
                ]
              }
           ]
        }
    },
}

Looking forward to your feedback on this – if this would make sense as a potential addition to the specification, then I would transform the content of this issue into a use case submission via the new template :)

@github-actions github-actions bot added the needs-triage Automatically added to new issues. TF should triage them with proper labels label Aug 19, 2024
@JKRhb JKRhb changed the title Let tm:optional support more fields Allow for more TM fields to be optional Aug 19, 2024
@JKRhb JKRhb added Thing Model Topic related to Thing Models Has Use Case Potential The use case can be extracted and explained Forms Topics related to the forms container and removed needs-triage Automatically added to new issues. TF should triage them with proper labels labels Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Forms Topics related to the forms container Has Use Case Potential The use case can be extracted and explained Thing Model Topic related to Thing Models
Projects
None yet
Development

No branches or pull requests

1 participant