pub struct ConformanceTap { /* private fields */ }Expand description
A passive conformance tap over one loaded spec.
Implementations§
Source§impl ConformanceTap
impl ConformanceTap
Sourcepub fn from_spec_value(spec: Value, strict: bool) -> Result<Self, String>
pub fn from_spec_value(spec: Value, strict: bool) -> Result<Self, String>
Build a tap from a raw OpenAPI 3.x document (JSON or YAML already parsed to a Value).
pub fn is_strict(&self) -> bool
Sourcepub fn match_template(
&self,
method: &str,
concrete_path: &str,
) -> Option<(String, HashMap<String, String>)>
pub fn match_template( &self, method: &str, concrete_path: &str, ) -> Option<(String, HashMap<String, String>)>
Match a concrete request path against spec templates.
Returns (template, extracted path params).
Sourcepub async fn validate_request(
&self,
method: &str,
concrete_path: &str,
query: Option<&str>,
headers: &HeaderMap,
body: Option<&[u8]>,
) -> Option<(u16, Value)>
pub async fn validate_request( &self, method: &str, concrete_path: &str, query: Option<&str>, headers: &HeaderMap, body: Option<&[u8]>, ) -> Option<(u16, Value)>
Validate an inbound request against the matched route.
Violations are recorded into the shared conformance buffer inside
run_validation_with_recording_ex. Returns Some((status, payload))
only in STRICT mode when validation fails, so the caller can reject
instead of forwarding.
Sourcepub async fn validate_response(
&self,
method: &str,
concrete_path: &str,
status: u16,
body: Option<&[u8]>,
)
pub async fn validate_response( &self, method: &str, concrete_path: &str, status: u16, body: Option<&[u8]>, )
Validate a response received from upstream against the matched route’s declared responses:
- undeclared status code (and no default) →
response-shapeviolation; - declared JSON schema → body validated via
validate_json_value, errors collapsed into oneresponse-shapeviolation.
Always observational; never mutates the response.
Sourcepub async fn check_response(
&self,
method: &str,
concrete_path: &str,
status: u16,
body: Option<&[u8]>,
) -> bool
pub async fn check_response( &self, method: &str, concrete_path: &str, status: u16, body: Option<&[u8]>, ) -> bool
Record response violations and return whether the declared contract holds. This permits the caller to enforce an explicitly requested strict policy.
Sourcepub async fn check_encoded_response(
&self,
method: &str,
concrete_path: &str,
status: u16,
body: Option<&[u8]>,
content_encoding: Option<&str>,
) -> bool
pub async fn check_encoded_response( &self, method: &str, concrete_path: &str, status: u16, body: Option<&[u8]>, content_encoding: Option<&str>, ) -> bool
Validate a decoded copy while leaving the encoded upstream bytes untouched. Decoded JSON is bounded to 16 MiB and at most four encoding layers.