pub struct NestedEndpointParams<'a> {
    pub root: &'a str,
    pub parent: &'a str,
    pub child: &'a str,
    pub parent_query: &'a str,
    pub base_uri: Option<&'a str>,
}Available on crate feature 
wiremock only.Expand description
The construction parameters for NestedEndpoint
Example:
use django_query::mock::{nested_endpoint_matches, NestedEndpoint, NestedEndpointParams};
#[derive(Clone, Filterable, IntoRow, Sortable)]
struct Foo {
  #[django(traverse, foreign_key="id")]
  bar: Arc<Bar>
}
#[derive(Clone, Filterable, IntoRow, Sortable)]
struct Bar {
  id: i32
}
let s = wiremock::MockServer::start().await;
let foos = vec![Foo { bar: Arc::new( Bar { id: 1 }) }];
wiremock::Mock::given(wiremock::matchers::method("GET"))
   .and(nested_endpoint_matches("/api", "bars", "foos"))
   .respond_with(NestedEndpoint::new(
       foos,
       NestedEndpointParams {
           root: "/api/",
           parent: "bars",
           child: "foos",
           parent_query: "bar__id",
           base_uri: Some(&s.uri())
       }
   ))
   .mount(&s)
   .await;
let u = format!("{}/api/bars/1/foos/", s.uri());
let body: serde_json::Value = reqwest::get(&u)
    .await
    .expect("error getting response")
    .json()
    .await
    .expect("error parsing response");
assert_eq!(body, serde_json::json!{
  {
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
      { "bar": 1 }
    ]
  }
});Fields§
§root: &'a strThe base mock path, without trailing slash, for example "/api/v0.2"
parent: &'a strThe objects this endpoint is nested under, for example "bars".
child: &'a strThe objects this endpoint serves, for example "foos"
parent_query: &'a strThe filter path for the parent from the child, so for example
"parent__id" if the filter expression for a given Foo to
obtain the value used in the query from its Bar is
"parent__id".
base_uri: Option<&'a str>The mock server URI, since wiremock does not make this
available to us; specifying None here will break
pagination (if requested) until wiremock propagates this
information.
Auto Trait Implementations§
impl<'a> Freeze for NestedEndpointParams<'a>
impl<'a> RefUnwindSafe for NestedEndpointParams<'a>
impl<'a> Send for NestedEndpointParams<'a>
impl<'a> Sync for NestedEndpointParams<'a>
impl<'a> Unpin for NestedEndpointParams<'a>
impl<'a> UnwindSafe for NestedEndpointParams<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more