feat: add API key management and tag discovery functionality with corresponding schemas and routes
This commit is contained in:
16
thoughts-backend/doc/src/api_key.rs
Normal file
16
thoughts-backend/doc/src/api_key.rs
Normal 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;
|
@@ -6,9 +6,11 @@ use utoipa::{
|
|||||||
use utoipa_scalar::{Scalar, Servable as ScalarServable};
|
use utoipa_scalar::{Scalar, Servable as ScalarServable};
|
||||||
use utoipa_swagger_ui::SwaggerUi;
|
use utoipa_swagger_ui::SwaggerUi;
|
||||||
|
|
||||||
|
mod api_key;
|
||||||
mod auth;
|
mod auth;
|
||||||
mod feed;
|
mod feed;
|
||||||
mod root;
|
mod root;
|
||||||
|
mod tag;
|
||||||
mod thought;
|
mod thought;
|
||||||
mod user;
|
mod user;
|
||||||
|
|
||||||
@@ -18,8 +20,10 @@ mod user;
|
|||||||
(path = "/", api = root::RootApi),
|
(path = "/", api = root::RootApi),
|
||||||
(path = "/auth", api = auth::AuthApi),
|
(path = "/auth", api = auth::AuthApi),
|
||||||
(path = "/users", api = user::UserApi),
|
(path = "/users", api = user::UserApi),
|
||||||
|
(path = "/users/me/api-keys", api = api_key::ApiKeyApi),
|
||||||
(path = "/thoughts", api = thought::ThoughtApi),
|
(path = "/thoughts", api = thought::ThoughtApi),
|
||||||
(path = "/feed", api = feed::FeedApi),
|
(path = "/feed", api = feed::FeedApi),
|
||||||
|
(path = "/tags", api = tag::TagApi),
|
||||||
),
|
),
|
||||||
tags(
|
tags(
|
||||||
(name = "root", description = "Root API"),
|
(name = "root", description = "Root API"),
|
||||||
@@ -27,6 +31,7 @@ mod user;
|
|||||||
(name = "user", description = "User & Social API"),
|
(name = "user", description = "User & Social API"),
|
||||||
(name = "thought", description = "Thoughts API"),
|
(name = "thought", description = "Thoughts API"),
|
||||||
(name = "feed", description = "Feed API"),
|
(name = "feed", description = "Feed API"),
|
||||||
|
(name = "tag", description = "Tag Discovery API"),
|
||||||
),
|
),
|
||||||
modifiers(&SecurityAddon),
|
modifiers(&SecurityAddon),
|
||||||
)]
|
)]
|
||||||
|
12
thoughts-backend/doc/src/tag.rs
Normal file
12
thoughts-backend/doc/src/tag.rs
Normal 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;
|
@@ -2,7 +2,7 @@ use utoipa::OpenApi;
|
|||||||
|
|
||||||
use api::models::{ApiErrorResponse, ParamsErrorResponse};
|
use api::models::{ApiErrorResponse, ParamsErrorResponse};
|
||||||
use api::routers::user::*;
|
use api::routers::user::*;
|
||||||
use models::params::user::CreateUserParams;
|
use models::params::user::{CreateUserParams, UpdateUserParams};
|
||||||
use models::schemas::{
|
use models::schemas::{
|
||||||
thought::{ThoughtListSchema, ThoughtSchema},
|
thought::{ThoughtListSchema, ThoughtSchema},
|
||||||
user::{UserListSchema, UserSchema},
|
user::{UserListSchema, UserSchema},
|
||||||
@@ -24,6 +24,7 @@ use models::schemas::{
|
|||||||
components(schemas(
|
components(schemas(
|
||||||
CreateUserParams,
|
CreateUserParams,
|
||||||
UserListSchema,
|
UserListSchema,
|
||||||
|
UpdateUserParams,
|
||||||
UserSchema,
|
UserSchema,
|
||||||
ThoughtSchema,
|
ThoughtSchema,
|
||||||
ThoughtListSchema,
|
ThoughtListSchema,
|
||||||
|
Reference in New Issue
Block a user