Opened 8 years ago
Closed 8 years ago
#41056 closed defect (bug) (fixed)
WP-API JS Client: Settings is incorrectly registered as a collection
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.8.1 | Priority: | normal |
| Severity: | normal | Version: | 4.7 |
| Component: | General | Keywords: | has-patch has-unit-tests commit fixed-major |
| Focuses: | javascript, rest-api | Cc: |
Description
Similar to the me endpoint, /wp/v2/settings is a model, not a collection. This is incorrectly detected due to the JS code assuming anything not ending with a regex is a collection, which is not true.
Potentially, we need to change the API to better expose what is and isn't a collection to the JS. The schema in the returned OPTIONS currently indicates that the response is an object, whereas it's actually a list of objects. If we change this, we need to look carefully at how we retrofit this, as changing it may break compatibility.
We should discuss how best to expose collections vs models via the API. Changing the schema is the best way, I think. See WP-API/proposals#2 for that discussion.
In the meantime, we should special-case /settings as well.
Attachments (2)
Change History (17)
#2
@
8 years ago
- Keywords has-patch has-unit-tests added; needs-patch removed
- Milestone changed from Awaiting Review to 4.8.1
- Owner set to adamsilverstein
- Status changed from new to assigned
- Version set to 4.7
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
8 years ago
This ticket was mentioned in Slack in #core-js by adamsilverstein. View the logs.
8 years ago
#5
@
8 years ago
@adamsilverstein Reviewed. In general it looks good; in lieu of a better way to clearly explain how we want an endpoint to be treated, this seems like a straightforward solution. One naming nitpick, I'd suggest modelEndpoints instead of singleModels as I feel it's a little more descriptive. If I see singleModels I would want to know what other kinds of models there are, vs understanding that this is a model and not a collection.
#6
@
8 years ago
@kadamwhite thanks for the feedback, I like your naming suggestion. I will work on an updated patch.
In 41056.diff:
settingsendpoint as a model