pub struct OpenApiRoute {
pub method: String,
pub path: String,
pub operation: Operation,
pub metadata: BTreeMap<String, String>,
pub parameters: Vec<String>,
pub spec: Arc<OpenApiSpec>,
pub ai_config: Option<AiResponseConfig>,
}
Expand description
OpenAPI route wrapper with additional metadata
Fields§
§method: String
The HTTP method
path: String
The path pattern
operation: Operation
The OpenAPI operation
metadata: BTreeMap<String, String>
Route-specific metadata
parameters: Vec<String>
Path parameters extracted from the path
spec: Arc<OpenApiSpec>
Reference to the OpenAPI spec for response generation
ai_config: Option<AiResponseConfig>
AI response configuration (parsed from x-mockforge-ai extension)
Implementations§
Source§impl OpenApiRoute
impl OpenApiRoute
Sourcepub fn new(
method: String,
path: String,
operation: Operation,
spec: Arc<OpenApiSpec>,
) -> Self
pub fn new( method: String, path: String, operation: Operation, spec: Arc<OpenApiSpec>, ) -> Self
Create a new OpenApiRoute
Sourcepub fn from_operation(
method: &str,
path: String,
operation: &Operation,
spec: Arc<OpenApiSpec>,
) -> Self
pub fn from_operation( method: &str, path: String, operation: &Operation, spec: Arc<OpenApiSpec>, ) -> Self
Create an OpenApiRoute from an operation
Sourcepub fn with_metadata(self, key: String, value: String) -> Self
pub fn with_metadata(self, key: String, value: String) -> Self
Add metadata to the route
Sourcepub async fn mock_response_with_status_async(
&self,
context: &RequestContext,
ai_generator: Option<&dyn AiGenerator>,
) -> (u16, Value)
pub async fn mock_response_with_status_async( &self, context: &RequestContext, ai_generator: Option<&dyn AiGenerator>, ) -> (u16, Value)
Generate a mock response with status code for this route (async version with AI support)
This method checks if AI response generation is configured and uses it if available, otherwise falls back to standard OpenAPI response generation.
§Arguments
context
- The request context for AI prompt expansionai_generator
- Optional AI generator implementation for actual LLM calls
Sourcepub fn mock_response_with_status(&self) -> (u16, Value)
pub fn mock_response_with_status(&self) -> (u16, Value)
Generate a mock response with status code for this route (synchronous version)
Note: This method does not support AI-assisted response generation.
Use mock_response_with_status_async
for AI features.
Trait Implementations§
Source§impl Clone for OpenApiRoute
impl Clone for OpenApiRoute
Source§fn clone(&self) -> OpenApiRoute
fn clone(&self) -> OpenApiRoute
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more