#39561 closed defect (bug) (fixed)
REST API JavaScript client: Correct name route discovery for custom namespaces
Reported by: | adamsilverstein | Owned by: | adamsilverstein |
---|---|---|---|
Milestone: | 4.7.3 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | REST API | Keywords: | fixed-major |
Focuses: | javascript | Cc: |
Description (last modified by )
When users initialize the WP API JavaScript client with a custom namespace, the route discovery code does a poor job parsing the endpoints. This ticket aims to improve the parsing of custom namespaces. Originally raised by @westonruter and @jazbek, see https://github.com/WP-API/client-js/pull/152.
Attachments (5)
Change History (24)
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
8 years ago
This ticket was mentioned in Slack in #core-restapi by ocean90. View the logs.
8 years ago
#9
@
8 years ago
- Keywords fixed-major added; commit removed
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for 4.7.3 consideration.
#11
in reply to:
↑ 10
@
8 years ago
- Keywords needs-unit-tests added
Replying to jnylen0:
@adamsilverstein what about the unit tests for this change?
Good point! I will work on adding a version of the test for this.
#12
@
8 years ago
In 39561.4.diff :
- check for each route instead of a strict equality comparison on the schema. address a potential failure if plugins or themes try running tests with additional routes present, as @rachelbaker pointed out in slack.
- add a fixture for the custom endpoints created by the wp-js-widgets plugin - this is a good test case for the route discovery/class naming code.
- add an additional test block, verifying the schema parsing correctly generates proper class names for each model and collection route.
- ensure nav-menu test passes when code loaded without tests executing (tests for unset 'assert')
Note: the tests surfaced one issue with the parsing - underscores are being left untouched - hence the class name WidgetsTag_cloud
, this should probably be auto-transformed to WidgetsTagCloud
similar to handling of -
. I will address that in a separate ticket.
#13
@
8 years ago
- Keywords commit added
@adamsilverstein let's go with 39561.5.diff here. Only minor changes from your last patch: removed the PHPUnit test fix as that's a separate change addressed in [40104], and added a comment about the assert && assert.equal
fix.
This ticket was mentioned in Slack in #core-restapi by jnylen. View the logs.
8 years ago
#17
@
8 years ago
- Keywords needs-unit-tests commit removed
- Resolution fixed deleted
- Status changed from closed to reopened
39561.2.diff is a slight cleanup of the code and doc blocks. This code got some testing by the original reporter and others via the plugin, this is ready to commit.