pub struct Api<P, R, S> {Show 19 fields
pub swagger: Version,
pub definitions: BTreeMap<String, S>,
pub paths: BTreeMap<String, PathItem<P, R>>,
pub host: Option<String>,
pub base_path: Option<String>,
pub consumes: BTreeSet<MediaRange>,
pub produces: BTreeSet<MediaRange>,
pub schemes: BTreeSet<OperationProtocol>,
pub parameters: BTreeMap<String, P>,
pub responses: BTreeMap<String, R>,
pub security_definitions: BTreeMap<String, SecurityScheme>,
pub security: Vec<BTreeMap<String, BTreeSet<String>>>,
pub tags: Vec<Tag>,
pub external_docs: Option<ExternalDocs>,
pub coders: Coders,
pub support_crates: BTreeMap<String, String>,
pub spec_format: SpecFormat,
pub info: Info,
pub extensions: BTreeMap<String, Value>,
}
Expand description
OpenAPI v2 (swagger) spec generic over parameter and schema.
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swagger-object
Fields§
§swagger: Version
§definitions: BTreeMap<String, S>
§paths: BTreeMap<String, PathItem<P, R>>
§host: Option<String>
§base_path: Option<String>
§consumes: BTreeSet<MediaRange>
§produces: BTreeSet<MediaRange>
§schemes: BTreeSet<OperationProtocol>
§parameters: BTreeMap<String, P>
§responses: BTreeMap<String, R>
§security_definitions: BTreeMap<String, SecurityScheme>
§security: Vec<BTreeMap<String, BTreeSet<String>>>
§external_docs: Option<ExternalDocs>
§coders: Coders
Extension for custom coders to be used for decoding API objects.
An example for JSON would be:
x-rust-coders:
application/json:
encoder_path: serde_json::to_writer
decoder_path: serde_json::from_reader
any_value: serde_json::Value
error_path: serde_json::Error
NOTE: JSON and YAML encodings are already supported.
support_crates: BTreeMap<String, String>
Additional crates that need to be added to the manifest.
The key is the LHS of a dependency, which is the crate name. The value is the RHS of a crate’s requirements as it would appear in the manifest. Note that the caller must add proper escaping wherever required.
For example, the following are all valid:
my_crate: "0.7"
my_crate: "{ git = \"git://foo.bar/repo\" }"
my_crate: "{ version = \"0.9\", features = [\"booya\"] }"
spec_format: SpecFormat
This field is set manually, because we don’t know the format in which the spec was provided and we need to use this as the fallback encoding.
info: Info
§extensions: BTreeMap<String, Value>
Implementations§
source§impl<S: Schema + Default> Api<Arc<RwLock<Parameter<Resolvable<S>>>>, Arc<RwLock<Response<Resolvable<S>>>>, Resolvable<S>>
impl<S: Schema + Default> Api<Arc<RwLock<Parameter<Resolvable<S>>>>, Arc<RwLock<Response<Resolvable<S>>>>, Resolvable<S>>
sourcepub fn resolve(self) -> Result<ResolvableApi<S>, ValidationError>
pub fn resolve(self) -> Result<ResolvableApi<S>, ValidationError>
Consumes this API schema, resolves the references and returns the resolved schema.
This walks recursively, collects the referenced schema objects, substitutes the referenced IDs with the pointer to schema objects and returns the resolved object or an error if it encountered one.
Trait Implementations§
source§impl<'de, P, R, S> Deserialize<'de> for Api<P, R, S>
impl<'de, P, R, S> Deserialize<'de> for Api<P, R, S>
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>,
source§impl From<Api<Parameter<DefaultSchemaRaw>, Response<DefaultSchemaRaw>, DefaultSchemaRaw>> for OpenAPI
impl From<Api<Parameter<DefaultSchemaRaw>, Response<DefaultSchemaRaw>, DefaultSchemaRaw>> for OpenAPI
source§fn from(v2: DefaultApiRaw) -> Self
fn from(v2: DefaultApiRaw) -> Self
Auto Trait Implementations§
impl<P, R, S> Freeze for Api<P, R, S>
impl<P, R, S> RefUnwindSafe for Api<P, R, S>
impl<P, R, S> Send for Api<P, R, S>
impl<P, R, S> Sync for Api<P, R, S>
impl<P, R, S> Unpin for Api<P, R, S>
impl<P, R, S> UnwindSafe for Api<P, R, S>
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)