From 5c7fa9b92457c1adc6b557ee49ffeaa906516994 Mon Sep 17 00:00:00 2001 From: Tamo Date: Mon, 13 Jan 2025 11:40:57 +0100 Subject: [PATCH 1/5] fix the examples of the experimental-feature route --- crates/meilisearch/src/routes/features.rs | 31 ++++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/crates/meilisearch/src/routes/features.rs b/crates/meilisearch/src/routes/features.rs index b7e85882f..30838de6f 100644 --- a/crates/meilisearch/src/routes/features.rs +++ b/crates/meilisearch/src/routes/features.rs @@ -45,13 +45,13 @@ pub fn configure(cfg: &mut web::ServiceConfig) { tag = "Experimental features", security(("Bearer" = ["experimental_features.get", "experimental_features.*", "*"])), responses( - (status = OK, description = "Experimental features are returned", body = RuntimeTogglableFeatures, content_type = "application/json", example = json!( - { - "metrics": false, - "logsRoute": true, - "vectorSearch": false, - } - )), + (status = OK, description = "Experimental features are returned", body = RuntimeTogglableFeatures, content_type = "application/json", example = json!(RuntimeTogglableFeatures { + vector_store: Some(true), + metrics: Some(true), + logs_route: Some(false), + edit_documents_by_function: Some(false), + contains_filter: Some(false), + })), (status = 401, description = "The authorization header is missing", body = ResponseError, content_type = "application/json", example = json!( { "message": "The Authorization header is missing. It must use the bearer authorization method.", @@ -75,8 +75,9 @@ async fn get_features( HttpResponse::Ok().json(features) } -#[derive(Debug, Deserr, ToSchema)] +#[derive(Debug, Deserr, ToSchema, Serialize)] #[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields)] +#[serde(rename_all = "camelCase")] #[schema(rename_all = "camelCase")] pub struct RuntimeTogglableFeatures { #[deserr(default)] @@ -129,13 +130,13 @@ impl Aggregate for PatchExperimentalFeatureAnalytics { tag = "Experimental features", security(("Bearer" = ["experimental_features.update", "experimental_features.*", "*"])), responses( - (status = OK, description = "Experimental features are returned", body = RuntimeTogglableFeatures, content_type = "application/json", example = json!( - { - "metrics": false, - "logsRoute": true, - "vectorSearch": false, - } - )), + (status = OK, description = "Experimental features are returned", body = RuntimeTogglableFeatures, content_type = "application/json", example = json!(RuntimeTogglableFeatures { + vector_store: Some(true), + metrics: Some(true), + logs_route: Some(false), + edit_documents_by_function: Some(false), + contains_filter: Some(false), + })), (status = 401, description = "The authorization header is missing", body = ResponseError, content_type = "application/json", example = json!( { "message": "The Authorization header is missing. It must use the bearer authorization method.", From 67a0c9fff85e7bfae42d6e2d7a4d830bc3487b21 Mon Sep 17 00:00:00 2001 From: Tamo Date: Mon, 13 Jan 2025 11:55:59 +0100 Subject: [PATCH 2/5] remove trailing slash in path --- crates/meilisearch/src/routes/api_key.rs | 4 ++-- crates/meilisearch/src/routes/batches.rs | 2 +- crates/meilisearch/src/routes/dump.rs | 2 +- crates/meilisearch/src/routes/features.rs | 4 ++-- crates/meilisearch/src/routes/indexes/mod.rs | 4 ++-- crates/meilisearch/src/routes/metrics.rs | 2 +- crates/meilisearch/src/routes/multi_search.rs | 2 +- crates/meilisearch/src/routes/snapshot.rs | 2 +- crates/meilisearch/src/routes/swap_indexes.rs | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/meilisearch/src/routes/api_key.rs b/crates/meilisearch/src/routes/api_key.rs index 9f832b0f2..3130006e3 100644 --- a/crates/meilisearch/src/routes/api_key.rs +++ b/crates/meilisearch/src/routes/api_key.rs @@ -54,7 +54,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) { /// Create an API Key. #[utoipa::path( post, - path = "/", + path = "", tag = "Keys", security(("Bearer" = ["keys.create", "keys.*", "*"])), request_body = CreateApiKey, @@ -133,7 +133,7 @@ impl ListApiKeys { /// List all API Keys #[utoipa::path( get, - path = "/", + path = "", tag = "Keys", security(("Bearer" = ["keys.get", "keys.*", "*"])), params(ListApiKeys), diff --git a/crates/meilisearch/src/routes/batches.rs b/crates/meilisearch/src/routes/batches.rs index 7a801dae6..8ca9f1537 100644 --- a/crates/meilisearch/src/routes/batches.rs +++ b/crates/meilisearch/src/routes/batches.rs @@ -121,7 +121,7 @@ pub struct AllBatches { /// Batch results are paginated and can be filtered with query parameters. #[utoipa::path( get, - path = "/", + path = "", tag = "Batches", security(("Bearer" = ["tasks.get", "tasks.*", "*"])), params(TasksFilterQuery), diff --git a/crates/meilisearch/src/routes/dump.rs b/crates/meilisearch/src/routes/dump.rs index 8bcb167ee..bc16409a2 100644 --- a/crates/meilisearch/src/routes/dump.rs +++ b/crates/meilisearch/src/routes/dump.rs @@ -45,7 +45,7 @@ crate::empty_analytics!(DumpAnalytics, "Dump Created"); /// If the dump directory does not exist yet, it will be created. #[utoipa::path( post, - path = "/", + path = "", tag = "Dumps", security(("Bearer" = ["dumps.create", "dumps.*", "*"])), responses( diff --git a/crates/meilisearch/src/routes/features.rs b/crates/meilisearch/src/routes/features.rs index 30838de6f..e0b8073e6 100644 --- a/crates/meilisearch/src/routes/features.rs +++ b/crates/meilisearch/src/routes/features.rs @@ -41,7 +41,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) { /// Get a list of all experimental features that can be activated via the /experimental-features route and whether or not they are currently activated. #[utoipa::path( post, - path = "/", + path = "", tag = "Experimental features", security(("Bearer" = ["experimental_features.get", "experimental_features.*", "*"])), responses( @@ -126,7 +126,7 @@ impl Aggregate for PatchExperimentalFeatureAnalytics { /// Activate or deactivate experimental features. #[utoipa::path( patch, - path = "/", + path = "", tag = "Experimental features", security(("Bearer" = ["experimental_features.update", "experimental_features.*", "*"])), responses( diff --git a/crates/meilisearch/src/routes/indexes/mod.rs b/crates/meilisearch/src/routes/indexes/mod.rs index 2b1fddd6b..a03d5f691 100644 --- a/crates/meilisearch/src/routes/indexes/mod.rs +++ b/crates/meilisearch/src/routes/indexes/mod.rs @@ -135,7 +135,7 @@ impl ListIndexes { /// List all indexes. #[utoipa::path( get, - path = "/", + path = "", tag = "Indexes", security(("Bearer" = ["indexes.get", "indexes.*", "*"])), params(ListIndexes), @@ -226,7 +226,7 @@ impl Aggregate for IndexCreatedAggregate { /// Create an index. #[utoipa::path( post, - path = "/", + path = "", tag = "Indexes", security(("Bearer" = ["indexes.create", "indexes.*", "*"])), request_body = IndexCreateRequest, diff --git a/crates/meilisearch/src/routes/metrics.rs b/crates/meilisearch/src/routes/metrics.rs index 03a1923ca..6e93284c2 100644 --- a/crates/meilisearch/src/routes/metrics.rs +++ b/crates/meilisearch/src/routes/metrics.rs @@ -30,7 +30,7 @@ pub fn configure(config: &mut web::ServiceConfig) { /// which means it must be enabled. #[utoipa::path( get, - path = "/", + path = "", tag = "Stats", security(("Bearer" = ["metrics.get", "metrics.*", "*"])), responses( diff --git a/crates/meilisearch/src/routes/multi_search.rs b/crates/meilisearch/src/routes/multi_search.rs index 2d15d29bf..495b3c99c 100644 --- a/crates/meilisearch/src/routes/multi_search.rs +++ b/crates/meilisearch/src/routes/multi_search.rs @@ -48,7 +48,7 @@ pub struct SearchResults { /// Bundle multiple search queries in a single API request. Use this endpoint to search through multiple indexes at once. #[utoipa::path( post, - path = "/", + path = "", tag = "Multi-search", security(("Bearer" = ["search", "*"])), responses( diff --git a/crates/meilisearch/src/routes/snapshot.rs b/crates/meilisearch/src/routes/snapshot.rs index b7bb116ed..de7ecc37f 100644 --- a/crates/meilisearch/src/routes/snapshot.rs +++ b/crates/meilisearch/src/routes/snapshot.rs @@ -39,7 +39,7 @@ crate::empty_analytics!(SnapshotAnalytics, "Snapshot Created"); /// Triggers a snapshot creation process. Once the process is complete, a snapshot is created in the snapshot directory. If the snapshot directory does not exist yet, it will be created. #[utoipa::path( post, - path = "/", + path = "", tag = "Snapshots", security(("Bearer" = ["snapshots.create", "snapshots.*", "*"])), responses( diff --git a/crates/meilisearch/src/routes/swap_indexes.rs b/crates/meilisearch/src/routes/swap_indexes.rs index 2d46642c0..4a35d1a6d 100644 --- a/crates/meilisearch/src/routes/swap_indexes.rs +++ b/crates/meilisearch/src/routes/swap_indexes.rs @@ -63,7 +63,7 @@ impl Aggregate for IndexSwappedAnalytics { /// Swapping indexA and indexB will also replace every mention of indexA by indexB and vice-versa in the task history. enqueued tasks are left unmodified. #[utoipa::path( post, - path = "/", + path = "", tag = "Indexes", security(("Bearer" = ["search", "*"])), request_body = Vec, From 6bfcad4b05ac46d44d127095c593baa4ee63f6d9 Mon Sep 17 00:00:00 2001 From: Tamo Date: Mon, 13 Jan 2025 12:13:39 +0100 Subject: [PATCH 3/5] Add the server property --- crates/meilisearch/src/routes/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/meilisearch/src/routes/mod.rs b/crates/meilisearch/src/routes/mod.rs index e37532359..3dcefdf46 100644 --- a/crates/meilisearch/src/routes/mod.rs +++ b/crates/meilisearch/src/routes/mod.rs @@ -81,6 +81,10 @@ pub mod tasks; (name = "Stats", description = "Stats gives extended information and metrics about indexes and the Meilisearch database."), ), modifiers(&OpenApiAuth), + servers(( + url = "/", + description = "Local server", + )), components(schemas(PaginationView, PaginationView, IndexView, DocumentDeletionByFilter, AllBatches, BatchStats, ProgressStepView, ProgressView, BatchView, RuntimeTogglableFeatures, SwapIndexesPayload, DocumentEditionByFunction, MergeFacets, FederationOptions, SearchQueryWithIndex, Federation, FederatedSearch, FederatedSearchResult, SearchResults, SearchResultWithIndex, SimilarQuery, SimilarResult, PaginationView, BrowseQuery, UpdateIndexRequest, IndexUid, IndexCreateRequest, KeyView, Action, CreateApiKey, UpdateStderrLogs, LogMode, GetLogs, IndexStats, Stats, HealthStatus, HealthResponse, VersionResponse, Code, ErrorType, AllTasks, TaskView, Status, DetailsView, ResponseError, Settings, Settings, TypoSettings, MinWordSizeTyposSetting, FacetingSettings, PaginationSettings, SummarizedTaskView, Kind)) )] pub struct MeilisearchApi; From 0de34aa8fa84a3565583ff4900d43e1eb0077f6c Mon Sep 17 00:00:00 2001 From: Tamo Date: Mon, 13 Jan 2025 12:36:22 +0100 Subject: [PATCH 4/5] avoid generating the same operationId --- crates/meilisearch/src/routes/indexes/settings.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/meilisearch/src/routes/indexes/settings.rs b/crates/meilisearch/src/routes/indexes/settings.rs index 4307caea8..e2138ee4d 100644 --- a/crates/meilisearch/src/routes/indexes/settings.rs +++ b/crates/meilisearch/src/routes/indexes/settings.rs @@ -86,6 +86,7 @@ macro_rules! make_setting_route { path = concat!("{indexUid}/settings", $route), tag = "Settings", security(("Bearer" = ["settings.update", "settings.*", "*"])), + operation_id = concat!("delete", $camelcase_attr), summary = concat!("Reset ", $camelcase_attr), description = concat!("Reset an index's ", $camelcase_attr, " to its default value"), params(("indexUid", example = "movies", description = "Index Unique Identifier", nullable = false)), @@ -149,6 +150,7 @@ macro_rules! make_setting_route { path = concat!("{indexUid}/settings", $route), tag = "Settings", security(("Bearer" = ["settings.update", "settings.*", "*"])), + operation_id = concat!(stringify!($update_verb), $camelcase_attr), summary = concat!("Update ", $camelcase_attr), description = concat!("Update an index's user defined ", $camelcase_attr), params(("indexUid", example = "movies", description = "Index Unique Identifier", nullable = false)), @@ -236,6 +238,7 @@ macro_rules! make_setting_route { summary = concat!("Get ", $camelcase_attr), description = concat!("Get an user defined ", $camelcase_attr), security(("Bearer" = ["settings.get", "settings.*", "*"])), + operation_id = concat!("get", $camelcase_attr), params(("indexUid", example = "movies", description = "Index Unique Identifier", nullable = false)), responses( (status = 200, description = concat!($camelcase_attr, " is returned"), body = $type, content_type = "application/json", example = json!( From c9fb6c48b823a24e69b7b51576910f6086b85118 Mon Sep 17 00:00:00 2001 From: Tamo Date: Mon, 13 Jan 2025 13:43:38 +0100 Subject: [PATCH 5/5] Update crates/meilisearch/src/routes/features.rs Co-authored-by: Louis Dureuil --- crates/meilisearch/src/routes/features.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/meilisearch/src/routes/features.rs b/crates/meilisearch/src/routes/features.rs index e0b8073e6..fe41ad9d9 100644 --- a/crates/meilisearch/src/routes/features.rs +++ b/crates/meilisearch/src/routes/features.rs @@ -40,7 +40,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) { /// /// Get a list of all experimental features that can be activated via the /experimental-features route and whether or not they are currently activated. #[utoipa::path( - post, + get, path = "", tag = "Experimental features", security(("Bearer" = ["experimental_features.get", "experimental_features.*", "*"])),