mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 02:27:40 +08:00
finish the task routes almost entirely
This commit is contained in:
parent
8d6c5bf89b
commit
220fbff619
@ -15,11 +15,17 @@ use utoipa::ToSchema;
|
|||||||
pub struct ResponseError {
|
pub struct ResponseError {
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub code: StatusCode,
|
pub code: StatusCode,
|
||||||
|
/// The error message.
|
||||||
pub message: String,
|
pub message: String,
|
||||||
|
/// The error code.
|
||||||
|
#[schema(value_type = Code)]
|
||||||
#[serde(rename = "code")]
|
#[serde(rename = "code")]
|
||||||
error_code: String,
|
error_code: String,
|
||||||
|
/// The error type.
|
||||||
|
#[schema(value_type = ErrorType)]
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
error_type: String,
|
error_type: String,
|
||||||
|
/// A link to the documentation about this specific error.
|
||||||
#[serde(rename = "link")]
|
#[serde(rename = "link")]
|
||||||
error_link: String,
|
error_link: String,
|
||||||
}
|
}
|
||||||
@ -99,7 +105,9 @@ pub trait ErrorCode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::enum_variant_names)]
|
#[allow(clippy::enum_variant_names)]
|
||||||
enum ErrorType {
|
#[derive(ToSchema)]
|
||||||
|
#[schema(rename_all = "snake_case")]
|
||||||
|
pub enum ErrorType {
|
||||||
Internal,
|
Internal,
|
||||||
InvalidRequest,
|
InvalidRequest,
|
||||||
Auth,
|
Auth,
|
||||||
@ -131,7 +139,8 @@ impl fmt::Display for ErrorType {
|
|||||||
/// `MyErrorCode::default().error_code()`.
|
/// `MyErrorCode::default().error_code()`.
|
||||||
macro_rules! make_error_codes {
|
macro_rules! make_error_codes {
|
||||||
($($code_ident:ident, $err_type:ident, $status:ident);*) => {
|
($($code_ident:ident, $err_type:ident, $status:ident);*) => {
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, ToSchema)]
|
||||||
|
#[schema(rename_all = "snake_case")]
|
||||||
pub enum Code {
|
pub enum Code {
|
||||||
$($code_ident),*
|
$($code_ident),*
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
use utoipa::OpenApi;
|
use utoipa::OpenApi;
|
||||||
|
use utoipa::ToSchema;
|
||||||
use utoipa_rapidoc::RapiDoc;
|
use utoipa_rapidoc::RapiDoc;
|
||||||
use utoipa_scalar::{Scalar, Servable as ScalarServable};
|
use utoipa_scalar::{Scalar, Servable as ScalarServable};
|
||||||
|
|
||||||
@ -108,14 +109,19 @@ pub fn is_dry_run(req: &HttpRequest, opt: &Opt) -> Result<bool, ResponseError> {
|
|||||||
.map_or(false, |s| s.to_lowercase() == "true"))
|
.map_or(false, |s| s.to_lowercase() == "true"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, ToSchema)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct SummarizedTaskView {
|
pub struct SummarizedTaskView {
|
||||||
|
/// The task unique identifier.
|
||||||
task_uid: TaskId,
|
task_uid: TaskId,
|
||||||
|
/// The index affected by this task. May be `null` if the task is not linked to any index.
|
||||||
index_uid: Option<String>,
|
index_uid: Option<String>,
|
||||||
|
/// The status of the task.
|
||||||
status: Status,
|
status: Status,
|
||||||
|
/// The type of the task.
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: Kind,
|
kind: Kind,
|
||||||
|
/// The date on which the task was enqueued.
|
||||||
#[serde(serialize_with = "time::serde::rfc3339::serialize")]
|
#[serde(serialize_with = "time::serde::rfc3339::serialize")]
|
||||||
enqueued_at: OffsetDateTime,
|
enqueued_at: OffsetDateTime,
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ use deserr::Deserr;
|
|||||||
use index_scheduler::{IndexScheduler, Query, TaskId};
|
use index_scheduler::{IndexScheduler, Query, TaskId};
|
||||||
use meilisearch_types::deserr::query_params::Param;
|
use meilisearch_types::deserr::query_params::Param;
|
||||||
use meilisearch_types::deserr::DeserrQueryParamError;
|
use meilisearch_types::deserr::DeserrQueryParamError;
|
||||||
use meilisearch_types::error::deserr_codes::*;
|
use meilisearch_types::error::{deserr_codes::*, Code, ErrorType};
|
||||||
use meilisearch_types::error::{InvalidTaskDateError, ResponseError};
|
use meilisearch_types::error::{InvalidTaskDateError, ResponseError};
|
||||||
use meilisearch_types::index_uid::IndexUid;
|
use meilisearch_types::index_uid::IndexUid;
|
||||||
use meilisearch_types::settings::{
|
use meilisearch_types::settings::{
|
||||||
@ -43,7 +43,7 @@ const DEFAULT_LIMIT: u32 = 20;
|
|||||||
|
|
||||||
)),
|
)),
|
||||||
modifiers(&OpenApiAuth),
|
modifiers(&OpenApiAuth),
|
||||||
components(schemas(AllTasks, TaskView, Status, DetailsView, ResponseError, Settings<Unchecked>, Settings<Checked>, TypoSettings, MinWordSizeTyposSetting, FacetingSettings, PaginationSettings))
|
components(schemas(Code, ErrorType, AllTasks, TaskView, Status, DetailsView, ResponseError, Settings<Unchecked>, Settings<Checked>, TypoSettings, MinWordSizeTyposSetting, FacetingSettings, PaginationSettings, SummarizedTaskView, Kind))
|
||||||
)]
|
)]
|
||||||
pub struct TaskApi;
|
pub struct TaskApi;
|
||||||
|
|
||||||
@ -404,6 +404,7 @@ async fn delete_tasks(
|
|||||||
|
|
||||||
#[derive(Debug, Serialize, ToSchema)]
|
#[derive(Debug, Serialize, ToSchema)]
|
||||||
pub struct AllTasks {
|
pub struct AllTasks {
|
||||||
|
/// The list of tasks that matched the filter.
|
||||||
results: Vec<TaskView>,
|
results: Vec<TaskView>,
|
||||||
/// Total number of browsable results using offset/limit parameters for the given resource.
|
/// Total number of browsable results using offset/limit parameters for the given resource.
|
||||||
total: u64,
|
total: u64,
|
||||||
|
Loading…
Reference in New Issue
Block a user