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

Support for additionalResponses #548

Open
relu91 opened this issue Apr 24, 2024 · 7 comments
Open

Support for additionalResponses #548

relu91 opened this issue Apr 24, 2024 · 7 comments
Labels
priority: high Issues that will be tackled in 2024 Spec-improvement Using idioms, standard prose, Web IDL, alignment with other specs

Comments

@relu91
Copy link
Member

relu91 commented Apr 24, 2024

Current TD specification introduced the concept of additionalResponses to model APIs that might return different payloads from the same affordance. The field is used also to model both successful responses and error responses. For example, the Thing Description of a Thing Description Directory contains the following:

"actions": {
        "createThing": {
            "description": "Create a Thing Description",
            "uriVariables": {
                "id": {
                    "@type": "ThingID",
                    "title": "Thing Description ID",
                    "type": "string",
                    "format": "iri-reference"
                }
            },
            "input": {
                "description": "The schema is implied by the content type",
                "type": "object"
            },
            "forms": [
                {
                    "href": "/things/{id}",
                    "htv:methodName": "PUT",
                    "contentType": "application/td+json",
                    "response": {
                        "description": "Success response",
                        "htv:statusCodeValue": 201
                    },
                    "additionalResponses": [
                        {
                            "description": "Invalid serialization or TD",
                            "contentType": "application/problem+json",
                            "htv:statusCodeValue": 400
                        }
                    ]
                }
            ]
        },
@relu91
Copy link
Member Author

relu91 commented Apr 24, 2024

Notice that there is also the concept of response that we currently don't take into account.

@relu91 relu91 changed the title Support for additionalExpectedResponses Support for additionalResponses Apr 24, 2024
@lu-zero
Copy link

lu-zero commented Apr 24, 2024

And it has to be composed with Action::output (and the same logical concepts in Property and Event).

@zolkis
Copy link
Contributor

zolkis commented Apr 29, 2024

In the context of a scripting API these are errors - which we do take into account, but we may want to extend the details.
Implementations can choose to report these.

@relu91
Copy link
Member Author

relu91 commented Apr 29, 2024

In the context of a scripting API these are errors - which we do take into account, but we may want to extend the details.
Implementations can choose to report these.

Not all of them, since you can express alternative success responses too.

@zolkis
Copy link
Contributor

zolkis commented Apr 29, 2024

Doesn't matter, the API is still fine with a Promise... eventually you can resolve it with an object.

@relu91 relu91 added Spec-improvement Using idioms, standard prose, Web IDL, alignment with other specs priority: high Issues that will be tackled in 2024 labels May 13, 2024
@relu91
Copy link
Member Author

relu91 commented May 13, 2024

Call 13/05:

  • We need to handle the use case and give an example or a note. Eventually, an algorithm is needed.
  • @danielpeintner Since actions have output schema what happens when the additionalResposes have another schema? @relu91 is a grey area we need to understand how to explain the issue.
  • @JKRhb can we generalize it with other protocols?
  • @zolkis This is an example of why the scripting API is useful. Best to solve in the binding.

We need somebody who can work on this issue and propose pointers to a solution.

@lu-zero
Copy link

lu-zero commented May 13, 2024

We have a normal path that is relying on the logical data schemas of the affordance and we have a richer path that adds additional schemas bound to the form (and thus potentially protocol specific).

As it is the best we can provide is the data and the schema it matches, if one is matched.

We should discuss on TD if we want to say anything regarding when more than a dataschema matches probably. For TD 2.0 could be useful to give provisions to map protocol-specific errors and/or other side-channel metadata to logical concepts so would be possible easier to have protocol-translating proxies (e.g http 404 -> not_found).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high Issues that will be tackled in 2024 Spec-improvement Using idioms, standard prose, Web IDL, alignment with other specs
Projects
None yet
Development

No branches or pull requests

3 participants