chore: update everything to work with utoipa
This commit is contained in:
@@ -41,9 +41,9 @@ revolt-result = { version = "0.8.9", path = "../../core/result", features = [
|
||||
revolt-files = { version = "0.8.9", path = "../../core/files" }
|
||||
|
||||
# Axum / web server
|
||||
axum = { version = "0.7.5" }
|
||||
axum-extra = { version = "0.9", features = ["typed-header"] }
|
||||
axum = { version = "0.8.6" }
|
||||
axum-extra = { version = "0.12.0", features = ["typed-header"] }
|
||||
|
||||
# OpenAPI & documentation generation
|
||||
utoipa-scalar = { version = "0.1.0", features = ["axum"] }
|
||||
utoipa = { version = "4.2.3", features = ["axum_extras", "ulid"] }
|
||||
utoipa-scalar = { version = "0.3.0", features = ["axum"] }
|
||||
utoipa = { version = "5.4.0", features = ["ulid"] }
|
||||
|
||||
@@ -80,9 +80,6 @@ async fn proxy(Query(UrlQuery { url }): Query<UrlQuery>) -> Result<impl IntoResp
|
||||
params(
|
||||
("url" = String, Query, description = "URL to fetch")
|
||||
),
|
||||
security(
|
||||
("api_key" = [])
|
||||
)
|
||||
)]
|
||||
async fn embed(
|
||||
Query(UrlQuery { url }): Query<UrlQuery>,
|
||||
|
||||
@@ -3,11 +3,8 @@ use std::net::{Ipv4Addr, SocketAddr};
|
||||
use axum::Router;
|
||||
|
||||
use tokio::net::TcpListener;
|
||||
use utoipa::{
|
||||
openapi::security::{Http, HttpAuthScheme, SecurityScheme},
|
||||
Modify, OpenApi,
|
||||
};
|
||||
use utoipa_scalar::{Scalar, Servable as ScalarServable};
|
||||
use utoipa::OpenApi;
|
||||
use utoipa_scalar::{Scalar, Servable};
|
||||
|
||||
mod api;
|
||||
pub mod requests;
|
||||
@@ -21,7 +18,6 @@ async fn main() -> Result<(), std::io::Error> {
|
||||
// Configure API schema
|
||||
#[derive(OpenApi)]
|
||||
#[openapi(
|
||||
modifiers(&SecurityAddon),
|
||||
paths(
|
||||
api::root,
|
||||
api::proxy,
|
||||
@@ -47,22 +43,17 @@ async fn main() -> Result<(), std::io::Error> {
|
||||
)]
|
||||
struct ApiDoc;
|
||||
|
||||
struct SecurityAddon;
|
||||
|
||||
impl Modify for SecurityAddon {
|
||||
fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
|
||||
if let Some(components) = openapi.components.as_mut() {
|
||||
components.add_security_scheme(
|
||||
"api_key",
|
||||
SecurityScheme::Http(Http::new(HttpAuthScheme::Bearer)),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Configure Axum and router
|
||||
let app = Router::new()
|
||||
.merge(Scalar::with_url("/scalar", ApiDoc::openapi()))
|
||||
// .route("/scalar", {
|
||||
// let html = Scalar::new(ApiDoc::openapi()).to_html();
|
||||
|
||||
// get(move || {
|
||||
// let html = html.clone();
|
||||
// async { Html(html) }
|
||||
// })
|
||||
// })
|
||||
.nest("/", api::router().await);
|
||||
|
||||
// Configure TCP listener and bind
|
||||
|
||||
Reference in New Issue
Block a user