mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 10:07: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 {
|
||||
#[serde(skip)]
|
||||
pub code: StatusCode,
|
||||
/// The error message.
|
||||
pub message: String,
|
||||
/// The error code.
|
||||
#[schema(value_type = Code)]
|
||||
#[serde(rename = "code")]
|
||||
error_code: String,
|
||||
/// The error type.
|
||||
#[schema(value_type = ErrorType)]
|
||||
#[serde(rename = "type")]
|
||||
error_type: String,
|
||||
/// A link to the documentation about this specific error.
|
||||
#[serde(rename = "link")]
|
||||
error_link: String,
|
||||
}
|
||||
@ -99,7 +105,9 @@ pub trait ErrorCode {
|
||||
}
|
||||
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
enum ErrorType {
|
||||
#[derive(ToSchema)]
|
||||
#[schema(rename_all = "snake_case")]
|
||||
pub enum ErrorType {
|
||||
Internal,
|
||||
InvalidRequest,
|
||||
Auth,
|
||||
@ -131,7 +139,8 @@ impl fmt::Display for ErrorType {
|
||||
/// `MyErrorCode::default().error_code()`.
|
||||
macro_rules! make_error_codes {
|
||||
($($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 {
|
||||
$($code_ident),*
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ use serde::{Deserialize, Serialize};
|
||||
use time::OffsetDateTime;
|
||||
use tracing::debug;
|
||||
use utoipa::OpenApi;
|
||||
use utoipa::ToSchema;
|
||||
use utoipa_rapidoc::RapiDoc;
|
||||
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"))
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, ToSchema)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SummarizedTaskView {
|
||||
/// The task unique identifier.
|
||||
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>,
|
||||
/// The status of the task.
|
||||
status: Status,
|
||||
/// The type of the task.
|
||||
#[serde(rename = "type")]
|
||||
kind: Kind,
|
||||
/// The date on which the task was enqueued.
|
||||
#[serde(serialize_with = "time::serde::rfc3339::serialize")]
|
||||
enqueued_at: OffsetDateTime,
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use deserr::Deserr;
|
||||
use index_scheduler::{IndexScheduler, Query, TaskId};
|
||||
use meilisearch_types::deserr::query_params::Param;
|
||||
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::index_uid::IndexUid;
|
||||
use meilisearch_types::settings::{
|
||||
@ -43,7 +43,7 @@ const DEFAULT_LIMIT: u32 = 20;
|
||||
|
||||
)),
|
||||
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;
|
||||
|
||||
@ -404,6 +404,7 @@ async fn delete_tasks(
|
||||
|
||||
#[derive(Debug, Serialize, ToSchema)]
|
||||
pub struct AllTasks {
|
||||
/// The list of tasks that matched the filter.
|
||||
results: Vec<TaskView>,
|
||||
/// Total number of browsable results using offset/limit parameters for the given resource.
|
||||
total: u64,
|
||||
|
Loading…
Reference in New Issue
Block a user