Expand description
§Simple parsing
A library to easily parse an OpenApi Document according to specifications. It allows for distant references and support the OpenApi operators.
For example, parsing a file in your code might you like the following :
extern crate oapi;
extern crate sppparse;
use oapi::OApi;
use sppparse::SparseRoot;
use std::path::PathBuf;
fn main() {
let doc: OApi = OApi::new(
SparseRoot::new_from_file(PathBuf::from(concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/documents/test_docs/openapi.yml"
)))
.expect("to parse the openapi"),
);
doc.check().expect("not to have logic errors");
println!("{:#?}", doc);
}
§Extension support
You can use extension of the OpenApi Document, as specified in the specifications.
For example, parsing a file with extension in your code might you like the following :
extern crate oapi;
extern crate sppparse;
use oapi::{OApi, OApiExtensionExtractor};
use sppparse::SparseRoot;
use std::path::PathBuf;
use serde::{Serialize, Deserialize};
use sppparse::Sparsable;
use oapi_derive::OApiCheckInner;
#[derive(Debug, PartialEq, Serialize, Deserialize, Sparsable, OApiCheckInner)]
#[serde(rename_all = "camelCase")]
pub struct OApiDummyExt {
first_name: String,
last_name: String,
}
fn main() {
let doc: OApi = OApi::new(
SparseRoot::new_from_file(PathBuf::from(concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/documents/test_docs/extensions.yml"
)))
.expect("to parse the openapi"),
);
doc.check().expect("not to have logic errors");
let ext: OApiDummyExt = doc
.root_get()
.unwrap()
.oapi_extract_ext(doc.doc(), "x-toto")
.unwrap();
println!("{:#?}", ext);
}
Structs§
- AllOf
Select allOf
operator- AnyOf
Select anyOf
operator- NotSelect
not
operator- OApi
- OpenApi document
- OApi
Components - The OpenApi components
- OApi
Contact - The OpenApi contact object
- OApi
Document - The OpenApi document root object
- OApi
Encoding - The OpenApi encoding object
- OApi
Example - The OpenApi example object
- OApi
External Documentation - The OpenApi external documentation object
- OApi
Header - The OpenApi header object
- OApi
Info - The OpenApi document information object
- OApi
License - The OpenApi license object
- OApi
Link - The OpenApi link object
- OApi
Media Type - The OpenApi media type object
- OApiO
Auth Flow - The OAuth flows
- OApiO
Auth Flow Authorization Code - The OAuth Authorization Code Flow parameters
- OApiO
Auth Flow Client Credentials - The OAuth Client Credentials Flow parameters
- OApiO
Auth Flow Implicit - The OAuth Implicit Flow parameters
- OApiO
Auth Flow Password - The OAuth Password Flow parameters
- OApi
Operation - The OpenApi operation object
- OApi
Parameter - The OpenApi parameter object
- OApi
Path Item - The OpenApi path items
- OApi
Request Body - The OpenApi request body object
- OApi
Response - The OpenApi response object
- OApi
Schema Array - An array object in a schema
- OApi
Schema Discriminator - An object to switch between multiple schemas depending on a field value
- OApi
Schema Numeric - A numeric object in a schema
- OApi
Schema Object - An object in a schema
- OApi
Schema String - An string in a schema
- OApi
Schema Xml - The OpenApi xml object
- OApi
Security Scheme ApiKey - Parameter for Api Key security scheme
- OApi
Security Scheme Http - Parameter for HTTP security scheme
- OApi
Security Scheme Oauth2 - Parameter for OAuth2 security scheme
- OApi
Security Scheme Open IdConnect - Parameter for OIDC security scheme
- OApi
Server - The OpenApi server object
- OApi
Server Variable - The OpenApi server variables
- OApiTag
- The OpenApi tag object
- OneOf
Select oneOf
operator
Enums§
- OApi
ApiKey Location - The possible location of an api key
- OApi
Error - An error throwable by OApi
- OApi
Example Selector - A selector between a single example or multiple examples
- OApi
Numeric Format - The numeric format authorized by the OAPI specs
- OApi
Numeric Maximum - A selector between the inclusive or exclusive way to express upper numeric bound
- OApi
Numeric Minimum - A selector between the inclusive or exclusive way to express lower numeric bound
- OApi
Parameter Location - Location possible for parameters
- OApi
Parameter Style - Style possible for parameters
- OApi
Schema - An OpenApi schema
- OApi
Schema Additional Item - A selector for additional items
- OApi
Security Scheme - The OpenApi security scheme object
- OApi
String Format - The string format authorized by the OAPI specs
- Operator
Selector - A selector between operator or value
Traits§
- OApi
Check Trait - Check trait for OApi
- OApi
Extension Extractor - Extension extractor trait
- OApi
Operator - OApi Operator trait
Type Aliases§
- OApi
Callback - The OpenApi callback object
Derive Macros§
- OApi
Check - Derive for OApiCheckTrait