Conversation
Locks in that `WpApiDetails` reads the stripped-down `/wp-json/` index a private site serves — application-passwords auth only, empty namespaces and routes. Also adds a README cataloguing the `api-details` fixtures. No library behavior change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Collaborator
XCFramework BuildThis PR's XCFramework is available for testing. Add to your .package(url: "https://github.com/automattic/wordpress-rs", branch: "pr-build/1606")Built from 4faa68c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a validation test that the minimal REST API root a private site advertises parses into
WpApiDetails. A private site serves a stripped-down/wp-json/index — just enough for a client to discover the application-password login endpoint — and this locks in that the library reads it correctly.No library behavior change:
WpApiDetailsalready parses this shape. The test guards that contract against regressions.Changes
test-data/api-details/test-case-08.json(new): the minimal private-site root —application-passwordsauthentication only, emptynamespacesandroutes({}),gmt_offset: 0, and notimezone_string/site_icon_url.wp_api/src/login.rs:test_parse_private_site_api_rootasserts the fixture parses and thatfind_application_passwords_authentication_url()returns the authorize endpoint. The fixture is also added to thetest_api_details_jsonparse list, with a pointer comment to the new README.test-data/api-details/README.md(new): a catalogue of all eightapi-detailsfixtures — what each exercises, plus the recurring WordPress serialization quirks they cover ([]vs{}empty maps,gmt_offsetas string-or-number,site_icon_urlasfalse/string/absent, and the UTF-8 BOM). Retroactively documents the previously-undocumented cases 01–07.CHANGELOG.md: an**Internal:**entry under### Changed.Notes
The fixture uses
"routes": {}, matching what a correct emitter produces. The parser is intentionally left strict —routesis a plainHashMap, so aroutes: [](PHP'sjson_encode([])for an empty map) would fail this test rather than be silently tolerated. That is the desired behavior: a malformed root surfaces as a loud failure. Emptyauthenticationis the one field that already tolerates[], because WordPress core itself emits it that way (seetest-case-04.json).Test plan
cargo test -p wp_api --lib -- login::tests— all parse tests pass, includingtest_parse_private_site_api_rootand the newtest_api_details_jsoncase.cargo fmt --all -- --check— clean.cargo clippy -p wp_api --tests --all-features -- -D warnings— clean.Changelog
CHANGELOG.mdunder## [Unreleased], using the Keep a Changelog categories — an**Internal:**note under### Changed(no user-facing behavior change).