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>(path: P) -> Result<OpenApiSpec, Error>
pub async fn from_file<P>(path: P) -> Result<OpenApiSpec, Error>
Load OpenAPI spec from a file path
Sourcepub fn from_string(
content: &str,
format: Option<&str>,
) -> Result<OpenApiSpec, Error>
pub fn from_string( content: &str, format: Option<&str>, ) -> Result<OpenApiSpec, Error>
Load OpenAPI spec from string content
Sourcepub fn validate(&self) -> Result<(), Error>
pub fn validate(&self) -> Result<(), Error>
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: &[IndexMap<String, Vec<String>>],
auth_header: Option<&str>,
api_key: Option<&str>,
) -> Result<(), Error>
pub fn validate_security_requirements( &self, security_requirements: &[IndexMap<String, Vec<String>>], auth_header: Option<&str>, api_key: Option<&str>, ) -> Result<(), Error>
Validate security requirements
Sourcepub fn get_global_security_requirements(
&self,
) -> Vec<IndexMap<String, Vec<String>>>
pub fn get_global_security_requirements( &self, ) -> Vec<IndexMap<String, Vec<String>>>
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 more