angelxmoreno / angelxmoreno/WPRestClient
API Prefix vs Endpoint path
- Dominant language
- PHP
- Stars
- 5
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
# The problem
currently, the default values for the API prefix and the end point paths are wrong.
```
ApiClient::api_prefix = wp-json/wp/v2
PostsRepository::path = posts
Final path = wp-json/wp/v2/posts
```
The current repositories work fine because they are all part of the `wp/v2` end points. However, when creating custom repositories not under the `wp/v2` path, you would not be able to properly set the path from the custom repository.
# Example
An example of this would be a scenario where you would want to create a new repository that interacts with the [WP API Menus plugin](https://wordpress.org/plugins/wp-api-menus/). Their endpoints are `wp-json/wp-api-menus/v2/`.
# The Fix
`ApiClient::api_prefix` should be set to `wp-json` and the current repositories path should be `wp/v2/{name}`
Contributor guide
Research direction
Read ApiClient and the current repository definitions, especially PostsRepository, to trace how the API prefix and endpoint paths are combined. Update the defaults so the final path remains wp-json/wp/v2/posts while custom repositories can target paths such as wp-json/wp-api-menus/v2; verify both existing and custom repository URLs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100