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

Things API with optional CRUD #273

Merged
merged 17 commits into from
Feb 21, 2022
Merged

Things API with optional CRUD #273

merged 17 commits into from
Feb 21, 2022

Conversation

farshidtz
Copy link
Member

@farshidtz farshidtz commented Feb 12, 2022

After review in the discovery call on Feb 14th, 2022:

  • recommend 404 not found for missing optional endpoints
  • clarify basic vs full HTTP directory

Another PR: Update section IDs - doing so will make section IDs and assertions IDs inconsistent. Updating assertion IDs will cause issues with existing testing tools.


Preview | Diff

index.html Outdated Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
},
"base": "{{DIRECTORY_BASE_URL}}",
"tm:required": [
"#/properties/things"
],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The things property has two forms. One is for array payload which is mandatory, another is for the collection payload which is optional. To define this required form, the TM should support setting of a form to required using a nested required: true field. It currently doesn't.

I am setting the whole property to required, assuming that it means at least one form should offer this interaction. I can also set to #/properties/things/forms/0 but that means we are forcing the order of items in the forms array.

This was discussed in #253 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, I think that for now having only things property required is fine. I know that it is clearly depicting the whole picture but we have normative statements that cover that part. I would wait for the TD spec to catch up and deal with this kind of issue (I would say that the issue here is much more complex than just requiring that a derived TD must have a specific form).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK for now with this resolution, but I'm wondering now if we should not have two different interactions here. The expectation in TDs are that different forms are somehow equivalent, not for different purposes. The scripting API, for example, also assumes that any form in an interaction will do the same thing as any other.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are equivalent ways of getting the TDs. The only difference is payload and header formats.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion: Farshids thinks this is broken (maybe messed up as part of an earlier PR) and needs to be fixed. McCool thinks at the very least that putting forms distinguished by different contentTypes in a single interaction is inconvenient for Consumers. Farshid will create an issue and will investigate.

@farshidtz farshidtz marked this pull request as ready for review February 14, 2022 11:06
@farshidtz
Copy link
Member Author

farshidtz commented Feb 14, 2022

@RoboPhred, This PR closes your issue. I could not add you as the reviewer, but please consider doing so.

@farshidtz farshidtz requested a review from egekorkan February 14, 2022 11:36
index.html Outdated
Comment on lines 897 to 901
If the missing feature is the whole functionality at an API endpoint,
the server may respond with 404 (Not Found).
Alternatively, a server may respond with 501 (Not Implemented)
to signify that it has placeholders in place for the given
endpoint and would provide this functionality in future.
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 wasn't sure if this should be an assertion. It won't help the clients anyway because it is optional for servers. Turning it into an assertion also means that we need to find two implementations who don't implement the feature and use those status codes!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not completely convinced about returning 501 either. Programmatically speaking having 404 or 501 result in the same output -> I cannot use this endpoint. About user, perspective knowing that the feature Might be implemented in the future feels like a temporary workaround. I would prefer chooseing just one of the two error codes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed 501 and converted 404 to an assertion, but recommended instead of optional.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I agree with only having one error code. I am personally unsure why we don't make this mandatory but having it as a recommended is ok (probably best to not force an implementation to do anything at all if there is an error).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "may" should probably be MAY though and marked as an assertion with a span and id, however. Are all errors written like this? Do we have a general statement/assertion somewhere about errors that makes individual assertions unnecessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmccool I think you are commenting on the outdated diff.

Regarding mandatory or recommended; as you said, forcing this means server have to implement it specifically that way. For example, a server may need to implement all those HTTP handlers and return 404.

index.html Show resolved Hide resolved
@farshidtz farshidtz mentioned this pull request Feb 14, 2022
7 tasks
Copy link
Contributor

@mmccool mmccool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the interest of time I think it is ok to go ahead and merge this, although there were a few places where I felt some improvements would be useful. If there is time before the feature freeze an additional round of polishing may be a good idea.

index.html Show resolved Hide resolved
<ul>
<li>
If the missing feature is to customize existing functionality of an
API, the server will respond with 501 (Not Implemented)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will -> MUST assertion?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assertions are in the respective sections as explained below:

The normative behavior is prescribed in the respective sections.

index.html Show resolved Hide resolved
index.html Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
index.html Show resolved Hide resolved
index.html Show resolved Hide resolved
@mmccool mmccool merged commit f03fa88 into w3c:main Feb 21, 2022
@farshidtz farshidtz deleted the things-api branch March 7, 2022 16:13
farshidtz added a commit to farshidtz/w3c-wot-discovery that referenced this pull request Mar 14, 2022
farshidtz added a commit to farshidtz/w3c-wot-discovery that referenced this pull request Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Small fixes on Creation Read-Only Directories
3 participants