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: OpenAPIThe 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 validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate the OpenAPI specification
This method provides basic validation. For comprehensive validation
with detailed error messages, use spec_parser::OpenApiValidator::validate().
Sourcepub fn validate_enhanced(&self) -> ValidationResult
pub fn validate_enhanced(&self) -> ValidationResult
Enhanced validation with detailed error reporting
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
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more