-
Notifications
You must be signed in to change notification settings - Fork 4
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
docs: Add REST endpoints documentation #13
Conversation
- Remove unnecessary elements - Check & verify everything is accurate.
docs/rest-api.md
Outdated
### Testing Instructions | ||
|
||
To verify the functionality of this endpoint, you can use any API testing tool (e.g., cURL, Postman, or a custom script). Follow these steps: | ||
|
||
1. **Set up the request**: | ||
* Create a new GET request. | ||
* Set the URL to: `https://your-wordpress-site.com/wp-json/snapwp/v1/env` | ||
|
||
2. **Set up Authentication**: | ||
* Use Basic Auth with your WordPress username and the application password you generated. | ||
|
||
3. **Set up Request Body**: | ||
* In the "Body" tab, select "raw" and choose "JSON" from the dropdown. | ||
* In the request body, enter the following JSON: | ||
```json | ||
{ | ||
"variables": [ | ||
{ | ||
"name": "NEXT_URL", | ||
"value": "http://localhost:3000" | ||
}, | ||
{ | ||
"name": "HOME_URL", | ||
"value": "https://headless-demo.local" | ||
}, | ||
{ | ||
"name": "GRAPHQL_ENDPOINT", | ||
"value": "wp-graphql" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
4. **Send the Request and Verify Responses**: | ||
* Send the request and verify that you receive a 200 OK response. | ||
* Check that the response body matches the example in the documentation. | ||
|
||
5. **Test Error Cases**: | ||
* Remove all variables from the request body and send the request. Verify that you receive a 400 Bad Request response matching the documentation. | ||
* Remove one of the required variables (e.g., NEXT_URL) and send the request. Verify that you receive a 500 Internal Server Error response matching the documentation. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, these are usage docs for developers. Teaching readers how to use REST is beyond the scope. Please remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this and added an example curl request.
docs/rest-api.md
Outdated
### Authentication | ||
|
||
This endpoint requires administrator privileges. To authenticate: | ||
|
||
1. In your WordPress admin panel, go to Users -> Your Profile. | ||
2. Scroll down to the "Application Passwords" section. | ||
3. Enter a name for your application password (e.g., "API Testing") and click "Add New Application Password". | ||
4. Copy the generated password. | ||
|
||
You'll use this password along with your username for Basic Auth when making requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the remaining unnecessary stuff I flagged, and this should be good to merge.
What
This PR adds comprehensive documentation for the REST API endpoint (
snapwp/v1/env
) used in the SnapWP Helper plugin.Why
Documentation is crucial for developers who want to integrate with or extend our plugin. This PR addresses the lack of detailed REST API documentation, making it easier for developers to understand and use our endpoint.
Related Issue(s):
How
docs/rest-api.md
file with detailed documentation for thesnapwp/v1/env
endpoint.README.md
file to include a link to the new REST API documentation.The documentation covers:
Testing Instructions
docs/rest-api.md
file to ensure all information is accurate and complete.README.md
file to confirm the new link to the REST API documentation is present and correct.Screenshots
N/A (Documentation changes only)
Additional Info
N/A
Checklist