pub struct OpenApiSpec {
pub spec: OpenAPI,
pub file_path: Option<String>,
pub raw_document: Option<Value>,
}
Expand description
OpenAPI specification loader and parser
Fields§
§spec: OpenAPI
The parsed OpenAPI specification
file_path: Option<String>
Path to the original spec file
raw_document: Option<Value>
Raw OpenAPI document preserved as JSON for resolving unsupported constructs
Implementations§
Source§impl OpenApiSpec
impl OpenApiSpec
Sourcepub async fn from_file<P: AsRef<Path>>(path: P) -> Result<Self>
pub async fn from_file<P: AsRef<Path>>(path: P) -> Result<Self>
Load OpenAPI spec from a file path
Sourcepub fn from_string(content: &str, format: Option<&str>) -> Result<Self>
pub fn from_string(content: &str, format: Option<&str>) -> Result<Self>
Load OpenAPI spec from string content
Sourcepub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
Get the API description
Sourcepub fn api_version(&self) -> &str
pub fn api_version(&self) -> &str
Get the API version
Sourcepub fn schemas(&self) -> Option<&IndexMap<String, ReferenceOr<Schema>>>
pub fn schemas(&self) -> Option<&IndexMap<String, ReferenceOr<Schema>>>
Get all schemas defined in the spec
Sourcepub fn security_schemes(
&self,
) -> Option<&IndexMap<String, ReferenceOr<SecurityScheme>>>
pub fn security_schemes( &self, ) -> Option<&IndexMap<String, ReferenceOr<SecurityScheme>>>
Get all security schemes defined in the spec
Sourcepub fn operations_for_path(&self, path: &str) -> HashMap<String, Operation>
pub fn operations_for_path(&self, path: &str) -> HashMap<String, Operation>
Get all operations for a given path
Sourcepub fn all_paths_and_operations(
&self,
) -> HashMap<String, HashMap<String, Operation>>
pub fn all_paths_and_operations( &self, ) -> HashMap<String, HashMap<String, Operation>>
Get all paths with their operations
Sourcepub fn get_schema(&self, reference: &str) -> Option<OpenApiSchema>
pub fn get_schema(&self, reference: &str) -> Option<OpenApiSchema>
Get a schema by reference
Sourcepub fn validate_security_requirements(
&self,
security_requirements: &[SecurityRequirement],
auth_header: Option<&str>,
api_key: Option<&str>,
) -> Result<()>
pub fn validate_security_requirements( &self, security_requirements: &[SecurityRequirement], auth_header: Option<&str>, api_key: Option<&str>, ) -> Result<()>
Validate security requirements
Sourcepub fn get_global_security_requirements(&self) -> Vec<SecurityRequirement> ⓘ
pub fn get_global_security_requirements(&self) -> Vec<SecurityRequirement> ⓘ
Get global security requirements
Sourcepub fn get_request_body(&self, reference: &str) -> Option<&RequestBody>
pub fn get_request_body(&self, reference: &str) -> Option<&RequestBody>
Resolve a request body reference
Sourcepub fn get_response(&self, reference: &str) -> Option<&Response>
pub fn get_response(&self, reference: &str) -> Option<&Response>
Resolve a response reference
Sourcepub fn get_example(&self, reference: &str) -> Option<&Example>
pub fn get_example(&self, reference: &str) -> Option<&Example>
Resolve an example reference
Trait Implementations§
Source§impl Clone for OpenApiSpec
impl Clone for OpenApiSpec
Source§fn clone(&self) -> OpenApiSpec
fn clone(&self) -> OpenApiSpec
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 OpenApiSpec
impl RefUnwindSafe for OpenApiSpec
impl Send for OpenApiSpec
impl Sync for OpenApiSpec
impl Unpin for OpenApiSpec
impl UnwindSafe for OpenApiSpec
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