mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-01-09 04:54:31 +01:00
review all the return type
This commit is contained in:
parent
5f55e88484
commit
ac944f0960
@ -16,7 +16,7 @@ pub struct TaskView {
|
||||
#[schema(value_type = u32, example = 4312)]
|
||||
pub uid: TaskId,
|
||||
/// The unique identifier of the index where this task is operated.
|
||||
#[schema(example = json!("movies"))]
|
||||
#[schema(value_type = Option<u32>, example = json!("movies"))]
|
||||
pub batch_uid: Option<BatchId>,
|
||||
#[serde(default)]
|
||||
pub index_uid: Option<String>,
|
||||
|
@ -16,7 +16,7 @@ use time::OffsetDateTime;
|
||||
use utoipa::{IntoParams, OpenApi, ToSchema};
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::{PAGINATION_DEFAULT_LIMIT, PAGINATION_DEFAULT_LIMIT_FN};
|
||||
use super::{PaginationView, PAGINATION_DEFAULT_LIMIT, PAGINATION_DEFAULT_LIMIT_FN};
|
||||
use crate::extractors::authentication::policies::*;
|
||||
use crate::extractors::authentication::GuardedData;
|
||||
use crate::extractors::sequential_extractor::SeqHandler;
|
||||
@ -134,7 +134,6 @@ impl ListApiKeys {
|
||||
/// Get API Keys
|
||||
///
|
||||
/// List all API Keys
|
||||
/// TODO: Tamo fix the return type
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/",
|
||||
@ -142,7 +141,7 @@ impl ListApiKeys {
|
||||
security(("Bearer" = ["keys.get", "keys.*", "*"])),
|
||||
params(ListApiKeys),
|
||||
responses(
|
||||
(status = 202, description = "List of keys", body = serde_json::Value, content_type = "application/json", example = json!(
|
||||
(status = 202, description = "List of keys", body = PaginationView<KeyView>, content_type = "application/json", example = json!(
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
@ -268,11 +267,10 @@ pub async fn get_api_key(
|
||||
}
|
||||
|
||||
|
||||
/// Update an API Key
|
||||
/// Update a Key
|
||||
///
|
||||
/// Update an API key from its `uid` or its `key` field.
|
||||
/// Only the `name` and `description` of the api key can be updated.
|
||||
/// If there is an issue with the `key` or `uid` of a key, then you must recreate one from scratch.
|
||||
/// Update the name and description of an API key.
|
||||
/// Updates to keys are partial. This means you should provide only the fields you intend to update, as any fields not present in the payload will remain unchanged.
|
||||
#[utoipa::path(
|
||||
patch,
|
||||
path = "/{uidOrKey}",
|
||||
@ -338,11 +336,9 @@ pub async fn patch_api_key(
|
||||
|
||||
|
||||
|
||||
/// Update an API Key
|
||||
/// Delete a key
|
||||
///
|
||||
/// Update an API key from its `uid` or its `key` field.
|
||||
/// Only the `name` and `description` of the api key can be updated.
|
||||
/// If there is an issue with the `key` or `uid` of a key, then you must recreate one from scratch.
|
||||
/// Delete the specified API key.
|
||||
#[utoipa::path(
|
||||
delete,
|
||||
path = "/{uidOrKey}",
|
||||
|
@ -372,25 +372,30 @@ pub async fn delete_document(
|
||||
Ok(HttpResponse::Accepted().json(task))
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserr)]
|
||||
#[derive(Debug, Deserr, IntoParams)]
|
||||
#[deserr(error = DeserrQueryParamError, rename_all = camelCase, deny_unknown_fields)]
|
||||
#[into_params(rename_all = "camelCase", parameter_in = Query)]
|
||||
pub struct BrowseQueryGet {
|
||||
#[param(default, value_type = Option<usize>)]
|
||||
#[deserr(default, error = DeserrQueryParamError<InvalidDocumentOffset>)]
|
||||
offset: Param<usize>,
|
||||
#[param(default, value_type = Option<usize>)]
|
||||
#[deserr(default = Param(PAGINATION_DEFAULT_LIMIT), error = DeserrQueryParamError<InvalidDocumentLimit>)]
|
||||
limit: Param<usize>,
|
||||
#[param(default, value_type = Option<Vec<String>>)]
|
||||
#[deserr(default, error = DeserrQueryParamError<InvalidDocumentFields>)]
|
||||
fields: OptionStarOrList<String>,
|
||||
#[param(default, value_type = Option<bool>)]
|
||||
#[deserr(default, error = DeserrQueryParamError<InvalidDocumentRetrieveVectors>)]
|
||||
retrieve_vectors: Param<bool>,
|
||||
#[param(default, value_type = Option<String>, example = "popularity > 1000")]
|
||||
#[deserr(default, error = DeserrQueryParamError<InvalidDocumentFilter>)]
|
||||
filter: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserr, IntoParams, ToSchema)]
|
||||
#[derive(Debug, Deserr, ToSchema)]
|
||||
#[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields)]
|
||||
#[schema(rename_all = "camelCase")]
|
||||
#[into_params(rename_all = "camelCase", parameter_in = Query)]
|
||||
pub struct BrowseQuery {
|
||||
#[schema(default, example = 150)]
|
||||
#[deserr(default, error = DeserrJsonError<InvalidDocumentOffset>)]
|
||||
@ -404,7 +409,7 @@ pub struct BrowseQuery {
|
||||
#[schema(default, example = true)]
|
||||
#[deserr(default, error = DeserrJsonError<InvalidDocumentRetrieveVectors>)]
|
||||
retrieve_vectors: bool,
|
||||
#[schema(default, example = "popularity > 1000")]
|
||||
#[schema(default, value_type = Option<Value>, example = "popularity > 1000")]
|
||||
#[deserr(default, error = DeserrJsonError<InvalidDocumentFilter>)]
|
||||
filter: Option<Value>,
|
||||
}
|
||||
@ -494,7 +499,7 @@ pub async fn documents_by_query_post(
|
||||
security(("Bearer" = ["documents.get", "documents.*", "*"])),
|
||||
params(
|
||||
("indexUid", example = "movies", description = "Index Unique Identifier", nullable = false),
|
||||
BrowseQuery
|
||||
BrowseQueryGet
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "The documents are returned", body = PaginationView<serde_json::Value>, content_type = "application/json", example = json!(
|
||||
|
@ -234,9 +234,8 @@ macro_rules! make_setting_route {
|
||||
tag = "Settings",
|
||||
security(("Bearer" = ["settings.get", "settings.*", "*"])),
|
||||
params(("indexUid", example = "movies", description = "Index Unique Identifier", nullable = false)),
|
||||
request_body = $type,
|
||||
responses(
|
||||
(status = 200, description = concat!($camelcase_attr, " is returned"), body = SummarizedTaskView, content_type = "application/json", example = json!(
|
||||
(status = 200, description = concat!($camelcase_attr, " is returned"), body = $type, content_type = "application/json", example = json!(
|
||||
<$type>::default()
|
||||
)),
|
||||
(status = 401, description = "The authorization header is missing", body = ResponseError, content_type = "application/json", example = json!(
|
||||
|
@ -8,6 +8,7 @@ use crate::routes::batches::AllBatches;
|
||||
use crate::routes::features::RuntimeTogglableFeatures;
|
||||
use crate::routes::indexes::documents::DocumentDeletionByFilter;
|
||||
use crate::routes::indexes::documents::DocumentEditionByFunction;
|
||||
use crate::routes::indexes::IndexView;
|
||||
use crate::routes::multi_search::SearchResults;
|
||||
use crate::routes::swap_indexes::SwapIndexesPayload;
|
||||
use crate::search::{
|
||||
@ -87,7 +88,7 @@ pub mod tasks;
|
||||
(name = "Stats", description = "Stats gives extended information and metrics about indexes and the Meilisearch database."),
|
||||
),
|
||||
modifiers(&OpenApiAuth),
|
||||
components(schemas(DocumentDeletionByFilter, AllBatches, BatchStats, ProgressStepView, ProgressView, BatchView, RuntimeTogglableFeatures, SwapIndexesPayload, DocumentEditionByFunction, MergeFacets, FederationOptions, SearchQueryWithIndex, Federation, FederatedSearch, FederatedSearchResult, SearchResults, SearchResultWithIndex, SimilarQuery, SimilarResult, PaginationView<serde_json::Value>, BrowseQuery, UpdateIndexRequest, IndexUid, IndexCreateRequest, KeyView, Action, CreateApiKey, UpdateStderrLogs, LogMode, GetLogs, IndexStats, Stats, HealthStatus, HealthResponse, VersionResponse, Code, ErrorType, AllTasks, TaskView, Status, DetailsView, ResponseError, Settings<Unchecked>, Settings<Checked>, TypoSettings, MinWordSizeTyposSetting, FacetingSettings, PaginationSettings, SummarizedTaskView, Kind))
|
||||
components(schemas(PaginationView<KeyView>, PaginationView<IndexView>, IndexView, DocumentDeletionByFilter, AllBatches, BatchStats, ProgressStepView, ProgressView, BatchView, RuntimeTogglableFeatures, SwapIndexesPayload, DocumentEditionByFunction, MergeFacets, FederationOptions, SearchQueryWithIndex, Federation, FederatedSearch, FederatedSearchResult, SearchResults, SearchResultWithIndex, SimilarQuery, SimilarResult, PaginationView<serde_json::Value>, BrowseQuery, UpdateIndexRequest, IndexUid, IndexCreateRequest, KeyView, Action, CreateApiKey, UpdateStderrLogs, LogMode, GetLogs, IndexStats, Stats, HealthStatus, HealthResponse, VersionResponse, Code, ErrorType, AllTasks, TaskView, Status, DetailsView, ResponseError, Settings<Unchecked>, Settings<Checked>, TypoSettings, MinWordSizeTyposSetting, FacetingSettings, PaginationSettings, SummarizedTaskView, Kind))
|
||||
)]
|
||||
pub struct MeilisearchApi;
|
||||
|
||||
@ -200,6 +201,7 @@ pub struct Pagination {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, ToSchema)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[schema(rename_all = "camelCase")]
|
||||
pub struct PaginationView<T> {
|
||||
pub results: Vec<T>,
|
||||
pub offset: usize,
|
||||
|
Loading…
x
Reference in New Issue
Block a user