pub struct OpenApiExpectation {
pub spec_url_or_payload: String,
pub operations_and_responses: Option<HashMap<String, String>>,
pub context_path_prefix: Option<String>,
}Expand description
An OpenAPI specification import — registers matchers and example responses for the operations in an OpenAPI/Swagger spec.
Sent via PUT /mockserver/openapi. The spec may be a URL, a filesystem
path (file://...), a classpath resource, or an inline JSON/YAML payload.
§Example
use mockserver_client::OpenApiExpectation;
let expectation = OpenApiExpectation::new(
"https://example.com/petstore.yaml",
)
.operation("listPets", "200")
.operation("showPetById", "200");Fields§
§spec_url_or_payload: String§operations_and_responses: Option<HashMap<String, String>>§context_path_prefix: Option<String>Implementations§
Source§impl OpenApiExpectation
impl OpenApiExpectation
Sourcepub fn new(spec_url_or_payload: impl Into<String>) -> Self
pub fn new(spec_url_or_payload: impl Into<String>) -> Self
Create an OpenAPI import from a spec URL, file path, classpath resource, or inline JSON/YAML payload.
Sourcepub fn operation(
self,
operation_id: impl Into<String>,
status_code: impl Into<String>,
) -> Self
pub fn operation( self, operation_id: impl Into<String>, status_code: impl Into<String>, ) -> Self
Map an operationId to the status code (or example name) to respond with.
When no operations are specified, MockServer creates example responses for every operation in the spec.
Sourcepub fn operations_and_responses(self, map: HashMap<String, String>) -> Self
pub fn operations_and_responses(self, map: HashMap<String, String>) -> Self
Replace the full operations-to-responses map.
Sourcepub fn context_path_prefix(self, prefix: impl Into<String>) -> Self
pub fn context_path_prefix(self, prefix: impl Into<String>) -> Self
Set a context-path prefix to prepend to every generated matcher path.
Trait Implementations§
Source§impl Clone for OpenApiExpectation
impl Clone for OpenApiExpectation
Source§fn clone(&self) -> OpenApiExpectation
fn clone(&self) -> OpenApiExpectation
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OpenApiExpectation
impl Debug for OpenApiExpectation
Source§impl Default for OpenApiExpectation
impl Default for OpenApiExpectation
Source§fn default() -> OpenApiExpectation
fn default() -> OpenApiExpectation
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for OpenApiExpectation
impl<'de> Deserialize<'de> for OpenApiExpectation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for OpenApiExpectation
impl PartialEq for OpenApiExpectation
Source§fn eq(&self, other: &OpenApiExpectation) -> bool
fn eq(&self, other: &OpenApiExpectation) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for OpenApiExpectation
impl Serialize for OpenApiExpectation
impl StructuralPartialEq for OpenApiExpectation
Auto Trait Implementations§
impl Freeze for OpenApiExpectation
impl RefUnwindSafe for OpenApiExpectation
impl Send for OpenApiExpectation
impl Sync for OpenApiExpectation
impl Unpin for OpenApiExpectation
impl UnsafeUnpin for OpenApiExpectation
impl UnwindSafe for OpenApiExpectation
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