torn-api.rs/torn-api-codegen/src/openapi/schema.rs

31 lines
782 B
Rust

use indexmap::IndexMap;
use serde::Deserialize;
use super::{parameter::OpenApiParameter, path::OpenApiPath, r#type::OpenApiType};
#[derive(Debug, Clone, Deserialize)]
pub struct Components<'a> {
#[serde(borrow)]
pub schemas: IndexMap<&'a str, OpenApiType<'a>>,
#[serde(borrow)]
pub parameters: IndexMap<&'a str, OpenApiParameter<'a>>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct OpenApiSchema<'a> {
#[serde(borrow)]
pub paths: IndexMap<&'a str, OpenApiPath<'a>>,
#[serde(borrow)]
pub components: Components<'a>,
}
#[cfg(test)]
pub(crate) mod test {
use super::*;
pub(crate) fn get_schema() -> OpenApiSchema<'static> {
let s = include_str!("../../../torn-api/openapi.json");
serde_json::from_str(s).unwrap()
}
}