mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 13:36:59 +00:00
fix: manually specify params
This commit is contained in:
@@ -3,14 +3,6 @@ use std::str::FromStr;
|
||||
use revolt_result::Result;
|
||||
#[cfg(feature = "rocket-impl")]
|
||||
use rocket::request::FromParam;
|
||||
#[cfg(feature = "utoipa")]
|
||||
use utoipa::{
|
||||
openapi::{
|
||||
path::{Parameter, ParameterBuilder, ParameterIn},
|
||||
Required,
|
||||
},
|
||||
IntoParams,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
Bot, Channel, Database, Emoji, Invite, Member, Message, Server, ServerBan, User, Webhook,
|
||||
@@ -115,15 +107,3 @@ impl<'r> FromParam<'r> for Reference<'r> {
|
||||
Ok(Reference::from_unchecked(param))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "utoipa")]
|
||||
impl IntoParams for Reference<'_> {
|
||||
fn into_params(parameter_in_provider: impl Fn() -> Option<ParameterIn>) -> Vec<Parameter> {
|
||||
vec![ParameterBuilder::new()
|
||||
.name("id")
|
||||
.required(Required::True)
|
||||
.description(Some("An ID".to_string()))
|
||||
.parameter_in(parameter_in_provider().unwrap_or_default())
|
||||
.build()]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
use utoipa::{Modify, openapi::{OpenApi, security::{ApiKey, ApiKeyValue, SecurityScheme}}};
|
||||
use utoipa::{
|
||||
openapi::{
|
||||
schema::SchemaType,
|
||||
security::{ApiKey, ApiKeyValue, SecurityScheme},
|
||||
ObjectBuilder, OpenApi, RefOr, Schema, Type,
|
||||
},
|
||||
Modify, PartialSchema, ToSchema,
|
||||
};
|
||||
|
||||
use crate::util::reference::Reference;
|
||||
|
||||
pub struct TokenSecurity;
|
||||
|
||||
@@ -18,4 +27,23 @@ impl Modify for TokenSecurity {
|
||||
SecurityScheme::ApiKey(ApiKey::Header(ApiKeyValue::new("X-Bot-Ticket".to_string()))),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToSchema for Reference<'_> {
|
||||
fn name() -> std::borrow::Cow<'static, str> {
|
||||
std::borrow::Cow::Borrowed("Reference")
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialSchema for Reference<'_> {
|
||||
fn schema() -> RefOr<Schema> {
|
||||
RefOr::T(
|
||||
ObjectBuilder::new()
|
||||
.description(Some("An id referencing a stoat model."))
|
||||
.schema_type(SchemaType::Type(Type::String))
|
||||
.examples(["01FD58YK5W7QRV5H3D64KTQYX3"])
|
||||
.build()
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user