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

TDD Thing Model is missing contentType in response objects #465

Closed
JKRhb opened this issue Mar 6, 2023 · 4 comments · Fixed by #469
Closed

TDD Thing Model is missing contentType in response objects #465

JKRhb opened this issue Mar 6, 2023 · 4 comments · Fixed by #469

Comments

@JKRhb
Copy link
Member

JKRhb commented Mar 6, 2023

Experimenting with discovery from TDDs, I noticed that a TDD implementation that adheres to the currently defined Thing Model for the API specification ends up generating a Thing Description that is not valid according to the TD specification. That is because a form like the following does not define a contentType for its response member, causing an instantiated TD to be invalid if no contentType is explicitly added by the TDD:

{
    "href": "/things/{id}",
    "htv:methodName": "PUT",
    "contentType": "application/td+json",
    "response": {
        "description": "Success response",
        "htv:statusCodeValue": 201
        // No contentType defined!
    },
    "additionalResponses": [
        {
            ...
        }
    ]
}

As also discussed in w3c/wot-thing-description#1776, having no contentType seems reasonable to me here – however, if a discovery validates a TDD's Thing Description, then it is rejected in its current form.

Would it be a possible workaround to add application/octet-stream for cases like these? Or is there maybe a better alternative?

@mmccool
Copy link
Contributor

mmccool commented Mar 6, 2023

Can't add an assertion, at most can add an informative statement. Worst case, we mention the above workaround using application/octet-stream.

@farshidtz
Copy link
Member

A content type should not be needed when there is no content (no HTTP body). Enforcing that on directories would be really strange.

See also:

I suggest we wait and hope that contentType becomes optional in an upcoming TD spec patch.

@JKRhb
Copy link
Member Author

JKRhb commented Mar 6, 2023

I fully agree with you, @farshidtz. I opened w3c/wot-thing-description#1780 in the TD repository in order to discuss a possible solution there.

@mmccool
Copy link
Contributor

mmccool commented Mar 27, 2023

It looks like making this optional is not going to happen in the current spec, as it would be a normative change which is not possible in CR. The referenced issue is marked as "Defer to TD 2.0".

So we will have to go with the "strange" option, but as an informative note. Suggest adding an informative comment (not an ed note, just a normal sentence) like the following:

Note that a contentType is required by the WoT TD 1.1 specification for ExpectedResponse, even when the body is empty.
In this case, "application/octet-stream" can be used to ensure that the TD is valid.

@JKRhb will prepare a PR (and decide where a suitable place to insert this would).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants