angelxmoreno / angelxmoreno/WPRestClient

API Prefix vs Endpoint path

Open
#21 0 comments 0 reactions 0 assignees View on GitHub
bug good first issue help wanted
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.