Generate request builder type for #[derive(WpDerivedRequest)]
#151
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.
Following up on #149, this PR adds request builder generation to
#[derive(WpDerivedRequest)]
. Besides the newfn_body_build_request_from_url
helper, it doesn't require any new implementation and can be built from the existing helpers - mostly because the existing helpers were built to support this type alongside the endpoint generation.It adds a new
WpApiRequestBuilder
type. This is a temporary type that can be used to make manual requests. It takes a request executor, but doesn't actually use it. Once we re-organizeRequestBuilder
type, we'll be able to address this, but for now, it's added to be used inwp_api/tests/test_manual_request_builder_immut.rs
. These new tests prove that requests can be built from the generated type and executed in the same way we used to do it before theRequestExecutor
trait.Please keep in mind that it's not possible to have everything be in polished state in this transition period - unless we want to do all the changes in a huge PR. That's why for example the new generated type is named
UsersRequestBuilder2
. If we were to use the actual name, it'll clash with the existing type - even though it's in a separate module - because the type is exposed through FFI. I'll do my best to address theseTODO
s once everything is in place.To Test
make test-server && make dump-mysql && make backup-wp-content-plugins
cargo test --test '*' -- --test-threads 1
Here is an example usage and its generated code: