pub struct OpenApiRouteRegistry { /* private fields */ }Expand description
OpenAPI route registry that manages generated routes
Implementations§
Source§impl OpenApiRouteRegistry
impl OpenApiRouteRegistry
Sourcepub fn new(spec: OpenApiSpec) -> Self
pub fn new(spec: OpenApiSpec) -> Self
Create a new registry from an OpenAPI spec with default options
Sourcepub fn new_with_env(spec: OpenApiSpec) -> Self
pub fn new_with_env(spec: OpenApiSpec) -> Self
Create a new registry from an OpenAPI spec with environment-based options
Options are read from environment variables:
MOCKFORGE_REQUEST_VALIDATION: “off”/“warn”/“enforce” (default: “enforce”)MOCKFORGE_AGGREGATE_ERRORS: “1”/“true” to aggregate errors (default: true)MOCKFORGE_RESPONSE_VALIDATION: “1”/“true” to validate responses (default: false)MOCKFORGE_RESPONSE_TEMPLATE_EXPAND: “1”/“true” to expand templates (default: false)MOCKFORGE_VALIDATION_STATUS: HTTP status code for validation failures (optional)
Sourcepub fn new_with_options(spec: OpenApiSpec, options: ValidationOptions) -> Self
pub fn new_with_options(spec: OpenApiSpec, options: ValidationOptions) -> Self
Create a new registry from an OpenAPI spec with explicit validation options
§Arguments
spec- OpenAPI specificationoptions- Validation options to use
Sourcepub fn routes(&self) -> &[OpenApiRoute]
pub fn routes(&self) -> &[OpenApiRoute]
Get all generated routes
Sourcepub fn spec(&self) -> &OpenApiSpec
pub fn spec(&self) -> &OpenApiSpec
Get the OpenAPI specification used to generate routes
Sourcepub fn options(&self) -> &ValidationOptions
pub fn options(&self) -> &ValidationOptions
Get immutable reference to validation options
Sourcepub fn options_mut(&mut self) -> &mut ValidationOptions
pub fn options_mut(&mut self) -> &mut ValidationOptions
Get mutable reference to validation options for runtime configuration changes
Sourcepub fn build_router(&self) -> Router
pub fn build_router(&self) -> Router
Build an Axum router from the generated routes
Sourcepub fn build_router_with_injectors(
&self,
latency_injector: LatencyInjector,
failure_injector: Option<FailureInjector>,
) -> Router
pub fn build_router_with_injectors( &self, latency_injector: LatencyInjector, failure_injector: Option<FailureInjector>, ) -> Router
Sourcepub fn build_router_with_ai(
&self,
ai_generator: Option<Arc<dyn AiGenerator + Send + Sync>>,
) -> Router
pub fn build_router_with_ai( &self, ai_generator: Option<Arc<dyn AiGenerator + Send + Sync>>, ) -> Router
Trait Implementations§
Source§impl Clone for OpenApiRouteRegistry
impl Clone for OpenApiRouteRegistry
Source§fn clone(&self) -> OpenApiRouteRegistry
fn clone(&self) -> OpenApiRouteRegistry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for OpenApiRouteRegistry
impl RefUnwindSafe for OpenApiRouteRegistry
impl Send for OpenApiRouteRegistry
impl Sync for OpenApiRouteRegistry
impl Unpin for OpenApiRouteRegistry
impl UnwindSafe for OpenApiRouteRegistry
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