feat: add API key management and tag discovery functionality with corresponding schemas and routes

This commit is contained in:
2025-09-06 17:49:07 +02:00
parent 82c6de8da8
commit 6aef739438
4 changed files with 35 additions and 1 deletions

View File

@@ -0,0 +1,16 @@
use api::{models::ApiErrorResponse, routers::api_key::*};
use models::schemas::api_key::{ApiKeyListSchema, ApiKeyRequest, ApiKeyResponse, ApiKeySchema};
use utoipa::OpenApi;
#[derive(OpenApi)]
#[openapi(
paths(get_keys, create_key, delete_key),
components(schemas(
ApiKeySchema,
ApiKeyListSchema,
ApiKeyRequest,
ApiKeyResponse,
ApiErrorResponse,
))
)]
pub(super) struct ApiKeyApi;

View File

@@ -6,9 +6,11 @@ use utoipa::{
use utoipa_scalar::{Scalar, Servable as ScalarServable};
use utoipa_swagger_ui::SwaggerUi;
mod api_key;
mod auth;
mod feed;
mod root;
mod tag;
mod thought;
mod user;
@@ -18,8 +20,10 @@ mod user;
(path = "/", api = root::RootApi),
(path = "/auth", api = auth::AuthApi),
(path = "/users", api = user::UserApi),
(path = "/users/me/api-keys", api = api_key::ApiKeyApi),
(path = "/thoughts", api = thought::ThoughtApi),
(path = "/feed", api = feed::FeedApi),
(path = "/tags", api = tag::TagApi),
),
tags(
(name = "root", description = "Root API"),
@@ -27,6 +31,7 @@ mod user;
(name = "user", description = "User & Social API"),
(name = "thought", description = "Thoughts API"),
(name = "feed", description = "Feed API"),
(name = "tag", description = "Tag Discovery API"),
),
modifiers(&SecurityAddon),
)]

View File

@@ -0,0 +1,12 @@
// in thoughts-backend/doc/src/tag.rs
use api::{models::ApiErrorResponse, routers::tag::*};
use models::schemas::thought::{ThoughtListSchema, ThoughtSchema};
use utoipa::OpenApi;
#[derive(OpenApi)]
#[openapi(
paths(get_thoughts_by_tag, get_popular_tags),
components(schemas(ThoughtSchema, ThoughtListSchema, ApiErrorResponse))
)]
pub(super) struct TagApi;

View File

@@ -2,7 +2,7 @@ use utoipa::OpenApi;
use api::models::{ApiErrorResponse, ParamsErrorResponse};
use api::routers::user::*;
use models::params::user::CreateUserParams;
use models::params::user::{CreateUserParams, UpdateUserParams};
use models::schemas::{
thought::{ThoughtListSchema, ThoughtSchema},
user::{UserListSchema, UserSchema},
@@ -24,6 +24,7 @@ use models::schemas::{
components(schemas(
CreateUserParams,
UserListSchema,
UpdateUserParams,
UserSchema,
ThoughtSchema,
ThoughtListSchema,