pub struct ApiSchema {
pub name: String,
pub description: Option<String>,
pub version: ApiVersion,
pub base_path: String,
pub endpoints: Vec<ApiEndpoint>,
pub definitions: HashMap<String, SchemaType>,
pub tags: Vec<String>,
pub contact: Option<String>,
pub license: Option<String>,
}Expand description
Complete API schema for a node
Fields§
§name: StringSchema name
description: Option<String>Schema description
version: ApiVersionAPI version
base_path: StringBase path prefix
endpoints: Vec<ApiEndpoint>Available endpoints
definitions: HashMap<String, SchemaType>Shared schema definitions (for $ref)
Global tags
contact: Option<String>Contact information
license: Option<String>License
Implementations§
Source§impl ApiSchema
impl ApiSchema
Sourcepub fn new(name: impl Into<String>, version: ApiVersion) -> Self
pub fn new(name: impl Into<String>, version: ApiVersion) -> Self
Create a new API schema
Sourcepub fn with_description(self, desc: impl Into<String>) -> Self
pub fn with_description(self, desc: impl Into<String>) -> Self
Set description
Sourcepub fn with_base_path(self, path: impl Into<String>) -> Self
pub fn with_base_path(self, path: impl Into<String>) -> Self
Set base path
Sourcepub fn add_endpoint(self, endpoint: ApiEndpoint) -> Self
pub fn add_endpoint(self, endpoint: ApiEndpoint) -> Self
Add endpoint
Sourcepub fn add_definition(self, name: impl Into<String>, schema: SchemaType) -> Self
pub fn add_definition(self, name: impl Into<String>, schema: SchemaType) -> Self
Add schema definition
Sourcepub fn find_endpoint(
&self,
path: &str,
method: ApiMethod,
) -> Option<&ApiEndpoint>
pub fn find_endpoint( &self, path: &str, method: ApiMethod, ) -> Option<&ApiEndpoint>
Find endpoint by path and method
Sourcepub fn endpoints_by_tag(&self, tag: &str) -> Vec<&ApiEndpoint>
pub fn endpoints_by_tag(&self, tag: &str) -> Vec<&ApiEndpoint>
Get all endpoints with a specific tag
Sourcepub fn from_bytes(bytes: &[u8]) -> Option<Self>
pub fn from_bytes(bytes: &[u8]) -> Option<Self>
Deserialize from bytes
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ApiSchema
impl<'de> Deserialize<'de> for ApiSchema
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>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for ApiSchema
Auto Trait Implementations§
impl Freeze for ApiSchema
impl RefUnwindSafe for ApiSchema
impl Send for ApiSchema
impl Sync for ApiSchema
impl Unpin for ApiSchema
impl UnsafeUnpin for ApiSchema
impl UnwindSafe for ApiSchema
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