From 43e60619afb6692bf30663714725f2eff2d541bb Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Sat, 8 Nov 2025 21:21:39 +0000 Subject: [PATCH 01/17] Optimize --- typesense/src/traits/document.rs | 1 + typesense/src/traits/field_type.rs | 100 ++++++++---------- typesense/tests/client/aliases_test.rs | 6 +- typesense/tests/client/collections_test.rs | 16 +-- .../tests/client/conversation_models_test.rs | 22 ++-- .../tests/client/derive_integration_test.rs | 16 +-- typesense/tests/client/documents_test.rs | 32 +++--- typesense/tests/client/multi_search_test.rs | 13 +-- typesense/tests/derive/collection.rs | 7 +- .../src/models/collection_schema.rs | 8 +- typesense_codegen/src/models/field.rs | 25 ++--- typesense_derive/src/field_attributes.rs | 59 +++++------ typesense_derive/src/lib.rs | 30 ++++-- 13 files changed, 162 insertions(+), 173 deletions(-) diff --git a/typesense/src/traits/document.rs b/typesense/src/traits/document.rs index dd019bd4..0c4a5453 100644 --- a/typesense/src/traits/document.rs +++ b/typesense/src/traits/document.rs @@ -14,6 +14,7 @@ pub trait DocumentPartial: Serialize {} pub trait Document: DeserializeOwned + Serialize { /// Collection name const COLLECTION_NAME: &'static str; + /// A struct for partial updates type Partial: DocumentPartial; diff --git a/typesense/src/traits/field_type.rs b/typesense/src/traits/field_type.rs index da2b52df..cf96142a 100644 --- a/typesense/src/traits/field_type.rs +++ b/typesense/src/traits/field_type.rs @@ -5,75 +5,65 @@ pub type FieldType = String; /// Trait that should implement each type of a document, in order to properly serialize the /// Collection Schema according to the Typesense reference. -pub trait ToTypesenseField { - /// Static function that should implement the types of the typesense documents. - fn to_typesense_type() -> &'static str; +pub trait TypesenseField { + /// the type of the typesense document. + const TYPESENSE_TYPE: &'static str; } /// Generic implementation for any type that is also a Typesense document. -impl ToTypesenseField for T { - fn to_typesense_type() -> &'static str { - "object" - } +impl TypesenseField for T { + const TYPESENSE_TYPE: &'static str = "object"; } /// Generic implementation for a Vec of any type that is also a Typesense document. -impl ToTypesenseField for Vec { - fn to_typesense_type() -> &'static str { - "object[]" - } +impl TypesenseField for Vec { + const TYPESENSE_TYPE: &'static str = "object[]"; } -/// macro used internally to add implementations of ToTypesenseField for several rust types. +/// macro used internally to add implementations of TypesenseField for several rust types. #[macro_export] -macro_rules! impl_to_typesense_field ( +macro_rules! impl_typesense_field ( ($for:ty, $typesense_variant:expr) => { - impl $crate::prelude::ToTypesenseField for $for { - #[inline(always)] - fn to_typesense_type() -> &'static str { - $typesense_variant - } + impl $crate::prelude::TypesenseField for $for { + const TYPESENSE_TYPE: &'static str = $typesense_variant; } }; ($for:ty, $typesense_variant:expr, $any:ident) => { - impl<$any> $crate::prelude::ToTypesenseField for $for { - #[inline(always)] - fn to_typesense_type() -> &'static str { - $typesense_variant - } + impl<$any> $crate::prelude::TypesenseField for $for { + const TYPESENSE_TYPE: &'static str = $typesense_variant; } }; ); -impl_to_typesense_field!(String, "string"); -impl_to_typesense_field!(i8, "int32"); -impl_to_typesense_field!(u8, "int32"); -impl_to_typesense_field!(i16, "int32"); -impl_to_typesense_field!(u16, "int32"); -impl_to_typesense_field!(i32, "int32"); -impl_to_typesense_field!(u32, "int64"); -impl_to_typesense_field!(i64, "int64"); -impl_to_typesense_field!(u64, "int64"); -impl_to_typesense_field!(isize, "int64"); -impl_to_typesense_field!(usize, "int64"); -impl_to_typesense_field!(f32, "float"); -impl_to_typesense_field!(f64, "float"); -impl_to_typesense_field!(bool, "bool"); -impl_to_typesense_field!(HashMap, "object", T); -impl_to_typesense_field!(BTreeMap, "object", T); +impl_typesense_field!(String, "string"); +impl_typesense_field!(i8, "int32"); +impl_typesense_field!(u8, "int32"); +impl_typesense_field!(i16, "int32"); +impl_typesense_field!(u16, "int32"); +impl_typesense_field!(i32, "int32"); +impl_typesense_field!(u32, "int64"); +impl_typesense_field!(i64, "int64"); +impl_typesense_field!(u64, "int64"); +impl_typesense_field!(isize, "int64"); +impl_typesense_field!(usize, "int64"); +impl_typesense_field!(f32, "float"); +impl_typesense_field!(f64, "float"); +impl_typesense_field!(bool, "bool"); +impl_typesense_field!(HashMap, "object", T); +impl_typesense_field!(BTreeMap, "object", T); -impl_to_typesense_field!(Vec, "string[]"); -impl_to_typesense_field!(Vec, "int32[]"); -impl_to_typesense_field!(Vec, "int32[]"); -impl_to_typesense_field!(Vec, "int32[]"); -impl_to_typesense_field!(Vec, "int32[]"); -impl_to_typesense_field!(Vec, "int32[]"); -impl_to_typesense_field!(Vec, "int64[]"); -impl_to_typesense_field!(Vec, "int64[]"); -impl_to_typesense_field!(Vec, "int64[]"); -impl_to_typesense_field!(Vec, "int64[]"); -impl_to_typesense_field!(Vec, "int64[]"); -impl_to_typesense_field!(Vec, "float[]"); -impl_to_typesense_field!(Vec, "float[]"); -impl_to_typesense_field!(Vec, "bool[]"); -impl_to_typesense_field!(Vec>, "object[]", T); -impl_to_typesense_field!(Vec>, "object[]", T); +impl_typesense_field!(Vec, "string[]"); +impl_typesense_field!(Vec, "int32[]"); +impl_typesense_field!(Vec, "int32[]"); +impl_typesense_field!(Vec, "int32[]"); +impl_typesense_field!(Vec, "int32[]"); +impl_typesense_field!(Vec, "int32[]"); +impl_typesense_field!(Vec, "int64[]"); +impl_typesense_field!(Vec, "int64[]"); +impl_typesense_field!(Vec, "int64[]"); +impl_typesense_field!(Vec, "int64[]"); +impl_typesense_field!(Vec, "int64[]"); +impl_typesense_field!(Vec, "float[]"); +impl_typesense_field!(Vec, "float[]"); +impl_typesense_field!(Vec, "bool[]"); +impl_typesense_field!(Vec>, "object[]", T); +impl_typesense_field!(Vec>, "object[]", T); diff --git a/typesense/tests/client/aliases_test.rs b/typesense/tests/client/aliases_test.rs index 7faf0185..0f80024c 100644 --- a/typesense/tests/client/aliases_test.rs +++ b/typesense/tests/client/aliases_test.rs @@ -9,10 +9,10 @@ async fn logic_test_aliases_and_alias_lifecycle() { // --- 1. Create a collection to alias to --- let collection_schema = CollectionSchema { - name: collection_name.clone(), + name: collection_name.clone().into(), fields: vec![Field { - name: "name".to_owned(), - r#type: "string".to_owned(), + name: "name".into(), + r#type: "string".into(), ..Default::default() }], ..Default::default() diff --git a/typesense/tests/client/collections_test.rs b/typesense/tests/client/collections_test.rs index 70d471cb..1c7fa33a 100644 --- a/typesense/tests/client/collections_test.rs +++ b/typesense/tests/client/collections_test.rs @@ -10,16 +10,16 @@ async fn logic_test_collections_and_collection_lifecycle() { // --- 1. Create a Collection (via `collections`) --- let schema = CollectionSchema { - name: collection_name.clone(), + name: collection_name.clone().into(), fields: vec![ Field { - name: "name".to_owned(), - r#type: "string".to_owned(), + name: "name".into(), + r#type: "string".into(), ..Default::default() }, Field { - name: "price".to_owned(), - r#type: "int32".to_owned(), + name: "price".into(), + r#type: "int32".into(), ..Default::default() }, ], @@ -67,14 +67,14 @@ async fn logic_test_collections_and_collection_lifecycle() { fields: vec![ // Add a new field Field { - name: "description".to_owned(), - r#type: "string".to_owned(), + name: "description".into(), + r#type: "string".into(), optional: Some(true), ..Default::default() }, // Drop an existing field Field { - name: "price".to_owned(), + name: "price".into(), drop: Some(true), ..Default::default() }, diff --git a/typesense/tests/client/conversation_models_test.rs b/typesense/tests/client/conversation_models_test.rs index d85e469d..3f4f8896 100644 --- a/typesense/tests/client/conversation_models_test.rs +++ b/typesense/tests/client/conversation_models_test.rs @@ -19,32 +19,32 @@ async fn test_create_model_with_invalid_key_fails_as_expected() { // --- 1. Setup: Create the prerequisite collection for history --- let schema = CollectionSchema { - name: collection_name.clone(), + name: collection_name.clone().into(), fields: vec![ Field { - name: "conversation_id".to_owned(), - r#type: "string".to_owned(), + name: "conversation_id".into(), + r#type: "string".into(), ..Default::default() }, Field { - name: "model_id".to_owned(), - r#type: "string".to_owned(), + name: "model_id".into(), + r#type: "string".into(), ..Default::default() }, Field { - name: "timestamp".to_owned(), - r#type: "int32".to_owned(), + name: "timestamp".into(), + r#type: "int32".into(), ..Default::default() }, Field { - name: "role".to_owned(), - r#type: "string".to_owned(), + name: "role".into(), + r#type: "string".into(), index: Some(false), ..Default::default() }, Field { - name: "message".to_owned(), - r#type: "string".to_owned(), + name: "message".into(), + r#type: "string".into(), index: Some(false), ..Default::default() }, diff --git a/typesense/tests/client/derive_integration_test.rs b/typesense/tests/client/derive_integration_test.rs index 89178f95..bf7db058 100644 --- a/typesense/tests/client/derive_integration_test.rs +++ b/typesense/tests/client/derive_integration_test.rs @@ -122,7 +122,7 @@ async fn logic_test_derive_macro_with_generic_client_lifecycle() { // Create Collection using the schema from the derive macro let schema = MegaProduct::collection_schema(); let mut schema_for_creation = schema.clone(); - schema_for_creation.name = collection_name.clone(); // Use the unique name + schema_for_creation.name = collection_name.clone().into(); // Use the unique name let create_res = client.collections().create(schema_for_creation).await; assert!( @@ -142,12 +142,12 @@ async fn logic_test_derive_macro_with_generic_client_lifecycle() { let actual_fields_map: std::collections::HashMap = retrieved_schema .fields .into_iter() - .map(|f| (f.name.clone(), f)) + .map(|f| (f.name.clone().into(), f)) .collect(); // Iterate through our *expected* fields and assert only the attributes we set. - for expected_field in schema.fields { - let field_name = &expected_field.name; + for expected_field in schema.fields.into_iter() { + let field_name = &expected_field.name as &str; // The 'id' field is a special primary key and not listed in the schema's "fields" array. if field_name == "id" { continue; @@ -160,7 +160,7 @@ async fn logic_test_derive_macro_with_generic_client_lifecycle() { }); // Perform targeted checks based on the attributes set in MegaProduct struct - match field_name.as_str() { + match field_name { "title" => { assert_eq!( actual_field.infix, @@ -343,7 +343,7 @@ async fn logic_test_derive_macro_with_generic_client_lifecycle() { "locale" => { assert_eq!( actual_field.locale, - Some("vi".to_owned()), + Some("vi".into()), "Field 'locale' should have locale of 'vi'" ); } @@ -617,10 +617,10 @@ async fn logic_test_manual_flattening_lifecycle() { // 1. Create collection from the schema derived from `ManualFlattenedProduct` let mut schema = ManualFlattenedProduct::collection_schema(); - schema.name = collection_name.clone(); + schema.name = collection_name.clone().into(); // Verify the generated schema is correct *before* creating it - let schema_fields: Vec<_> = schema.fields.iter().map(|f| f.name.as_str()).collect(); + let schema_fields: Vec<_> = schema.fields.iter().map(|f| &f.name as &str).collect(); assert!( !schema_fields.contains(&"details"), "Schema should not contain the skipped 'details' field" diff --git a/typesense/tests/client/documents_test.rs b/typesense/tests/client/documents_test.rs index a98cce1d..c4e6e87d 100644 --- a/typesense/tests/client/documents_test.rs +++ b/typesense/tests/client/documents_test.rs @@ -14,22 +14,22 @@ async fn run_test_schemaless_document_lifecycle() { // --- Setup: Create a Collection --- let schema = CollectionSchema { - name: collection_name.clone(), + name: collection_name.clone().into(), fields: vec![ Field { - name: "title".to_owned(), - r#type: "string".to_owned(), + name: "title".into(), + r#type: "string".into(), ..Default::default() }, Field { - name: "author".to_owned(), - r#type: "string".to_owned(), + name: "author".into(), + r#type: "string".into(), facet: Some(true), ..Default::default() }, Field { - name: "publication_year".to_owned(), - r#type: "int32".to_owned(), + name: "publication_year".into(), + r#type: "int32".into(), ..Default::default() }, ], @@ -152,27 +152,27 @@ async fn run_test_generic_document_lifecycle() { // --- 1. Setup: Create a Collection matching the Book struct --- let schema = CollectionSchema { - name: collection_name.clone(), + name: collection_name.clone().into(), fields: vec![ Field { - name: "title".to_owned(), - r#type: "string".to_owned(), + name: "title".into(), + r#type: "string".into(), ..Default::default() }, Field { - name: "author".to_owned(), - r#type: "string".to_owned(), + name: "author".into(), + r#type: "string".into(), facet: Some(true), ..Default::default() }, Field { - name: "publication_year".to_owned(), - r#type: "int32".to_owned(), + name: "publication_year".into(), + r#type: "int32".into(), ..Default::default() }, Field { - name: "in_stock".to_owned(), - r#type: "bool".to_owned(), + name: "in_stock".into(), + r#type: "bool".into(), optional: Some(true), ..Default::default() }, diff --git a/typesense/tests/client/multi_search_test.rs b/typesense/tests/client/multi_search_test.rs index 643ff45d..95cedec4 100644 --- a/typesense/tests/client/multi_search_test.rs +++ b/typesense/tests/client/multi_search_test.rs @@ -16,20 +16,17 @@ async fn setup_multi_search_tests( ) { // --- Create collections --- let products_schema = CollectionSchema { - name: products_collection_name.to_owned(), - fields: vec![ - Field::new("name".to_owned(), "string".to_owned()), - Field::new("price".to_owned(), "int32".to_owned()), - ], + name: products_collection_name.to_owned().into(), + fields: vec![Field::new("name", "string"), Field::new("price", "int32")], ..Default::default() }; client.collections().create(products_schema).await.unwrap(); let brands_schema = CollectionSchema { - name: brands_collection_name.to_owned(), + name: brands_collection_name.to_owned().into(), fields: vec![ - Field::new("company_name".to_owned(), "string".to_owned()), - Field::new("country".to_owned(), "string".to_owned()), + Field::new("company_name", "string"), + Field::new("country", "string"), ], ..Default::default() }; diff --git a/typesense/tests/derive/collection.rs b/typesense/tests/derive/collection.rs index 9cc6821c..b635ecbc 100644 --- a/typesense/tests/derive/collection.rs +++ b/typesense/tests/derive/collection.rs @@ -1,10 +1,7 @@ -use std::collections::BTreeMap; -use std::collections::HashMap; - +use ::std::collections::{BTreeMap, HashMap}; use serde::{Deserialize, Serialize}; use serde_json::json; -use typesense::Typesense; -use typesense::prelude::*; +use typesense::{Typesense, prelude::*}; // Test 1: Basic Schema Generation (keeping the old test to ensure backward compatibility) #[allow(dead_code)] diff --git a/typesense_codegen/src/models/collection_schema.rs b/typesense_codegen/src/models/collection_schema.rs index b861bee5..703febef 100644 --- a/typesense_codegen/src/models/collection_schema.rs +++ b/typesense_codegen/src/models/collection_schema.rs @@ -9,15 +9,17 @@ */ use crate::models; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(bon::Builder)] +#[builder(on(Cow<'_, str>, into))] #[builder(on(String, into))] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CollectionSchema { /// Name of the collection #[serde(rename = "name")] - pub name: String, + pub name: Cow<'static, str>, /// A list of fields for querying, filtering and faceting #[serde(rename = "fields")] pub fields: Vec, @@ -50,9 +52,9 @@ pub struct CollectionSchema { } impl CollectionSchema { - pub fn new(name: String, fields: Vec) -> CollectionSchema { + pub fn new(name: impl Into>, fields: Vec) -> CollectionSchema { CollectionSchema { - name, + name: name.into(), fields, default_sorting_field: None, token_separators: None, diff --git a/typesense_codegen/src/models/field.rs b/typesense_codegen/src/models/field.rs index 39bacbbc..57a42150 100644 --- a/typesense_codegen/src/models/field.rs +++ b/typesense_codegen/src/models/field.rs @@ -9,16 +9,17 @@ */ use crate::models; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(bon::Builder)] -#[builder(on(String, into))] +#[builder(on(Cow<'_, str>, into))] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Field { #[serde(rename = "name")] - pub name: String, + pub name: Cow<'static, str>, #[serde(rename = "type")] - pub r#type: String, + pub r#type: Cow<'static, str>, #[serde(rename = "optional", skip_serializing_if = "Option::is_none")] pub optional: Option, #[serde(rename = "facet", skip_serializing_if = "Option::is_none")] @@ -26,14 +27,14 @@ pub struct Field { #[serde(rename = "index", skip_serializing_if = "Option::is_none")] pub index: Option, #[serde(rename = "locale", skip_serializing_if = "Option::is_none")] - pub locale: Option, + pub locale: Option>, #[serde(rename = "sort", skip_serializing_if = "Option::is_none")] pub sort: Option, #[serde(rename = "infix", skip_serializing_if = "Option::is_none")] pub infix: Option, /// Name of a field in another collection that should be linked to this collection so that it can be joined during query. #[serde(rename = "reference", skip_serializing_if = "Option::is_none")] - pub reference: Option, + pub reference: Option>, #[serde(rename = "num_dim", skip_serializing_if = "Option::is_none")] pub num_dim: Option, #[serde(rename = "drop", skip_serializing_if = "Option::is_none")] @@ -43,7 +44,7 @@ pub struct Field { pub store: Option, /// The distance metric to be used for vector search. Default: `cosine`. You can also use `ip` for inner product. #[serde(rename = "vec_dist", skip_serializing_if = "Option::is_none")] - pub vec_dist: Option, + pub vec_dist: Option>, /// Enables an index optimized for range filtering on numerical fields (e.g. rating:>3.5). Default: false. #[serde(rename = "range_index", skip_serializing_if = "Option::is_none")] pub range_index: Option, @@ -52,22 +53,22 @@ pub struct Field { pub stem: Option, /// Name of the stemming dictionary to use for this field #[serde(rename = "stem_dictionary", skip_serializing_if = "Option::is_none")] - pub stem_dictionary: Option, + pub stem_dictionary: Option>, /// List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters. #[serde(rename = "token_separators", skip_serializing_if = "Option::is_none")] - pub token_separators: Option>, + pub token_separators: Option>>, /// List of symbols or special characters to be indexed. #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] - pub symbols_to_index: Option>, + pub symbols_to_index: Option>>, #[serde(rename = "embed", skip_serializing_if = "Option::is_none")] pub embed: Option>, } impl Field { - pub fn new(name: String, r#type: String) -> Field { + pub fn new(name: impl Into>, r#type: impl Into>) -> Field { Field { - name, - r#type, + name: name.into(), + r#type: r#type.into(), optional: None, facet: None, index: None, diff --git a/typesense_derive/src/field_attributes.rs b/typesense_derive/src/field_attributes.rs index 8cdfcdbf..905b7ddf 100644 --- a/typesense_derive/src/field_attributes.rs +++ b/typesense_derive/src/field_attributes.rs @@ -257,17 +257,17 @@ fn build_regular_field(field: &Field, field_attrs: &FieldAttributes) -> proc_mac (&field.ty, false) }; - let name_ident = &field.ident; let field_name = if let Some(rename) = &field_attrs.rename { - quote! { #rename.to_string() } + quote! { #rename } } else { - quote! { std::string::String::from(stringify!(#name_ident)) } + let name_ident = field.ident.as_ref().unwrap().to_string(); + quote! { #name_ident } }; let typesense_field_type = if let Some(override_str) = &field_attrs.type_override { - quote! { #override_str.to_owned() } + quote! { #override_str } } else { - quote! { <#ty as typesense::prelude::ToTypesenseField>::to_typesense_type().to_owned() } + quote! { <#ty as ::typesense::prelude::TypesenseField>::TYPESENSE_TYPE } }; let optional = field_attrs @@ -286,17 +286,20 @@ fn build_regular_field(field: &Field, field_attrs: &FieldAttributes) -> proc_mac let num_dim = field_attrs.num_dim.map(|v| quote!(.num_dim(#v))); quote! { - vec![ - typesense::models::Field::builder().name(#field_name).r#type(#typesense_field_type) - #optional #facet #index #store #sort #infix #stem #range_index #locale #vec_dist #num_dim - .build() - ] + typesense::models::Field::builder().name(#field_name).r#type(#typesense_field_type) + #optional #facet #index #store #sort #infix #stem #range_index #locale #vec_dist #num_dim + .build() } } /// Processes a single struct field. /// Returns a TokenStream which evaluates to a `Vec`. -pub(crate) fn process_field(field: &Field) -> syn::Result { +pub(crate) fn process_field( + field: &Field, +) -> syn::Result<( + Option, + Option, +)> { let field_attrs = extract_field_attrs(field)?; if field_attrs.flatten { @@ -304,8 +307,8 @@ pub(crate) fn process_field(field: &Field) -> syn::Result syn::Result::collection_schema().fields + <#inner_type as ::typesense::prelude::Document>::collection_schema().fields .into_iter() .map(|mut f| { // Use the dynamically determined prefix here - f.name = format!("{}.{}", #prefix, f.name); + f.name = ::std::borrow::Cow::Owned(format!("{}.{}", #prefix, f.name)); if #is_vec && !f.r#type.ends_with("[]") { - f.r#type.push_str("[]"); + f.r#type.to_mut().push_str("[]"); } f }) - .collect::>() }; if field_attrs.skip { // `#[typesense(flatten, skip)]` -> Only flattened fields - return Ok(quote! { - { - #flattened_fields - } - }); + return Ok((None, Some(quote! { #flattened_fields }))); } // `#[typesense(flatten)]` -> Flattened fields + object field let regular_field = build_regular_field(field, &field_attrs); - Ok(quote! { - { - let mut fields = #regular_field; - fields.extend(#flattened_fields); - fields - } - }) + Ok(( + Some(quote! { #regular_field }), + Some(quote! { #flattened_fields }), + )) } else { // --- REGULAR FIELD LOGIC --- if field_attrs.skip { - return Ok(quote! { - vec![] - }); + return Ok((None, None)); } - Ok(build_regular_field(field, &field_attrs)) + Ok((Some(build_regular_field(field, &field_attrs)), None)) } } diff --git a/typesense_derive/src/lib.rs b/typesense_derive/src/lib.rs index e62a65f3..b7ec117b 100644 --- a/typesense_derive/src/lib.rs +++ b/typesense_derive/src/lib.rs @@ -6,8 +6,8 @@ use helpers::*; use proc_macro::TokenStream; use proc_macro2::{Ident, TokenTree}; -use quote::{ToTokens, quote}; -use syn::{Attribute, ItemStruct, spanned::Spanned}; +use quote::{quote, ToTokens}; +use syn::{spanned::Spanned, Attribute, ItemStruct}; #[proc_macro_derive(Typesense, attributes(typesense))] pub fn typesense_collection_derive(input: TokenStream) -> TokenStream { @@ -76,10 +76,18 @@ fn impl_typesense_collection(item: ItemStruct) -> syn::Result { } } - let typesense_fields = fields + let (regular_fields, flattened_fields) = fields .iter() .map(process_field) - .collect::>>()?; + .collect::,Vec<_>)>>()?; + let regular_fields = regular_fields + .into_iter() + .filter_map(|v| v) + .collect::>(); + let flattened_fields = flattened_fields + .into_iter() + .filter_map(|v| v) + .collect::>(); let default_sorting_field = if let Some(v) = default_sorting_field { quote! { @@ -139,15 +147,15 @@ fn impl_typesense_collection(item: ItemStruct) -> syn::Result { impl #impl_generics ::typesense::prelude::Document for #ident #ty_generics #where_clause { const COLLECTION_NAME: &str = #collection_name; + type Partial = #name_partial; fn collection_schema() -> ::typesense::models::CollectionSchema { - let name = Self::COLLECTION_NAME.to_owned(); - - let mut fields = Vec::new(); - #(fields.extend(#typesense_fields);)* + let fields = [#(#regular_fields,)*].into_iter() + #(.chain(#flattened_fields))* + .collect::>(); - let builder = ::typesense::models::CollectionSchema::builder().name(name).fields(fields); + let builder = ::typesense::models::CollectionSchema::builder().name(Self::COLLECTION_NAME).fields(fields); #default_sorting_field #enable_nested_fields @@ -161,13 +169,13 @@ fn impl_typesense_collection(item: ItemStruct) -> syn::Result { Ok(generated_code.into()) } -// Add a bound `T: ToTypesenseField` to every type parameter T. +// Add a bound `T: TypesenseField` to every type parameter T. fn add_trait_bounds(mut generics: syn::Generics) -> syn::Generics { for param in &mut generics.params { if let syn::GenericParam::Type(ref mut type_param) = *param { type_param .bounds - .push(syn::parse_quote!(::typesense::field::ToTypesenseField)); + .push(syn::parse_quote!(::typesense::field::TypesenseField)); } } generics From 1a37d6e3ffad2aa80e6e0af39fb449adbfcb1200 Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Sun, 9 Nov 2025 14:27:46 +0000 Subject: [PATCH 02/17] Replace `String` with `Cow<'_, str>` --- .cargo/config.toml | 2 +- openapi-generator-template/model.mustache | 56 ++- .../reqwest/api.mustache | 59 +-- preprocessed_openapi.yml | 32 +- typesense/src/client/alias.rs | 12 +- typesense/src/client/aliases.rs | 14 +- typesense/src/client/collection/document.rs | 25 +- typesense/src/client/collection/documents.rs | 61 ++-- typesense/src/client/collection/mod.rs | 30 +- typesense/src/client/collections.rs | 16 +- typesense/src/client/conversations/model.rs | 23 +- typesense/src/client/conversations/models.rs | 11 +- typesense/src/client/key.rs | 9 +- typesense/src/client/keys.rs | 9 +- typesense/src/client/mod.rs | 12 +- typesense/src/client/multi_search.rs | 60 +-- typesense/src/client/operations.rs | 43 ++- typesense/src/client/preset.rs | 12 +- typesense/src/client/presets.rs | 13 +- typesense/src/client/stemming/dictionaries.rs | 14 +- typesense/src/client/stemming/dictionary.rs | 8 +- typesense/src/client/stopword.rs | 18 +- typesense/src/client/stopwords.rs | 15 +- typesense/src/models/mod.rs | 3 +- typesense/src/models/multi_search.rs | 4 +- typesense/src/models/scoped_key_parameters.rs | 4 +- typesense/src/traits/document.rs | 2 +- typesense/src/traits/multi_search_ext.rs | 35 +- typesense/tests/client/aliases_test.rs | 5 +- typesense/tests/client/client_test.rs | 2 +- .../tests/client/conversation_models_test.rs | 24 +- .../tests/client/derive_integration_test.rs | 59 +-- typesense/tests/client/documents_test.rs | 13 +- typesense/tests/client/keys_test.rs | 4 +- typesense/tests/client/multi_search_test.rs | 29 +- typesense/tests/client/operations_test.rs | 3 +- typesense/tests/client/presets_test.rs | 5 +- typesense/tests/client/stopwords_test.rs | 8 +- typesense/tests/derive/collection.rs | 19 +- typesense_codegen/.openapi-generator/VERSION | 2 +- typesense_codegen/README.md | 2 +- typesense_codegen/src/apis/analytics_api.rs | 158 +++++--- typesense_codegen/src/apis/collections_api.rs | 171 +++++---- .../src/apis/conversations_api.rs | 90 +++-- .../src/apis/curation_sets_api.rs | 155 +++++--- typesense_codegen/src/apis/debug_api.rs | 11 +- typesense_codegen/src/apis/documents_api.rs | 345 ++++++++++-------- typesense_codegen/src/apis/health_api.rs | 11 +- typesense_codegen/src/apis/keys_api.rs | 68 ++-- .../src/apis/nl_search_models_api.rs | 92 +++-- typesense_codegen/src/apis/operations_api.rs | 100 +++-- typesense_codegen/src/apis/presets_api.rs | 70 ++-- typesense_codegen/src/apis/stemming_api.rs | 56 ++- typesense_codegen/src/apis/stopwords_api.rs | 75 ++-- typesense_codegen/src/apis/synonyms_api.rs | 154 +++++--- .../src/models/analytics_event.rs | 24 +- .../models/analytics_event_create_response.rs | 14 +- .../src/models/analytics_event_data.rs | 20 +- .../src/models/analytics_events_response.rs | 16 +- .../analytics_events_response_events_inner.rs | 24 +- .../src/models/analytics_rule.rs | 28 +- .../src/models/analytics_rule_create.rs | 28 +- .../models/analytics_rule_create_params.rs | 16 +- .../src/models/analytics_rule_update.rs | 18 +- .../src/models/analytics_status.rs | 12 +- typesense_codegen/src/models/api_key.rs | 18 +- .../src/models/api_key_delete_response.rs | 14 +- .../src/models/api_key_schema.rs | 20 +- .../src/models/api_keys_response.rs | 16 +- typesense_codegen/src/models/api_response.rs | 16 +- .../src/models/api_stats_response.rs | 12 +- .../src/models/collection_alias.rs | 16 +- .../src/models/collection_alias_schema.rs | 16 +- .../src/models/collection_aliases_response.rs | 16 +- .../src/models/collection_response.rs | 24 +- .../src/models/collection_schema.rs | 24 +- .../src/models/collection_update_schema.rs | 14 +- .../conversation_model_create_schema.rs | 30 +- .../src/models/conversation_model_schema.rs | 32 +- .../conversation_model_update_schema.rs | 26 +- .../create_analytics_rule_200_response.rs | 9 +- ...nalytics_rule_200_response_one_of_inner.rs | 30 +- ...s_rule_200_response_one_of_inner_any_of.rs | 16 +- .../models/create_analytics_rule_request.rs | 9 +- .../src/models/curation_exclude.rs | 16 +- .../src/models/curation_include.rs | 17 +- .../src/models/curation_item_create_schema.rs | 26 +- .../src/models/curation_item_delete_schema.rs | 16 +- .../src/models/curation_item_schema.rs | 26 +- typesense_codegen/src/models/curation_rule.rs | 16 +- .../src/models/curation_set_create_schema.rs | 16 +- .../src/models/curation_set_delete_schema.rs | 16 +- .../src/models/curation_set_schema.rs | 18 +- .../src/models/debug_200_response.rs | 16 +- .../models/delete_documents_200_response.rs | 14 +- .../src/models/delete_documents_parameters.rs | 14 +- .../delete_stopwords_set_200_response.rs | 16 +- typesense_codegen/src/models/dirty_values.rs | 1 + .../src/models/drop_tokens_mode.rs | 1 + .../src/models/export_documents_parameters.rs | 18 +- typesense_codegen/src/models/facet_counts.rs | 18 +- .../src/models/facet_counts_counts_inner.rs | 16 +- .../src/models/facet_counts_stats.rs | 12 +- typesense_codegen/src/models/field.rs | 37 +- typesense_codegen/src/models/field_embed.rs | 14 +- .../src/models/field_embed_model_config.rs | 32 +- .../src/models/get_collections_parameters.rs | 14 +- typesense_codegen/src/models/health_status.rs | 14 +- .../src/models/import_documents_parameters.rs | 12 +- typesense_codegen/src/models/index_action.rs | 1 + ...list_stemming_dictionaries_200_response.rs | 14 +- .../multi_search_collection_parameters.rs | 76 ++-- .../src/models/multi_search_parameters.rs | 72 ++-- .../src/models/multi_search_result.rs | 16 +- .../src/models/multi_search_result_item.rs | 26 +- .../models/multi_search_searches_parameter.rs | 16 +- .../src/models/nl_search_model_base.rs | 36 +- .../models/nl_search_model_create_schema.rs | 38 +- .../models/nl_search_model_delete_schema.rs | 16 +- .../src/models/nl_search_model_schema.rs | 38 +- .../src/models/preset_delete_schema.rs | 16 +- typesense_codegen/src/models/preset_schema.rs | 16 +- .../src/models/preset_upsert_schema.rs | 14 +- .../src/models/preset_upsert_schema_value.rs | 9 +- .../src/models/presets_retrieve_schema.rs | 16 +- .../src/models/schema_change_status.rs | 14 +- .../src/models/search_grouped_hit.rs | 16 +- .../src/models/search_highlight.rs | 18 +- .../src/models/search_parameters.rs | 78 ++-- .../src/models/search_request_params.rs | 18 +- .../search_request_params_voice_query.rs | 14 +- typesense_codegen/src/models/search_result.rs | 24 +- .../src/models/search_result_conversation.rs | 24 +- .../src/models/search_result_hit.rs | 18 +- .../search_result_hit_hybrid_search_info.rs | 12 +- .../search_result_hit_text_match_info.rs | 16 +- .../src/models/search_synonym.rs | 18 +- .../models/search_synonym_delete_response.rs | 16 +- .../src/models/search_synonym_schema.rs | 16 +- .../src/models/search_synonyms_response.rs | 16 +- .../src/models/stemming_dictionary.rs | 19 +- .../models/stemming_dictionary_words_inner.rs | 19 +- .../models/stopwords_set_retrieve_schema.rs | 14 +- .../src/models/stopwords_set_schema.rs | 16 +- .../src/models/stopwords_set_upsert_schema.rs | 14 +- .../stopwords_sets_retrieve_all_schema.rs | 16 +- .../src/models/success_status.rs | 14 +- .../src/models/synonym_item_delete_schema.rs | 16 +- .../src/models/synonym_item_schema.rs | 18 +- .../src/models/synonym_set_create_schema.rs | 16 +- .../src/models/synonym_set_delete_schema.rs | 16 +- .../src/models/synonym_set_schema.rs | 19 +- .../models/synonym_sets_retrieve_schema.rs | 16 +- .../models/toggle_slow_request_log_request.rs | 12 +- .../models/update_documents_200_response.rs | 14 +- .../src/models/update_documents_parameters.rs | 16 +- .../voice_query_model_collection_config.rs | 16 +- typesense_derive/src/lib.rs | 29 +- xtask/Cargo.toml | 6 +- xtask/src/add_vendor_attributes.rs | 35 +- xtask/src/main.rs | 5 + 161 files changed, 2716 insertions(+), 1675 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 3b8bc0da..45bf408c 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,3 +1,3 @@ [alias] xtask = "run --package xtask --" -test-clean = "run --package xtask -- test-clean" +test-clean = "run --package xtask --features typesense -- test-clean" diff --git a/openapi-generator-template/model.mustache b/openapi-generator-template/model.mustache index 627362a2..574791e7 100644 --- a/openapi-generator-template/model.mustache +++ b/openapi-generator-template/model.mustache @@ -1,5 +1,7 @@ {{>partial_header}} use crate::models; +use ::std::borrow::Cow; +use ::std::marker::PhantomData; use serde::{Deserialize, Serialize}; {{#models}} {{#model}} @@ -123,11 +125,12 @@ impl Default for {{classname}} { {{^discriminator}} {{#vendorExtensions.x-rust-builder}} #[derive(bon::Builder)] +#[builder(on(Cow<'_, str>, into))] #[builder(on(String, into))] {{/vendorExtensions.x-rust-builder}} {{#vendorExtensions.x-rust-has-byte-array}}#[serde_as] {{/vendorExtensions.x-rust-has-byte-array}}{{#oneOf.isEmpty}}#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct {{{classname}}}{{{vendorExtensions.x-rust-generic-parameter}}} { +pub struct {{{classname}}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}> { {{#vars}} {{#description}} /// {{{.}}} @@ -145,21 +148,34 @@ pub struct {{{classname}}}{{{vendorExtensions.x-rust-generic-parameter}}} { }}{{#isNullable}}Option<{{/isNullable}}{{^required}}Option<{{/required}}{{! ### Enums }}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{! - ### Non-Enums Start - }}{{^isEnum}}{{! ### Models - }}{{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{{dataType}}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}{{! - ### Primative datatypes - }}{{^isModel}}{{#isByteArray}}Vec{{/isByteArray}}{{^isByteArray}}{{{dataType}}}{{/isByteArray}}{{/isModel}}{{! - ### Non-Enums End - }}{{/isEnum}}{{! + }}{{^isEnum}}{{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{{dataType}}}<'a>{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}{{! + ### ByteArray + }}{{^isModel}}{{#isByteArray}}Vec{{/isByteArray}}{{! + ### String + }}{{^isByteArray}}{{#isString}}Cow<'a, str>{{/isString}}{{! + ### Arrays + }}{{^isString}}{{#isArray}}Vec<{{#items}}{{! + ### Array Models + }}{{#isModel}}{{{dataType}}}<'a>{{/isModel}}{{! + ### Array other datatypes + }}{{^isModel}}{{{dataType}}}{{/isModel}}{{/items}}>{{/isArray}}{{! + ### Primitive datatypes + }}{{^isArray}}{{#isPrimitiveType}}{{{dataType}}}{{/isPrimitiveType}}{{! + ### Any other Non-Primitive datatypes + }}{{^isPrimitiveType}}{{{dataType}}}{{! + ### Closing tags + }}{{/isPrimitiveType}}{{/isArray}}{{/isString}}{{/isByteArray}}{{/isModel}}{{/isEnum}}{{! ### Option End (and trailing comma) }}{{#isNullable}}>{{/isNullable}}{{^required}}>{{/required}}, {{/vendorExtensions.x-rust-type}} {{/vars}} + #[serde(skip)] + {{#vendorExtensions.x-rust-builder}}#[builder(default)]{{/vendorExtensions.x-rust-builder}} + pub _phantom: PhantomData<&'a ()>, } -impl{{{vendorExtensions.x-rust-generic-parameter}}} {{{classname}}}{{{vendorExtensions.x-rust-generic-parameter}}} { +impl<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}> {{{classname}}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}> { {{#description}} /// {{{.}}} {{/description}} @@ -167,10 +183,19 @@ impl{{{vendorExtensions.x-rust-generic-parameter}}} {{{classname}}}{{{vendorExte ### CHANGE 1: If x-rust-type is available for a required var, use it for the parameter type. }}{{#vendorExtensions.x-rust-type}}{{{.}}}{{/vendorExtensions.x-rust-type}}{{! ### Fallback to original logic if x-rust-type is not present. - }}{{^vendorExtensions.x-rust-type}}{{#isNullable}}Option<{{/isNullable}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{#isByteArray}}Vec{{/isByteArray}}{{^isByteArray}}{{{dataType}}}{{/isByteArray}}{{/isEnum}}{{#isNullable}}>{{/isNullable}}{{/vendorExtensions.x-rust-type}}{{! + }}{{^vendorExtensions.x-rust-type}}{{#isNullable}}Option<{{/isNullable}}{{! + }}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{! + }}{{^isEnum}}{{#isByteArray}}Vec{{/isByteArray}}{{! + }}{{^isByteArray}}{{#isString}}Cow<'a, str>{{/isString}}{{! + }}{{^isString}}{{#isArray}}Vec<{{#items}}{{! + }}{{#isModel}}{{{dataType}}}<'a>{{/isModel}}{{! + }}{{^isModel}}{{{dataType}}}{{/isModel}}{{/items}}>{{/isArray}}{{! + }}{{^isArray}}{{{dataType}}}{{#isModel}}<'a>{{/isModel}}{{! + }}{{/isArray}}{{/isString}}{{/isByteArray}}{{/isEnum}}{{! + }}{{#isNullable}}>{{/isNullable}}{{/vendorExtensions.x-rust-type}}{{! ### Comma for next arguement - }}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}}{{{vendorExtensions.x-rust-generic-parameter}}}{ - {{{classname}}} { + }}{{^-last}}, {{/-last}}{{/requiredVars}}) -> Self { + Self { {{#vars}} {{#vendorExtensions.x-rust-type}} {{! Differentiate between required and optional fields with x-rust-type.}} @@ -185,6 +210,7 @@ impl{{{vendorExtensions.x-rust-generic-parameter}}} {{{classname}}}{{{vendorExte {{{name}}}{{^required}}: None{{/required}}{{#required}}{{#isModel}}{{^avoidBoxedModels}}: {{^isNullable}}Box::new({{{name}}}){{/isNullable}}{{#isNullable}}if let Some(x) = {{{name}}} {Some(Box::new(x))} else {None}{{/isNullable}}{{/avoidBoxedModels}}{{/isModel}}{{/required}}, {{/vendorExtensions.x-rust-type}} {{/vars}} + _phantom: PhantomData, } } } @@ -196,16 +222,16 @@ impl{{{vendorExtensions.x-rust-generic-parameter}}} {{{classname}}}{{{vendorExte {{/description}} #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum {{classname}} { +pub enum {{classname}}<'a> { {{#composedSchemas.oneOf}} {{#description}} /// {{{.}}} {{/description}} - {{{name}}}({{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{/isModel}}{{{dataType}}}{{#isModel}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}), + {{{name}}}({{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{/isModel}}{{#isArray}}Vec<{{{items.dataType}}}<'a>>{{/isArray}}{{^isArray}}{{{dataType}}}<'a>{{/isArray}}{{#isModel}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}), {{/composedSchemas.oneOf}} } -impl Default for {{classname}} { +impl Default for {{classname}}<'_> { fn default() -> Self { {{#composedSchemas.oneOf}}{{#-first}}Self::{{{name}}}(Default::default()){{/-first}}{{/composedSchemas.oneOf}} } diff --git a/openapi-generator-template/reqwest/api.mustache b/openapi-generator-template/reqwest/api.mustache index 9734291a..90dd3162 100644 --- a/openapi-generator-template/reqwest/api.mustache +++ b/openapi-generator-template/reqwest/api.mustache @@ -1,9 +1,11 @@ {{>partial_header}} +use super::{Error, configuration, ContentType}; +use crate::{apis::ResponseContent, models}; +use ::std::borrow::Cow; +use ::std::marker::PhantomData; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; -use crate::{apis::ResponseContent, models}; -use super::{Error, configuration, ContentType}; {{#operations}} {{#operation}} @@ -12,15 +14,15 @@ use super::{Error, configuration, ContentType}; {{#-first}} /// struct for passing parameters to the method [`{{operationId}}`] #[derive(Clone, Debug)] -pub struct {{{operationIdCamelCase}}}Params{{! +pub struct {{{operationIdCamelCase}}}Params<'p{{! Iterate through ALL parameters in the operation. Only the requestBody has this extension defined, so it will print "". The other parameters have nothing, so they will print nothing. This effectively extract the generic parameter from the requestBody and places it on the struct definition line. }}{{#allParams}} -{{{vendorExtensions.x-rust-params-generic-parameter}}} -{{/allParams}} { +{{#vendorExtensions.x-rust-params-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-params-generic-parameter}} +{{/allParams}}> { {{/-first}} {{#description}} /// {{{.}}} @@ -33,17 +35,18 @@ pub struct {{{operationIdCamelCase}}}Params{{! ### Option Start }}{{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{! ### &str and Vec<&str> - }}{{^isUuid}}{{#isString}}{{#isArray}}Vec<{{/isArray}}String{{#isArray}}>{{/isArray}}{{/isString}}{{/isUuid}}{{! + }}{{^isUuid}}{{#isString}}{{#isArray}}Vec<{{/isArray}}Cow<'p, str>{{#isArray}}>{{/isArray}}{{/isString}}{{/isUuid}}{{! ### UUIDs }}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}String{{#isArray}}>{{/isArray}}{{/isUuid}}{{! ### Models and primative types - }}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{! + }}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{#isModel}}<'p>{{/isModel}}{{/isUuid}}{{/isString}}{{! ### Option End }}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{! ### Comma for next arguement - }}{{^-last}},{{/-last}} + }}, {{/vendorExtensions.x-rust-type}} {{#-last}} + pub _phantom: PhantomData<&'p ()>, } {{/-last}} @@ -58,16 +61,20 @@ pub struct {{{operationIdCamelCase}}}Params{{! /// struct for typed successes of method [`{{operationId}}`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum {{{operationIdCamelCase}}}Success { +pub enum {{{operationIdCamelCase}}}Success<'a> { {{#responses}} {{#is2xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), + Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'a>{{/isEnum}}), {{/is2xx}} {{#is3xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), + Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'a>{{/isEnum}}), {{/is3xx}} {{/responses}} - UnknownValue(serde_json::Value), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } {{/operation}} @@ -78,19 +85,23 @@ pub enum {{{operationIdCamelCase}}}Success { /// struct for typed errors of method [`{{operationId}}`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum {{{operationIdCamelCase}}}Error { +pub enum {{{operationIdCamelCase}}}Error<'a> { {{#responses}} {{#is4xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), + Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'a>{{/isEnum}}), {{/is4xx}} {{#is5xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), + Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'a>{{/isEnum}}), {{/is5xx}} {{#isDefault}} - DefaultResponse({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), + DefaultResponse({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'a>{{/isEnum}}), {{/isDefault}} {{/responses}} - UnknownValue(serde_json::Value), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } {{/operation}} @@ -105,11 +116,17 @@ pub enum {{{operationIdCamelCase}}}Error { /// {{{.}}} {{/notes}} {{#vendorExtensions.x-group-parameters}} -pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}{{{vendorExtensions.x-rust-generic-parameter}}}(configuration: &configuration::Configuration{{#allParams}}{{#-first}}, {{! +pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}{{#vendorExtensions.x-rust-generic-parameter}}<{{{.}}}>{{/vendorExtensions.x-rust-generic-parameter}}(configuration: &configuration::Configuration{{#allParams}}{{#-first}}, {{! ### Params -}}params: &{{{operationIdCamelCase}}}Params{{#allParams}}{{{vendorExtensions.x-rust-params-generic-parameter}}}{{/allParams}}{{/-first}}{{/allParams}}{{! +}}params: &{{{operationIdCamelCase}}}Params<'_{{#allParams}}{{#vendorExtensions.x-rust-params-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-params-generic-parameter}}{{/allParams}}>{{/-first}}{{/allParams}}{{! ### Function return type -}}) -> Result<{{#vendorExtensions.x-rust-return-type}}{{{.}}}{{/vendorExtensions.x-rust-return-type}}{{^vendorExtensions.x-rust-return-type}}{{#isResponseFile}}{{#supportAsync}}reqwest::Response{{/supportAsync}}{{^supportAsync}}reqwest::blocking::Response{{/supportAsync}}{{/isResponseFile}}{{^isResponseFile}}{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{{returnType}}}{{/supportMultipleResponses}}{{/isResponseFile}}{{/vendorExtensions.x-rust-return-type}}, Error<{{{operationIdCamelCase}}}Error>> { +}}) -> Result<{{#vendorExtensions.x-rust-return-type}}{{{.}}}{{/vendorExtensions.x-rust-return-type}}{{^vendorExtensions.x-rust-return-type}}{{! +}}{{#isResponseFile}}{{#supportAsync}}reqwest::Response{{/supportAsync}}{{^supportAsync}}reqwest::blocking::Response{{/supportAsync}}{{/isResponseFile}}{{! +}}{{^isResponseFile}}{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{^supportMultipleResponses}}{{! +}}{{^returnType}}(){{/returnType}}{{! +}}{{#isArray}}Vec<{{#returnProperty.items}}{{{dataType}}}{{#isModel}}<'static>{{/isModel}}{{/returnProperty.items}}>{{/isArray}}{{! +}}{{^isArray}}{{#returnProperty}}{{{dataType}}}{{#isModel}}<'static>{{/isModel}}{{/returnProperty}}{{! +}}{{/isArray}}{{/supportMultipleResponses}}{{/isResponseFile}}{{/vendorExtensions.x-rust-return-type}}, Error<{{{operationIdCamelCase}}}Error<'static>>> { {{/vendorExtensions.x-group-parameters}} let uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode(&{{/isString}}{{{vendorExtensions.x-rust-param-identifier}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isArray}}.join(",").as_ref(){{/isArray}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}.to_string(){{/isContainer}}{{/isPrimitiveType}}{{/isUuid}}{{/isString}}{{#isString}}){{/isString}}{{/pathParams}}); let mut req_builder = configuration.client.request(reqwest::Method::{{{httpMethod}}}, &uri_str); @@ -416,7 +433,7 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}{{{vendorExtensi {{#vendorExtensions.x-rust-body-is-raw-text}} {{! If the flag is true, we generate only the raw text body logic }} {{#bodyParams}} - req_builder = req_builder.header(reqwest::header::CONTENT_TYPE, "text/plain").body({{{vendorExtensions.x-rust-param-identifier}}}.to_owned()); + req_builder = req_builder.header(reqwest::header::CONTENT_TYPE, "text/plain").body({{{vendorExtensions.x-rust-param-identifier}}}.clone().into_owned()); {{/bodyParams}} {{/vendorExtensions.x-rust-body-is-raw-text}} {{! Now, handle the case where the extension is NOT present. This is the "else" block }} diff --git a/preprocessed_openapi.yml b/preprocessed_openapi.yml index d0fc19d0..69290aeb 100644 --- a/preprocessed_openapi.yml +++ b/preprocessed_openapi.yml @@ -345,9 +345,9 @@ paths: description: Can be any key-value pair x-go-type: interface{} required: true - x-rust-params-generic-parameter: + x-rust-params-generic-parameter: B x-rust-type: B - x-rust-generic-parameter: '' + x-rust-generic-parameter: 'B: Serialize' delete: tags: - documents @@ -843,8 +843,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiResponse' - x-rust-generic-parameter: ' serde::Deserialize<''de> + Serialize>' - x-rust-return-type: models::SearchResult + x-rust-generic-parameter: 'D: for<''de> serde::Deserialize<''de> + Serialize' + x-rust-return-type: models::SearchResult<'static, D> /synonym_sets: get: tags: @@ -1500,7 +1500,7 @@ paths: description: Can be any key-value pair x-go-type: interface{} required: true - x-rust-params-generic-parameter: + x-rust-params-generic-parameter: B x-rust-type: B responses: '200': @@ -1516,7 +1516,7 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiResponse' - x-rust-generic-parameter: '' + x-rust-generic-parameter: 'B: Serialize' delete: tags: - documents @@ -1914,7 +1914,7 @@ paths: type: array items: $ref: '#/components/schemas/SchemaChangeStatus' - x-rust-return-type: Option> + x-rust-return-type: Option>> /operations/snapshot: post: tags: @@ -3409,13 +3409,13 @@ components: type: array items: $ref: '#/components/schemas/SearchGroupedHit' - x-rust-type: Option>> + x-rust-type: Option>> hits: type: array description: The documents that matched the search query items: $ref: '#/components/schemas/SearchResultHit' - x-rust-type: Option>> + x-rust-type: Option>> request_params: $ref: '#/components/schemas/SearchRequestParams' conversation: @@ -3429,7 +3429,7 @@ components: type: object description: Custom JSON object that can be returned in the search response additionalProperties: true - x-rust-generic-parameter: + x-rust-generic-parameter: D SearchRequestParams: type: object required: @@ -3482,8 +3482,8 @@ components: description: The documents that matched the search query items: $ref: '#/components/schemas/SearchResultHit' - x-rust-type: Vec> - x-rust-generic-parameter: + x-rust-type: Vec> + x-rust-generic-parameter: D SearchResultHit: type: object properties: @@ -3555,7 +3555,7 @@ components: num_employees: 5215 country: USA text_match: 1234556 - x-rust-generic-parameter: + x-rust-generic-parameter: D SearchHighlight: type: object properties: @@ -3741,10 +3741,10 @@ components: type: array items: $ref: '#/components/schemas/MultiSearchResultItem' - x-rust-type: Vec> + x-rust-type: Vec> conversation: $ref: '#/components/schemas/SearchResultConversation' - x-rust-generic-parameter: + x-rust-generic-parameter: D MultiSearchResultItem: allOf: - $ref: '#/components/schemas/SearchResult' @@ -3757,7 +3757,7 @@ components: error: type: string description: Error description - x-rust-generic-parameter: + x-rust-generic-parameter: D SearchParameters: type: object properties: diff --git a/typesense/src/client/alias.rs b/typesense/src/client/alias.rs index 65c9a680..1b41112b 100644 --- a/typesense/src/client/alias.rs +++ b/typesense/src/client/alias.rs @@ -23,9 +23,11 @@ impl<'a> Alias<'a> { /// Retrieves the details of a collection alias, including the collection it points to. pub async fn retrieve( &self, - ) -> Result> { + ) -> Result, Error>> + { let params = collections_api::GetAliasParams { - alias_name: self.alias_name.to_owned(), + alias_name: self.alias_name.into(), + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::get_alias, params) @@ -34,9 +36,11 @@ impl<'a> Alias<'a> { /// Deletes a collection alias. pub async fn delete( &self, - ) -> Result> { + ) -> Result, Error>> + { let params = collections_api::DeleteAliasParams { - alias_name: self.alias_name.to_owned(), + alias_name: self.alias_name.into(), + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::delete_alias, params) } diff --git a/typesense/src/client/aliases.rs b/typesense/src/client/aliases.rs index 43d32701..35afcc96 100644 --- a/typesense/src/client/aliases.rs +++ b/typesense/src/client/aliases.rs @@ -3,6 +3,7 @@ //! An `Aliases` instance is created via the main `client.aliases()` method. use crate::{Client, Error, execute_wrapper}; +use ::std::borrow::Cow; use typesense_codegen::{apis::collections_api, models}; /// Provides methods for interacting with Typesense collection aliases. @@ -30,12 +31,14 @@ impl<'a> Aliases<'a> { /// * `schema` - A `CollectionAliasSchema` pointing to the target collection. pub async fn upsert( &self, - alias_name: impl Into, - schema: models::CollectionAliasSchema, - ) -> Result> { + alias_name: impl Into>, + schema: models::CollectionAliasSchema<'_>, + ) -> Result, Error>> + { let params = collections_api::UpsertAliasParams { alias_name: alias_name.into(), collection_alias_schema: Some(schema), + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::upsert_alias, params) } @@ -43,7 +46,10 @@ impl<'a> Aliases<'a> { /// Lists all aliases and the corresponding collections that they map to. pub async fn retrieve( &self, - ) -> Result> { + ) -> Result< + models::CollectionAliasesResponse<'static>, + Error>, + > { execute_wrapper!(self, collections_api::get_aliases) } } diff --git a/typesense/src/client/collection/document.rs b/typesense/src/client/collection/document.rs index 9a159ec0..0956e418 100644 --- a/typesense/src/client/collection/document.rs +++ b/typesense/src/client/collection/document.rs @@ -21,7 +21,7 @@ where client: &'c Client, collection_name: &'n str, document_id: String, - _phantom: std::marker::PhantomData, + _phantom: core::marker::PhantomData, } impl<'c, 'n, D> Document<'c, 'n, D> @@ -35,7 +35,7 @@ where client, collection_name, document_id, - _phantom: std::marker::PhantomData, + _phantom: core::marker::PhantomData, } } @@ -43,10 +43,11 @@ where /// /// # Returns /// A `Result` containing the strongly-typed document `D` if successful. - pub async fn retrieve(&self) -> Result> { + pub async fn retrieve(&self) -> Result>> { let params = documents_api::GetDocumentParams { - collection_name: self.collection_name.to_owned(), - document_id: self.document_id.to_owned(), + collection_name: self.collection_name.into(), + document_id: self.document_id.as_str().into(), + _phantom: core::marker::PhantomData, }; let result_value = execute_wrapper!(self, documents_api::get_document, params)?; @@ -60,10 +61,11 @@ where /// /// # Returns /// A `Result` containing the deleted document deserialized into `D`. - pub async fn delete(&self) -> Result> { + pub async fn delete(&self) -> Result>> { let params = documents_api::DeleteDocumentParams { - collection_name: self.collection_name.to_owned(), - document_id: self.document_id.to_owned(), + collection_name: self.collection_name.into(), + document_id: self.document_id.as_str().into(), + _phantom: core::marker::PhantomData, }; let result_value = execute_wrapper!(self, documents_api::delete_document, params)?; @@ -123,12 +125,13 @@ where &self, partial_document: &D::Partial, params: Option, - ) -> Result> { + ) -> Result>> { let params = documents_api::UpdateDocumentParams { - collection_name: self.collection_name.to_owned(), - document_id: self.document_id.to_owned(), + collection_name: self.collection_name.into(), + document_id: self.document_id.as_str().into(), body: partial_document, dirty_values: params.and_then(|d| d.dirty_values), + _phantom: core::marker::PhantomData, }; let result_value = execute_wrapper!(self, documents_api::update_document, params)?; diff --git a/typesense/src/client/collection/documents.rs b/typesense/src/client/collection/documents.rs index b394475b..d3d8621b 100644 --- a/typesense/src/client/collection/documents.rs +++ b/typesense/src/client/collection/documents.rs @@ -28,7 +28,7 @@ where { client: &'c Client, collection_name: &'n str, - _phantom: std::marker::PhantomData, + _phantom: core::marker::PhantomData, } impl<'c, 'n, D> Documents<'c, 'n, D> @@ -41,7 +41,7 @@ where Self { client, collection_name, - _phantom: std::marker::PhantomData, + _phantom: core::marker::PhantomData, } } @@ -54,12 +54,13 @@ where document: serde_json::Value, action: &str, params: Option, - ) -> Result> { + ) -> Result>> { let params = documents_api::IndexDocumentParams { - collection_name: self.collection_name.to_owned(), + collection_name: self.collection_name.into(), body: document, - action: Some(action.to_owned()), + action: Some(action.into()), dirty_values: params.and_then(|d| d.dirty_values), // Or expose this as an argument if needed + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, documents_api::index_document, params) } @@ -76,11 +77,11 @@ where pub async fn import_jsonl( &self, documents_jsonl: String, - params: ImportDocumentsParameters, - ) -> Result> { + params: ImportDocumentsParameters<'_>, + ) -> Result>> { let params = documents_api::ImportDocumentsParams { - body: documents_jsonl, - collection_name: self.collection_name.to_owned(), + body: documents_jsonl.into(), + collection_name: self.collection_name.into(), action: params.action, batch_size: params.batch_size, @@ -88,6 +89,7 @@ where remote_embedding_batch_size: params.remote_embedding_batch_size, return_doc: params.return_doc, return_id: params.return_id, + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, documents_api::import_documents, params) } @@ -98,13 +100,14 @@ where /// * `params` - An `ExportDocumentsParameters` struct containing options like `filter_by` and `include_fields`. pub async fn export_jsonl( &self, - params: ExportDocumentsParameters, - ) -> Result> { + params: ExportDocumentsParameters<'_>, + ) -> Result>> { let params = documents_api::ExportDocumentsParams { - collection_name: self.collection_name.to_owned(), + collection_name: self.collection_name.into(), exclude_fields: params.exclude_fields, filter_by: params.filter_by, include_fields: params.include_fields, + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, documents_api::export_documents, params) } @@ -115,15 +118,18 @@ where /// * `params` - A `DeleteDocumentsParameters` describing the conditions for deleting documents. pub async fn delete( &self, - params: DeleteDocumentsParameters, - ) -> Result> - { + params: DeleteDocumentsParameters<'_>, + ) -> Result< + raw_models::DeleteDocuments200Response<'_>, + Error>, + > { let params = documents_api::DeleteDocumentsParams { - collection_name: self.collection_name.to_owned(), + collection_name: self.collection_name.into(), filter_by: Some(params.filter_by), batch_size: params.batch_size, ignore_not_found: params.ignore_not_found, truncate: params.truncate, + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, documents_api::delete_documents, params) } @@ -135,10 +141,11 @@ where /// * `params` - A `SearchParameters` struct containing all search parameters. pub async fn search( &self, - params: raw_models::SearchParameters, - ) -> Result, Error> { + params: raw_models::SearchParameters<'_>, + ) -> Result, Error>> + { let search_params = documents_api::SearchCollectionParams { - collection_name: self.collection_name.to_owned(), + collection_name: self.collection_name.into(), // Map all corresponding fields directly. cache_ttl: params.cache_ttl, @@ -212,6 +219,7 @@ where nl_query: params.nl_query, enable_analytics: params.enable_analytics, synonym_sets: params.synonym_sets, + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, documents_api::search_collection, search_params) } @@ -234,7 +242,7 @@ where &self, document: &D, params: Option, - ) -> Result> { + ) -> Result>> { let doc_value = serde_json::to_value(document)?; let result_value = self.index(doc_value, "create", params).await?; serde_json::from_value(result_value).map_err(Error::from) @@ -252,7 +260,7 @@ where &self, document: &D, params: Option, - ) -> Result> { + ) -> Result>> { let doc_value = serde_json::to_value(document)?; let result_value = self.index(doc_value, "upsert", params).await?; serde_json::from_value(result_value).map_err(Error::from) @@ -266,13 +274,16 @@ where pub async fn update( &self, document: &D::Partial, - params: UpdateDocumentsParameters, - ) -> Result> - { + params: UpdateDocumentsParameters<'_>, + ) -> Result< + raw_models::UpdateDocuments200Response<'static>, + Error>, + > { let params = documents_api::UpdateDocumentsParams { - collection_name: self.collection_name.to_owned(), + collection_name: self.collection_name.into(), filter_by: params.filter_by, body: document, + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, documents_api::update_documents, params) } diff --git a/typesense/src/client/collection/mod.rs b/typesense/src/client/collection/mod.rs index ba069502..75069961 100644 --- a/typesense/src/client/collection/mod.rs +++ b/typesense/src/client/collection/mod.rs @@ -18,7 +18,7 @@ where { client: &'c Client, collection_name: &'n str, - _phantom: std::marker::PhantomData, + _phantom: core::marker::PhantomData, } impl<'c, 'n, D> Collection<'c, 'n, D> @@ -31,7 +31,7 @@ where Self { client, collection_name, - _phantom: std::marker::PhantomData, + _phantom: core::marker::PhantomData, } } @@ -51,9 +51,13 @@ where #[inline] pub async fn retrieve( &self, - ) -> Result> { + ) -> Result< + models::CollectionResponse<'static>, + Error>, + > { let params = collections_api::GetCollectionParams { - collection_name: self.collection_name.to_owned(), + collection_name: self.collection_name.into(), + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::get_collection, params) } @@ -62,9 +66,13 @@ where #[inline] pub async fn delete( &self, - ) -> Result> { + ) -> Result< + models::CollectionResponse<'static>, + Error>, + > { let params = collections_api::DeleteCollectionParams { - collection_name: self.collection_name.to_owned(), + collection_name: self.collection_name.into(), + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::delete_collection, params) } @@ -76,11 +84,15 @@ where #[inline] pub async fn update( &self, - update_schema: models::CollectionUpdateSchema, - ) -> Result> { + update_schema: models::CollectionUpdateSchema<'_>, + ) -> Result< + models::CollectionUpdateSchema<'static>, + Error>, + > { let params = collections_api::UpdateCollectionParams { - collection_name: self.collection_name.to_owned(), + collection_name: self.collection_name.into(), collection_update_schema: update_schema, + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::update_collection, params) } diff --git a/typesense/src/client/collections.rs b/typesense/src/client/collections.rs index 060bf948..e9a07679 100644 --- a/typesense/src/client/collections.rs +++ b/typesense/src/client/collections.rs @@ -28,10 +28,14 @@ impl<'c> Collections<'c> { /// * `schema` - A `CollectionSchema` object describing the collection to be created. pub async fn create( &self, - schema: models::CollectionSchema, - ) -> Result> { + schema: models::CollectionSchema<'_>, + ) -> Result< + models::CollectionResponse<'static>, + Error>, + > { let params = collections_api::CreateCollectionParams { collection_schema: schema, + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::create_collection, params) } @@ -39,12 +43,16 @@ impl<'c> Collections<'c> { /// List the existing Typesense collections. pub async fn retrieve( &self, - params: GetCollectionsParameters, - ) -> Result, Error> { + params: GetCollectionsParameters<'_>, + ) -> Result< + Vec>, + Error>, + > { let params = GetCollectionsParams { exclude_fields: params.exclude_fields, limit: params.limit, offset: params.offset, + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::get_collections, params) } diff --git a/typesense/src/client/conversations/model.rs b/typesense/src/client/conversations/model.rs index e57faf2a..d8b1f2ab 100644 --- a/typesense/src/client/conversations/model.rs +++ b/typesense/src/client/conversations/model.rs @@ -24,11 +24,12 @@ impl<'a> Model<'a> { pub async fn retrieve( &self, ) -> Result< - models::ConversationModelSchema, - Error, + models::ConversationModelSchema<'static>, + Error>, > { let params = conversations_api::RetrieveConversationModelParams { - model_id: self.model_id.to_owned(), + model_id: self.model_id.into(), + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, conversations_api::retrieve_conversation_model, params) } @@ -39,14 +40,15 @@ impl<'a> Model<'a> { /// * `schema` - A `ConversationModelUpdateSchema` object with the fields to update. pub async fn update( &self, - schema: models::ConversationModelUpdateSchema, + schema: models::ConversationModelUpdateSchema<'_>, ) -> Result< - models::ConversationModelSchema, - Error, + models::ConversationModelSchema<'static>, + Error>, > { let params = conversations_api::UpdateConversationModelParams { - model_id: self.model_id.to_owned(), + model_id: self.model_id.into(), conversation_model_update_schema: schema, + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, conversations_api::update_conversation_model, params) } @@ -55,11 +57,12 @@ impl<'a> Model<'a> { pub async fn delete( &self, ) -> Result< - models::ConversationModelSchema, - Error, + models::ConversationModelSchema<'static>, + Error>, > { let params = conversations_api::DeleteConversationModelParams { - model_id: self.model_id.to_owned(), + model_id: self.model_id.into(), + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, conversations_api::delete_conversation_model, params) } diff --git a/typesense/src/client/conversations/models.rs b/typesense/src/client/conversations/models.rs index be6960e8..01f5511a 100644 --- a/typesense/src/client/conversations/models.rs +++ b/typesense/src/client/conversations/models.rs @@ -25,13 +25,14 @@ impl<'a> Models<'a> { /// * `schema` - A `ConversationModelCreateSchema` object describing the model. pub async fn create( &self, - schema: models::ConversationModelCreateSchema, + schema: models::ConversationModelCreateSchema<'_>, ) -> Result< - models::ConversationModelSchema, - Error, + models::ConversationModelSchema<'static>, + Error>, > { let params = conversations_api::CreateConversationModelParams { conversation_model_create_schema: schema, + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, conversations_api::create_conversation_model, params) } @@ -40,8 +41,8 @@ impl<'a> Models<'a> { pub async fn retrieve( &self, ) -> Result< - Vec, - Error, + Vec>, + Error>, > { execute_wrapper!(self, conversations_api::retrieve_all_conversation_models) } diff --git a/typesense/src/client/key.rs b/typesense/src/client/key.rs index 03e95360..1284c02a 100644 --- a/typesense/src/client/key.rs +++ b/typesense/src/client/key.rs @@ -25,9 +25,12 @@ impl<'c> Key<'c> { /// For security reasons, this endpoint only returns the key prefix and metadata, /// not the full key value. #[inline] - pub async fn retrieve(&self) -> Result> { + pub async fn retrieve( + &self, + ) -> Result, Error>> { let params = keys_api::GetKeyParams { key_id: self.key_id, + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, keys_api::get_key, params) } @@ -36,9 +39,11 @@ impl<'c> Key<'c> { #[inline] pub async fn delete( &self, - ) -> Result> { + ) -> Result, Error>> + { let params = keys_api::DeleteKeyParams { key_id: self.key_id, + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, keys_api::delete_key, params) } diff --git a/typesense/src/client/keys.rs b/typesense/src/client/keys.rs index a7979f0e..ceadb7ea 100644 --- a/typesense/src/client/keys.rs +++ b/typesense/src/client/keys.rs @@ -35,17 +35,20 @@ impl<'c> Keys<'c> { #[inline] pub async fn create( &self, - schema: models::ApiKeySchema, - ) -> Result> { + schema: models::ApiKeySchema<'_>, + ) -> Result, Error>> { let params = keys_api::CreateKeyParams { api_key_schema: Some(schema), + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, keys_api::create_key, params) } /// Lists all API keys and their metadata. #[inline] - pub async fn retrieve(&self) -> Result> { + pub async fn retrieve( + &self, + ) -> Result, Error>> { execute_wrapper!(self, keys_api::get_keys) } diff --git a/typesense/src/client/mod.rs b/typesense/src/client/mod.rs index 5b158717..7afd10ea 100644 --- a/typesense/src/client/mod.rs +++ b/typesense/src/client/mod.rs @@ -38,8 +38,8 @@ //! //! // Search for a document //! let search_params = models::SearchParameters { -//! q: Some("phone".to_owned()), -//! query_by: Some("name".to_owned()), +//! q: Some("phone".into()), +//! query_by: Some("name".into()), //! ..Default::default() //! }; //! @@ -608,7 +608,7 @@ impl Client { /// # .build() /// # .unwrap(); /// # let schema = models::ApiKeySchema { - /// # description: "Search-only key.".to_owned(), + /// # description: "Search-only key.".into(), /// # actions: vec!["documents:search".to_owned()], /// # collections: vec!["*".to_owned()], /// # ..Default::default() @@ -668,9 +668,9 @@ impl Client { /// # .unwrap(); /// # let search_requests = models::MultiSearchBody { /// # searches: vec![models::MultiSearchCollectionParameters { - /// # collection: Some("products".to_owned()), - /// # q: Some("phone".to_owned()), - /// # query_by: Some("name".to_owned()), + /// # collection: Some("products".into()), + /// # q: Some("phone".into()), + /// # query_by: Some("name".into()), /// # ..Default::default() /// # }], /// # ..Default::default() diff --git a/typesense/src/client/multi_search.rs b/typesense/src/client/multi_search.rs index 3188a019..e5f6c92e 100644 --- a/typesense/src/client/multi_search.rs +++ b/typesense/src/client/multi_search.rs @@ -69,16 +69,16 @@ impl<'c> MultiSearch<'c> { /// searches: vec![ /// // Search #0 targets the 'products' collection /// models::MultiSearchCollectionParameters { - /// collection: Some("products".to_owned()), - /// q: Some("shoe".to_owned()), - /// query_by: Some("name".to_owned()), + /// collection: Some("products".into()), + /// q: Some("shoe".into()), + /// query_by: Some("name".into()), /// ..Default::default() /// }, /// // Search #1 targets the 'brands' collection /// models::MultiSearchCollectionParameters { - /// collection: Some("brands".to_owned()), - /// q: Some("nike".to_owned()), - /// query_by: Some("company_name".to_owned()), + /// collection: Some("brands".into()), + /// q: Some("nike".into()), + /// query_by: Some("company_name".into()), /// ..Default::default() /// }, /// ], @@ -112,11 +112,11 @@ impl<'c> MultiSearch<'c> { /// * `common_search_params` - A `MultiSearchParameters` struct describing search parameters that are common to all searches. pub async fn perform( &self, - search_requests: MultiSearchBody, - common_search_params: raw_models::MultiSearchParameters, + search_requests: MultiSearchBody<'_>, + common_search_params: raw_models::MultiSearchParameters<'_>, ) -> Result< - raw_models::MultiSearchResult, - Error, + raw_models::MultiSearchResult<'static, serde_json::Value>, + Error>, > { let request_body = raw_models::MultiSearchSearchesParameter { searches: search_requests.searches, @@ -164,16 +164,16 @@ impl<'c> MultiSearch<'c> { /// searches: vec![ /// // Search #0 targets the 'products' collection /// models::MultiSearchCollectionParameters { - /// collection: Some("products".to_owned()), - /// q: Some("shoe".to_owned()), - /// query_by: Some("name".to_owned()), + /// collection: Some("products".into()), + /// q: Some("shoe".into()), + /// query_by: Some("name".into()), /// ..Default::default() /// }, /// // Search #1 targets the 'brands' collection /// models::MultiSearchCollectionParameters { - /// collection: Some("brands".to_owned()), - /// q: Some("nike".to_owned()), - /// query_by: Some("company_name".to_owned()), + /// collection: Some("brands".into()), + /// q: Some("nike".into()), + /// query_by: Some("company_name".into()), /// ..Default::default() /// }, /// ], @@ -216,15 +216,15 @@ impl<'c> MultiSearch<'c> { /// let search_requests = models::MultiSearchBody { /// searches: vec![ /// models::MultiSearchCollectionParameters { - /// collection: Some("products".to_owned()), - /// q: Some("shoe".to_owned()), - /// query_by: Some("name".to_owned()), + /// collection: Some("products".into()), + /// q: Some("shoe".into()), + /// query_by: Some("name".into()), /// ..Default::default() /// }, /// models::MultiSearchCollectionParameters { - /// collection: Some("products".to_owned()), - /// q: Some("sock".to_owned()), - /// query_by: Some("name".to_owned()), + /// collection: Some("products".into()), + /// q: Some("sock".into()), + /// query_by: Some("name".into()), /// ..Default::default() /// }, /// ], @@ -251,13 +251,14 @@ impl<'c> MultiSearch<'c> { /// A `Result` containing a `SearchResult` on success, or an `Error` on failure. pub async fn perform_union serde::Deserialize<'de>>( &self, - search_requests: MultiSearchBody, - common_search_params: raw_models::MultiSearchParameters, - ) -> Result, Error> { + search_requests: MultiSearchBody<'_>, + common_search_params: raw_models::MultiSearchParameters<'_>, + ) -> Result, Error>> { // Explicitly set `union: true` for the request body let request_body = raw_models::MultiSearchSearchesParameter { union: Some(true), searches: search_requests.searches, + _phantom: core::marker::PhantomData, }; let multi_search_params = build_multi_search_params(request_body, common_search_params); @@ -273,10 +274,10 @@ impl<'c> MultiSearch<'c> { } // Private helper function to construct the final search parameters object. // This encapsulates the repetitive mapping logic. -fn build_multi_search_params( - request_body: raw_models::MultiSearchSearchesParameter, - params: raw_models::MultiSearchParameters, -) -> MultiSearchParams { +fn build_multi_search_params<'a>( + request_body: raw_models::MultiSearchSearchesParameter<'a>, + params: raw_models::MultiSearchParameters<'a>, +) -> MultiSearchParams<'a> { MultiSearchParams { multi_search_searches_parameter: Some(request_body), // Common URL search params @@ -344,6 +345,7 @@ fn build_multi_search_params( vector_query: params.vector_query, voice_query: params.voice_query, enable_analytics: params.enable_analytics, + _phantom: core::marker::PhantomData, // enable_highlight_v1: None, // max_candidates: None, // max_filter_by_candidates: None, diff --git a/typesense/src/client/operations.rs b/typesense/src/client/operations.rs index d1c60608..2f9f85f3 100644 --- a/typesense/src/client/operations.rs +++ b/typesense/src/client/operations.rs @@ -28,7 +28,9 @@ impl<'a> Operations<'a> { /// to the specific node that responded successfully. /// /// Docs: - pub async fn debug(&self) -> Result> { + pub async fn debug( + &self, + ) -> Result, Error>> { execute_wrapper!(self, debug_api::debug) } @@ -36,7 +38,9 @@ impl<'a> Operations<'a> { /// When a node is running out of memory / disk, the API response will have an additional resource_error field that's set to either `OUT_OF_DISK`` or `OUT_OF_MEMORY``. /// /// Docs: - pub async fn health(&self) -> Result> { + pub async fn health( + &self, + ) -> Result, Error>> { execute_wrapper!(self, health_api::health) } @@ -70,7 +74,7 @@ impl<'a> Operations<'a> { /// Docs: pub async fn retrieve_metrics( &self, - ) -> Result> { + ) -> Result>> { execute_wrapper!(self, operations_api::retrieve_metrics) } @@ -95,7 +99,10 @@ impl<'a> Operations<'a> { /// Docs: pub async fn retrieve_api_stats( &self, - ) -> Result> { + ) -> Result< + models::ApiStatsResponse<'static>, + Error>, + > { execute_wrapper!(self, operations_api::retrieve_api_stats) } @@ -105,8 +112,9 @@ impl<'a> Operations<'a> { /// Docs: pub async fn take_snapshot( &self, - params: operations_api::TakeSnapshotParams, - ) -> Result> { + params: operations_api::TakeSnapshotParams<'_>, + ) -> Result, Error>> + { execute_wrapper!(self, operations_api::take_snapshot, params) } @@ -114,7 +122,9 @@ impl<'a> Operations<'a> { /// The follower node that you run this operation against will become the new leader, once this command succeeds. /// /// Docs: - pub async fn vote(&self) -> Result> { + pub async fn vote( + &self, + ) -> Result, Error>> { execute_wrapper!(self, operations_api::vote) } @@ -123,8 +133,10 @@ impl<'a> Operations<'a> { /// Docs: pub async fn get_schema_changes( &self, - ) -> Result>, Error> - { + ) -> Result< + Option>>, + Error>, + > { execute_wrapper!(self, operations_api::get_schema_changes) } @@ -134,7 +146,8 @@ impl<'a> Operations<'a> { /// Docs: pub async fn compact_db( &self, - ) -> Result> { + ) -> Result, Error>> + { execute_wrapper!(self, operations_api::compact_db) } @@ -143,7 +156,8 @@ impl<'a> Operations<'a> { /// Docs: pub async fn clear_cache( &self, - ) -> Result> { + ) -> Result, Error>> + { execute_wrapper!(self, operations_api::clear_cache) } @@ -154,11 +168,16 @@ impl<'a> Operations<'a> { pub async fn toggle_slow_request_log( &self, slow_requests_threshold_ms: i32, - ) -> Result> { + ) -> Result< + models::SuccessStatus<'static>, + Error>, + > { let params = operations_api::ToggleSlowRequestLogParams { toggle_slow_request_log_request: Some(models::ToggleSlowRequestLogRequest { log_slow_requests_time_ms: slow_requests_threshold_ms, + _phantom: core::marker::PhantomData, }), + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, operations_api::toggle_slow_request_log, params) } diff --git a/typesense/src/client/preset.rs b/typesense/src/client/preset.rs index fa6d3cbe..832c4fd7 100644 --- a/typesense/src/client/preset.rs +++ b/typesense/src/client/preset.rs @@ -23,9 +23,11 @@ impl<'a> Preset<'a> { /// Retrieves the details of a preset, given its Id. pub async fn retrieve( &self, - ) -> Result> { + ) -> Result, Error>> + { let params = presets_api::RetrievePresetParams { - preset_id: self.preset_id.to_owned(), + preset_id: self.preset_id.into(), + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, presets_api::retrieve_preset, params) } @@ -33,9 +35,11 @@ impl<'a> Preset<'a> { /// Permanently deletes a preset, given its Id. pub async fn delete( &self, - ) -> Result> { + ) -> Result, Error>> + { let params = presets_api::DeletePresetParams { - preset_id: self.preset_id.to_owned(), + preset_id: self.preset_id.into(), + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, presets_api::delete_preset, params) } diff --git a/typesense/src/client/presets.rs b/typesense/src/client/presets.rs index 0cce7b02..d14eb1fe 100644 --- a/typesense/src/client/presets.rs +++ b/typesense/src/client/presets.rs @@ -5,6 +5,7 @@ //! A `Presets` instance is created via the main `client.presets()` method. use crate::{Client, Error, execute_wrapper}; +use ::std::borrow::Cow; use typesense_codegen::{apis::presets_api, models}; /// Provides methods for managing all of your Typesense presets. @@ -24,7 +25,10 @@ impl<'a> Presets<'a> { /// Retrieves the details of all presets. pub async fn retrieve( &self, - ) -> Result> { + ) -> Result< + models::PresetsRetrieveSchema<'static>, + Error>, + > { execute_wrapper!(self, presets_api::retrieve_all_presets) } @@ -35,12 +39,13 @@ impl<'a> Presets<'a> { /// * `schema` - A `PresetUpsertSchema` object with the preset's value. pub async fn upsert( &self, - preset_id: impl Into, - schema: models::PresetUpsertSchema, - ) -> Result> { + preset_id: impl Into>, + schema: models::PresetUpsertSchema<'_>, + ) -> Result, Error>> { let params = presets_api::UpsertPresetParams { preset_id: preset_id.into(), preset_upsert_schema: schema, + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, presets_api::upsert_preset, params) } diff --git a/typesense/src/client/stemming/dictionaries.rs b/typesense/src/client/stemming/dictionaries.rs index 72854d19..a81bfe7d 100644 --- a/typesense/src/client/stemming/dictionaries.rs +++ b/typesense/src/client/stemming/dictionaries.rs @@ -6,6 +6,7 @@ use crate::{ client::{Client, Error}, execute_wrapper, }; +use ::std::borrow::Cow; use typesense_codegen::{apis::stemming_api, models}; /// Provides methods for interacting with the collection of stemming dictionaries. @@ -31,12 +32,13 @@ impl<'a> Dictionaries<'a> { /// * `dictionary_jsonl` - A string containing the word mappings in JSONL format. pub async fn import( &self, - dictionary_id: impl Into, - dictionary_jsonl: String, - ) -> Result> { + dictionary_id: impl Into>, + dictionary_jsonl: impl Into>, + ) -> Result>> { let params = stemming_api::ImportStemmingDictionaryParams { id: dictionary_id.into(), - body: dictionary_jsonl, + body: dictionary_jsonl.into(), + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, stemming_api::import_stemming_dictionary, params) } @@ -45,8 +47,8 @@ impl<'a> Dictionaries<'a> { pub async fn retrieve( &self, ) -> Result< - models::ListStemmingDictionaries200Response, - Error, + models::ListStemmingDictionaries200Response<'static>, + Error>, > { execute_wrapper!(self, stemming_api::list_stemming_dictionaries) } diff --git a/typesense/src/client/stemming/dictionary.rs b/typesense/src/client/stemming/dictionary.rs index bbd82126..c580f1ba 100644 --- a/typesense/src/client/stemming/dictionary.rs +++ b/typesense/src/client/stemming/dictionary.rs @@ -29,9 +29,13 @@ impl<'a> Dictionary<'a> { /// Retrieves the details of this specific stemming dictionary. pub async fn retrieve( &self, - ) -> Result> { + ) -> Result< + models::StemmingDictionary<'static>, + Error>, + > { let params = stemming_api::GetStemmingDictionaryParams { - dictionary_id: self.dictionary_id.to_owned(), + dictionary_id: self.dictionary_id.into(), + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, stemming_api::get_stemming_dictionary, params) } diff --git a/typesense/src/client/stopword.rs b/typesense/src/client/stopword.rs index f1fce682..64f44955 100644 --- a/typesense/src/client/stopword.rs +++ b/typesense/src/client/stopword.rs @@ -23,10 +23,13 @@ impl<'a> Stopword<'a> { /// Retrieves the details of this specific stopwords set. pub async fn retrieve( &self, - ) -> Result> - { + ) -> Result< + models::StopwordsSetRetrieveSchema<'static>, + Error>, + > { let params = stopwords_api::RetrieveStopwordsSetParams { - set_id: self.set_id.to_owned(), + set_id: self.set_id.into(), + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, stopwords_api::retrieve_stopwords_set, params) } @@ -34,10 +37,13 @@ impl<'a> Stopword<'a> { /// Permanently deletes this specific stopwords set. pub async fn delete( &self, - ) -> Result> - { + ) -> Result< + models::DeleteStopwordsSet200Response<'static>, + Error>, + > { let params = stopwords_api::DeleteStopwordsSetParams { - set_id: self.set_id.to_owned(), + set_id: self.set_id.into(), + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, stopwords_api::delete_stopwords_set, params) } diff --git a/typesense/src/client/stopwords.rs b/typesense/src/client/stopwords.rs index a19bf290..19550c5c 100644 --- a/typesense/src/client/stopwords.rs +++ b/typesense/src/client/stopwords.rs @@ -3,6 +3,7 @@ //! A `Stopwords` instance is created via the main `client.stopwords()` method. use crate::{Client, Error, execute_wrapper}; +use ::std::borrow::Cow; use typesense_codegen::{apis::stopwords_api, models}; /// Provides methods for managing Typesense stopwords sets. @@ -26,12 +27,16 @@ impl<'a> Stopwords<'a> { /// * `schema` - A `StopwordsSetUpsertSchema` object with the stopwords to upsert. pub async fn upsert( &self, - set_id: impl Into, - schema: models::StopwordsSetUpsertSchema, - ) -> Result> { + set_id: impl Into>, + schema: models::StopwordsSetUpsertSchema<'_>, + ) -> Result< + models::StopwordsSetSchema<'static>, + Error>, + > { let params = stopwords_api::UpsertStopwordsSetParams { set_id: set_id.into(), stopwords_set_upsert_schema: schema, + _phantom: core::marker::PhantomData, }; execute_wrapper!(self, stopwords_api::upsert_stopwords_set, params) } @@ -40,8 +45,8 @@ impl<'a> Stopwords<'a> { pub async fn retrieve( &self, ) -> Result< - models::StopwordsSetsRetrieveAllSchema, - Error, + models::StopwordsSetsRetrieveAllSchema<'static>, + Error>, > { execute_wrapper!(self, stopwords_api::retrieve_stopwords_sets) } diff --git a/typesense/src/models/mod.rs b/typesense/src/models/mod.rs index 689ca792..3902ecbb 100644 --- a/typesense/src/models/mod.rs +++ b/typesense/src/models/mod.rs @@ -5,7 +5,6 @@ mod scoped_key_parameters; pub use document_index_parameters::*; pub use scoped_key_parameters::*; -pub use typesense_codegen::apis::operations_api::TakeSnapshotParams; -pub use typesense_codegen::models::*; +pub use typesense_codegen::{apis::operations_api::TakeSnapshotParams, models::*}; pub use multi_search::MultiSearchBody; diff --git a/typesense/src/models/multi_search.rs b/typesense/src/models/multi_search.rs index 4efe08c0..439a3e1b 100644 --- a/typesense/src/models/multi_search.rs +++ b/typesense/src/models/multi_search.rs @@ -7,8 +7,8 @@ use typesense_codegen::models::MultiSearchCollectionParameters; /// sent to the Typesense multi-search endpoint. Each search query is defined in a /// `MultiSearchCollectionParameters` struct within the `searches` vector. #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)] -pub struct MultiSearchBody { +pub struct MultiSearchBody<'a> { /// A vector of individual search queries to be executed. The order of the search results returned by Typesense will match the order of these queries. #[serde(rename = "searches")] - pub searches: Vec, + pub searches: Vec>, } diff --git a/typesense/src/models/scoped_key_parameters.rs b/typesense/src/models/scoped_key_parameters.rs index 0d2e168f..8a8222d0 100644 --- a/typesense/src/models/scoped_key_parameters.rs +++ b/typesense/src/models/scoped_key_parameters.rs @@ -7,12 +7,12 @@ use serde::Serialize; /// search restrictions and an optional expiration time embedded within it. It allows /// you to delegate search permissions securely without exposing your main API key. #[derive(Debug, Clone, Default, Serialize)] -pub struct ScopedKeyParameters { +pub struct ScopedKeyParameters<'a> { /// The search parameters to embed in the key. These parameters will be /// enforced for all searches made with the generated key. /// For example, you can use `filter_by` to restrict searches to a subset of documents. #[serde(flatten, skip_serializing_if = "Option::is_none")] - pub search_params: Option, + pub search_params: Option>, /// The number of `multi_search` requests that can be performed using this key. #[serde(skip_serializing_if = "Option::is_none")] diff --git a/typesense/src/traits/document.rs b/typesense/src/traits/document.rs index 0c4a5453..dbc2803c 100644 --- a/typesense/src/traits/document.rs +++ b/typesense/src/traits/document.rs @@ -19,5 +19,5 @@ pub trait Document: DeserializeOwned + Serialize { type Partial: DocumentPartial; /// Collection schema associated with the document. - fn collection_schema() -> CollectionSchema; + fn collection_schema() -> CollectionSchema<'static>; } diff --git a/typesense/src/traits/multi_search_ext.rs b/typesense/src/traits/multi_search_ext.rs index dba598f3..c7c78ef8 100644 --- a/typesense/src/traits/multi_search_ext.rs +++ b/typesense/src/traits/multi_search_ext.rs @@ -5,7 +5,7 @@ use serde_json::Value; use crate::{MultiSearchParseError, models::SearchResult}; /// An extension trait for `MultiSearchResult` to provide typed parsing. -pub trait MultiSearchResultExt { +pub trait MultiSearchResultExt<'a> { /// Parses the result at a specific index from a multi-search response into a strongly-typed `SearchResult`. /// /// # Arguments @@ -14,9 +14,9 @@ pub trait MultiSearchResultExt { /// # Type Parameters /// * `D` - The concrete document type to deserialize the hits into. fn parse_at( - &self, + &'a self, index: usize, - ) -> Result, MultiSearchParseError>; + ) -> Result, MultiSearchParseError>; } /// Small helpers to convert documents stored as `serde_json::Value` into a concrete `D`. @@ -29,9 +29,9 @@ fn deserialize_opt_document( } } -fn convert_hit_ref( - raw_hit: &SearchResultHit, -) -> Result, serde_json::Error> { +fn convert_hit_ref<'a, D: DeserializeOwned>( + raw_hit: &SearchResultHit<'a, Value>, +) -> Result, serde_json::Error> { Ok(SearchResultHit { document: deserialize_opt_document(raw_hit.document.clone())?, highlights: raw_hit.highlights.clone(), @@ -42,12 +42,13 @@ fn convert_hit_ref( vector_distance: raw_hit.vector_distance, hybrid_search_info: raw_hit.hybrid_search_info.clone(), search_index: raw_hit.search_index, + _phantom: core::marker::PhantomData, }) } -fn convert_group_ref( - raw_group: &SearchGroupedHit, -) -> Result, serde_json::Error> { +fn convert_group_ref<'a, D: DeserializeOwned>( + raw_group: &'a SearchGroupedHit, +) -> Result, serde_json::Error> { let hits = raw_group .hits .iter() @@ -58,13 +59,14 @@ fn convert_group_ref( found: raw_group.found, group_key: raw_group.group_key.clone(), hits, + _phantom: core::marker::PhantomData, }) } /// Convert a single `MultiSearchResultItem` into a strongly-typed `SearchResult`. -fn multi_search_item_to_search_result( - item: &MultiSearchResultItem, -) -> Result, serde_json::Error> { +fn multi_search_item_to_search_result<'a, D: DeserializeOwned>( + item: &'a MultiSearchResultItem, +) -> Result, serde_json::Error> { let typed_hits = match &item.hits { Some(raw_hits) => Some( raw_hits @@ -99,15 +101,16 @@ fn multi_search_item_to_search_result( conversation: item.conversation.clone(), union_request_params: item.union_request_params.clone(), metadata: item.metadata.clone(), + _phantom: core::marker::PhantomData, }) } /// Extension to parse an item out of a `MultiSearchResult` into a typed `SearchResult`. -impl MultiSearchResultExt for MultiSearchResult { +impl<'a> MultiSearchResultExt<'a> for MultiSearchResult<'a, Value> { fn parse_at( - &self, + &'a self, index: usize, - ) -> Result, MultiSearchParseError> { + ) -> Result, MultiSearchParseError> { let raw_item = self .results .get(index) @@ -116,7 +119,7 @@ impl MultiSearchResultExt for MultiSearchResult { if let Some(error_msg) = &raw_item.error { return Err(MultiSearchParseError::ApiError { index, - message: error_msg.clone(), + message: error_msg.clone().into_owned(), }); } diff --git a/typesense/tests/client/aliases_test.rs b/typesense/tests/client/aliases_test.rs index 0f80024c..ad2ab600 100644 --- a/typesense/tests/client/aliases_test.rs +++ b/typesense/tests/client/aliases_test.rs @@ -9,7 +9,7 @@ async fn logic_test_aliases_and_alias_lifecycle() { // --- 1. Create a collection to alias to --- let collection_schema = CollectionSchema { - name: collection_name.clone().into(), + name: collection_name.as_str().into(), fields: vec![Field { name: "name".into(), r#type: "string".into(), @@ -26,7 +26,8 @@ async fn logic_test_aliases_and_alias_lifecycle() { // --- 2. Create (Upsert) an alias --- let alias_schema = CollectionAliasSchema { - collection_name: collection_name.clone(), + collection_name: collection_name.as_str().into(), + _phantom: core::marker::PhantomData, }; let upsert_result = client.aliases().upsert(&alias_name, alias_schema).await; diff --git a/typesense/tests/client/client_test.rs b/typesense/tests/client/client_test.rs index 05f38839..83658838 100644 --- a/typesense/tests/client/client_test.rs +++ b/typesense/tests/client/client_test.rs @@ -11,7 +11,7 @@ use wiremock::{ // Helper to create a mock Typesense server for a successful collection retrieval. async fn setup_mock_server_ok(server: &MockServer, collection_name: &str) { let response_body = CollectionResponse { - name: collection_name.to_owned(), + name: collection_name.into(), ..Default::default() }; diff --git a/typesense/tests/client/conversation_models_test.rs b/typesense/tests/client/conversation_models_test.rs index 3f4f8896..be5cd6fb 100644 --- a/typesense/tests/client/conversation_models_test.rs +++ b/typesense/tests/client/conversation_models_test.rs @@ -19,7 +19,7 @@ async fn test_create_model_with_invalid_key_fails_as_expected() { // --- 1. Setup: Create the prerequisite collection for history --- let schema = CollectionSchema { - name: collection_name.clone().into(), + name: collection_name.as_str().into(), fields: vec![ Field { name: "conversation_id".into(), @@ -59,10 +59,10 @@ async fn test_create_model_with_invalid_key_fails_as_expected() { // --- 2. Action: Attempt to create a model with a deliberately invalid API key --- let create_schema = ConversationModelCreateSchema { - id: Some(model_id.clone()), - model_name: "openai/gpt-4".to_owned(), - api_key: Some("THIS_IS_AN_INVALID_KEY".to_owned()), - history_collection: collection_name.clone(), + id: Some(model_id.into()), + model_name: "openai/gpt-4".into(), + api_key: Some("THIS_IS_AN_INVALID_KEY".into()), + history_collection: collection_name.into(), max_bytes: 10000, ..Default::default() }; @@ -134,11 +134,11 @@ async fn test_create_model_with_wiremock() { let collection_name = new_id("history-collection"); let create_schema = ConversationModelCreateSchema { - id: Some(model_id.clone()), - model_name: "openai/gpt-4".to_owned(), - api_key: Some("A-FAKE-BUT-VALID-LOOKING-KEY".to_owned()), - history_collection: collection_name.clone(), - system_prompt: Some("You are a helpful assistant.".to_owned()), + id: Some(model_id.as_str().into()), + model_name: "openai/gpt-4".into(), + api_key: Some("A-FAKE-BUT-VALID-LOOKING-KEY".into()), + history_collection: collection_name.as_str().into(), + system_prompt: Some("You are a helpful assistant.".into()), ..Default::default() }; @@ -180,7 +180,7 @@ async fn test_create_model_with_wiremock() { assert_eq!(created_model.history_collection, collection_name); assert_eq!( created_model.system_prompt, - Some("You are a helpful assistant.".to_owned()) + Some("You are a helpful assistant.".into()) ); } @@ -270,7 +270,7 @@ async fn test_update_single_model_with_wiremock() { let model_id = new_id("conv-model"); let update_schema = ConversationModelUpdateSchema { - system_prompt: Some("A new, updated prompt.".to_owned()), + system_prompt: Some("A new, updated prompt.".into()), ..Default::default() }; diff --git a/typesense/tests/client/derive_integration_test.rs b/typesense/tests/client/derive_integration_test.rs index bf7db058..fb07fef1 100644 --- a/typesense/tests/client/derive_integration_test.rs +++ b/typesense/tests/client/derive_integration_test.rs @@ -1,8 +1,9 @@ use serde::{Deserialize, Serialize}; -use typesense::Typesense; -use typesense::models::Field; -use typesense::models::SearchParameters; -use typesense::prelude::*; +use typesense::{ + Typesense, + models::{Field, SearchParameters}, + prelude::*, +}; use crate::{get_client, new_id}; @@ -122,7 +123,7 @@ async fn logic_test_derive_macro_with_generic_client_lifecycle() { // Create Collection using the schema from the derive macro let schema = MegaProduct::collection_schema(); let mut schema_for_creation = schema.clone(); - schema_for_creation.name = collection_name.clone().into(); // Use the unique name + schema_for_creation.name = collection_name.as_str().into(); // Use the unique name let create_res = client.collections().create(schema_for_creation).await; assert!( @@ -439,8 +440,8 @@ async fn logic_test_derive_macro_with_generic_client_lifecycle() { typesense::Error, > = documents_client .search(SearchParameters { - q: Some("Wrench".to_owned()), - query_by: Some("title".to_owned()), + q: Some("Wrench".into()), + query_by: Some("title".into()), ..Default::default() }) .await; @@ -449,8 +450,8 @@ async fn logic_test_derive_macro_with_generic_client_lifecycle() { // B. Search a renamed field let search_res2 = documents_client .search(SearchParameters { - q: Some("Wrenchmaster".to_owned()), - query_by: Some("product_name".to_owned()), + q: Some("Wrenchmaster".into()), + query_by: Some("product_name".into()), ..Default::default() }) .await; @@ -458,9 +459,9 @@ async fn logic_test_derive_macro_with_generic_client_lifecycle() { // C. Filter by a facet let search_params3 = SearchParameters { - q: Some("*".to_owned()), - query_by: Some("title".to_owned()), - filter_by: Some("brand:='MegaTools'".to_owned()), + q: Some("*".into()), + query_by: Some("title".into()), + filter_by: Some("brand:='MegaTools'".into()), ..Default::default() }; let search_res3 = documents_client.search(search_params3).await; @@ -468,9 +469,9 @@ async fn logic_test_derive_macro_with_generic_client_lifecycle() { // D. Filter by a range_index let search_params4 = SearchParameters { - q: Some("*".to_owned()), - query_by: Some("title".to_owned()), - filter_by: Some("review_score:>4.5".to_owned()), + q: Some("*".into()), + query_by: Some("title".into()), + filter_by: Some("review_score:>4.5".into()), ..Default::default() }; let search_res4 = documents_client.search(search_params4).await; @@ -478,8 +479,8 @@ async fn logic_test_derive_macro_with_generic_client_lifecycle() { // E. Search a flattened field let search_params5 = SearchParameters { - q: Some("MT-WM-3000".to_owned()), - query_by: Some("details.part_number".to_owned()), + q: Some("MT-WM-3000".into()), + query_by: Some("details.part_number".into()), ..Default::default() }; let search_res5 = documents_client.search(search_params5).await; @@ -487,9 +488,9 @@ async fn logic_test_derive_macro_with_generic_client_lifecycle() { // F. Filter by a deep nested field let search_params_deep = SearchParameters { - q: Some("*".to_owned()), - query_by: Some("title".to_owned()), - filter_by: Some("details.extra_details.color:='Red'".to_owned()), + q: Some("*".into()), + query_by: Some("title".into()), + filter_by: Some("details.extra_details.color:='Red'".into()), ..Default::default() }; let search_res_deep = documents_client.search(search_params_deep).await; @@ -500,8 +501,8 @@ async fn logic_test_derive_macro_with_generic_client_lifecycle() { ); let search_params6 = SearchParameters { - q: Some("WH-US-WEST-05".to_owned()), - query_by: Some("logistics_data.warehouse_code".to_owned()), + q: Some("WH-US-WEST-05".into()), + query_by: Some("logistics_data.warehouse_code".into()), ..Default::default() }; let search_res6 = documents_client.search(search_params6).await; @@ -513,8 +514,8 @@ async fn logic_test_derive_macro_with_generic_client_lifecycle() { // G. Search a field in a nested object array let search_params7 = SearchParameters { - q: Some("p-01".to_owned()), - query_by: Some("parts.part_id".to_owned()), + q: Some("p-01".into()), + query_by: Some("parts.part_id".into()), ..Default::default() }; let search_res7 = documents_client.search(search_params7).await; @@ -526,8 +527,8 @@ async fn logic_test_derive_macro_with_generic_client_lifecycle() { // H. Search a field in a flattened nested object array let search_params8 = SearchParameters { - q: Some("Supplier A".to_owned()), - query_by: Some("parts.supplier.name".to_owned()), + q: Some("Supplier A".into()), + query_by: Some("parts.supplier.name".into()), ..Default::default() }; let search_res8 = documents_client.search(search_params8).await; @@ -617,7 +618,7 @@ async fn logic_test_manual_flattening_lifecycle() { // 1. Create collection from the schema derived from `ManualFlattenedProduct` let mut schema = ManualFlattenedProduct::collection_schema(); - schema.name = collection_name.clone().into(); + schema.name = collection_name.as_str().into(); // Verify the generated schema is correct *before* creating it let schema_fields: Vec<_> = schema.fields.iter().map(|f| &f.name as &str).collect(); @@ -674,8 +675,8 @@ async fn logic_test_manual_flattening_lifecycle() { let search_res_indexed = typed_collection .documents() .search(SearchParameters { - q: Some("PG-123".to_owned()), - query_by: Some("details.part_number".to_owned()), + q: Some("PG-123".into()), + query_by: Some("details.part_number".into()), ..Default::default() }) .await diff --git a/typesense/tests/client/documents_test.rs b/typesense/tests/client/documents_test.rs index c4e6e87d..f5d34bdb 100644 --- a/typesense/tests/client/documents_test.rs +++ b/typesense/tests/client/documents_test.rs @@ -106,7 +106,7 @@ async fn run_test_schemaless_document_lifecycle() { // --- Export documents (via `documents().export_jsonl()`) --- let export_params = ExportDocumentsParameters { - filter_by: Some("author:John".to_owned()), + filter_by: Some("author:John".into()), ..Default::default() }; let exported_jsonl = documents_client @@ -122,7 +122,7 @@ async fn run_test_schemaless_document_lifecycle() { // --- Bulk Delete --- let delete_params = DeleteDocumentsParameters { - filter_by: "publication_year:>1960".to_owned(), + filter_by: "publication_year:>1960".into(), ..Default::default() }; let bulk_delete_response = documents_client @@ -152,7 +152,7 @@ async fn run_test_generic_document_lifecycle() { // --- 1. Setup: Create a Collection matching the Book struct --- let schema = CollectionSchema { - name: collection_name.clone().into(), + name: collection_name.as_str().into(), fields: vec![ Field { name: "title".into(), @@ -232,8 +232,8 @@ async fn run_test_generic_document_lifecycle() { // --- 5. Search for documents with strongly-typed results --- let search_params = SearchParameters { - q: Some("dune".to_owned()), - query_by: Some("title".to_owned()), + q: Some("dune".into()), + query_by: Some("title".into()), ..Default::default() }; let search_results = typed_collection @@ -277,7 +277,8 @@ async fn run_test_generic_document_lifecycle() { // --- 7. Bulk Update (via `documents().update()`) --- let bulk_update_params = UpdateDocumentsParameters { - filter_by: Some("publication_year:>1965".to_owned()), + filter_by: Some("publication_year:>1965".into()), + _phantom: core::marker::PhantomData, }; let bulk_update_response = typed_collection .documents() diff --git a/typesense/tests/client/keys_test.rs b/typesense/tests/client/keys_test.rs index a2f4a216..551275a6 100644 --- a/typesense/tests/client/keys_test.rs +++ b/typesense/tests/client/keys_test.rs @@ -7,7 +7,7 @@ async fn run_test_keys_lifecycle() { // --- 1. Create a new API Key (via `keys`) --- let key_schema = ApiKeySchema { - description: key_description.to_owned(), + description: key_description.into(), actions: vec!["documents:search".to_owned()], // Grant only search permissions collections: vec!["*".to_owned()], // For all collections ..Default::default() @@ -88,7 +88,7 @@ fn test_generate_scoped_search_key_with_example_values() { // The parameters to be embedded in the new scoped key. let params = ScopedKeyParameters { search_params: Some(SearchParameters { - filter_by: Some("company_id:124".to_owned()), + filter_by: Some("company_id:124".into()), ..Default::default() }), expires_at: Some(1906054106), diff --git a/typesense/tests/client/multi_search_test.rs b/typesense/tests/client/multi_search_test.rs index 95cedec4..38a7b22c 100644 --- a/typesense/tests/client/multi_search_test.rs +++ b/typesense/tests/client/multi_search_test.rs @@ -17,7 +17,10 @@ async fn setup_multi_search_tests( // --- Create collections --- let products_schema = CollectionSchema { name: products_collection_name.to_owned().into(), - fields: vec![Field::new("name", "string"), Field::new("price", "int32")], + fields: vec![ + Field::new("name".into(), "string".into()), + Field::new("price".into(), "int32".into()), + ], ..Default::default() }; client.collections().create(products_schema).await.unwrap(); @@ -25,8 +28,8 @@ async fn setup_multi_search_tests( let brands_schema = CollectionSchema { name: brands_collection_name.to_owned().into(), fields: vec![ - Field::new("company_name", "string"), - Field::new("country", "string"), + Field::new("company_name".into(), "string".into()), + Field::new("country".into(), "string".into()), ], ..Default::default() }; @@ -91,13 +94,13 @@ async fn run_test_multi_search_federated() { MultiSearchCollectionParameters { q: Some("pro".into()), query_by: Some("name".into()), - collection: Some(products_collection_name.clone()), + collection: Some(products_collection_name.into()), ..Default::default() }, MultiSearchCollectionParameters { q: Some("USA".into()), query_by: Some("country".into()), - collection: Some(brands_collection_name.clone()), + collection: Some(brands_collection_name.into()), ..Default::default() }, ], @@ -158,13 +161,13 @@ async fn run_test_multi_search_with_common_params() { let search_requests = MultiSearchBody { searches: vec![ MultiSearchCollectionParameters { - collection: Some(products_collection_name.clone()), + collection: Some(products_collection_name.into()), q: Some("pro".into()), // This should find "Macbook Pro" query_by: Some("name".into()), // Specific to the products schema ..Default::default() }, MultiSearchCollectionParameters { - collection: Some(brands_collection_name.clone()), + collection: Some(brands_collection_name.into()), q: Some("inc".into()), // This should find "Apple Inc." query_by: Some("company_name".into()), // Specific to the brands schema ..Default::default() @@ -246,14 +249,14 @@ async fn run_test_multi_search_generic_parsing() { MultiSearchCollectionParameters { q: Some("pro".into()), query_by: Some("name".into()), - collection: Some(products_collection_name.clone()), + collection: Some(products_collection_name.into()), ..Default::default() }, // Search #1 for brands MultiSearchCollectionParameters { q: Some("USA".into()), query_by: Some("country".into()), - collection: Some(brands_collection_name.clone()), + collection: Some(brands_collection_name.into()), ..Default::default() }, ], @@ -342,13 +345,13 @@ async fn run_test_multi_search_union_heterogeneous() { MultiSearchCollectionParameters { q: Some("pro".into()), query_by: Some("name".into()), - collection: Some(products_collection_name.clone()), + collection: Some(products_collection_name.into()), ..Default::default() }, MultiSearchCollectionParameters { q: Some("samsung".into()), query_by: Some("company_name".into()), - collection: Some(brands_collection_name.clone()), + collection: Some(brands_collection_name.into()), ..Default::default() }, ], @@ -424,14 +427,14 @@ async fn run_test_multi_search_union_homogeneous_and_typed_conversion() { MultiSearchCollectionParameters { q: Some("iphone".into()), query_by: Some("name".into()), - collection: Some(products_collection_name.clone()), + collection: Some(products_collection_name.as_str().into()), ..Default::default() }, // This query should find "MacBook Pro" MultiSearchCollectionParameters { q: Some("macbook".into()), query_by: Some("name".into()), - collection: Some(products_collection_name.clone()), + collection: Some(products_collection_name.as_str().into()), ..Default::default() }, ], diff --git a/typesense/tests/client/operations_test.rs b/typesense/tests/client/operations_test.rs index 9a0f1a6d..5f790a84 100644 --- a/typesense/tests/client/operations_test.rs +++ b/typesense/tests/client/operations_test.rs @@ -66,7 +66,8 @@ async fn run_test_take_snapshot() { // Note: This requires a directory that Typesense can write to. // In a typical Docker setup, `/tmp` is a safe choice. let params = typesense::models::TakeSnapshotParams { - snapshot_path: "/tmp/typesense-snapshots-rust-test".to_string(), + snapshot_path: "/tmp/typesense-snapshots-rust-test".into(), + _phantom: core::marker::PhantomData, }; let snapshot_result = client.operations().take_snapshot(params).await; diff --git a/typesense/tests/client/presets_test.rs b/typesense/tests/client/presets_test.rs index 4cd2c62b..854b467b 100644 --- a/typesense/tests/client/presets_test.rs +++ b/typesense/tests/client/presets_test.rs @@ -9,8 +9,8 @@ async fn run_test_presets_lifecycle() { // --- 1. Define the Preset's value using the strong types --- // This will be the expected value in the response as well. let search_params = SearchParameters { - query_by: Some("title,authors".to_owned()), - sort_by: Some("_text_match:desc,publication_year:desc".to_owned()), + query_by: Some("title,authors".into()), + sort_by: Some("_text_match:desc,publication_year:desc".into()), ..Default::default() }; let expected_preset_value = PresetUpsertSchemaValue::SearchParameters(Box::new(search_params)); @@ -18,6 +18,7 @@ async fn run_test_presets_lifecycle() { // This is the schema to be sent in the request body. let upsert_schema = PresetUpsertSchema { value: Box::new(expected_preset_value.clone()), + _phantom: core::marker::PhantomData, }; // --- 2. Create (Upsert) a Preset (via `presets`) --- diff --git a/typesense/tests/client/stopwords_test.rs b/typesense/tests/client/stopwords_test.rs index 9f89abe2..f0310e67 100644 --- a/typesense/tests/client/stopwords_test.rs +++ b/typesense/tests/client/stopwords_test.rs @@ -12,9 +12,11 @@ async fn run_test_stopwords_and_stopword_lifecycle() { ..Default::default() }; - let upsert_result = client.stopwords().upsert(&set_id, schema).await; - assert!(upsert_result.is_ok(), "Failed to upsert stopwords set"); - let upserted_set = upsert_result.unwrap(); + let upserted_set = client + .stopwords() + .upsert(&set_id, schema) + .await + .expect("Failed to upsert stopwords set"); assert_eq!(upserted_set.id, set_id); assert_eq!(upserted_set.stopwords, vec!["a", "the", "an"]); diff --git a/typesense/tests/derive/collection.rs b/typesense/tests/derive/collection.rs index b635ecbc..85e4b2cd 100644 --- a/typesense/tests/derive/collection.rs +++ b/typesense/tests/derive/collection.rs @@ -215,10 +215,19 @@ fn derived_document_handles_nested_and_flattened_fields() { // --- Sub-fields indexing --- { "name": "profile", "type": "object" }, + + { "name": "previous_addresses", "type": "object[]" }, + + { "name": "nested_struct_vec", "type": "object[]"}, + + // --- Manually flattened object --- + // correctly skipped `data` + { "name": "primary_address.city", "type": "string" }, + { "name": "work_addresses.zip", "type": "string[]" }, + { "name": "profile.name", "type": "string", "facet": true, "sort": true}, { "name": "profile.email", "type": "string", "optional": true }, - { "name": "previous_addresses", "type": "object[]" }, { "name": "previous_addresses.line_1", "type": "string[]" }, { "name": "previous_addresses.number", "type": "int32[]" }, { "name": "previous_addresses.optional_field", "type": "string[]", "optional": true}, @@ -232,16 +241,10 @@ fn derived_document_handles_nested_and_flattened_fields() { { "name": "nested_struct.address.primary_city", "type": "string" }, { "name": "nested_struct.address.work_zips", "type": "string[]" }, - { "name": "nested_struct_vec", "type": "object[]"}, { "name": "nested_struct_vec.name", "type": "string[]"}, { "name": "nested_struct_vec.address", "type": "object[]" }, { "name": "nested_struct_vec.address.primary_city", "type": "string[]" }, - { "name": "nested_struct_vec.address.work_zips", "type": "string[]" }, - - // --- Manually flattened object --- - // correctly skipped `data` - { "name": "primary_address.city", "type": "string" }, - { "name": "work_addresses.zip", "type": "string[]" } + { "name": "nested_struct_vec.address.work_zips", "type": "string[]" } ] }); diff --git a/typesense_codegen/.openapi-generator/VERSION b/typesense_codegen/.openapi-generator/VERSION index e465da43..2fb556b6 100644 --- a/typesense_codegen/.openapi-generator/VERSION +++ b/typesense_codegen/.openapi-generator/VERSION @@ -1 +1 @@ -7.14.0 +7.18.0-SNAPSHOT diff --git a/typesense_codegen/README.md b/typesense_codegen/README.md index d324f6f9..250ae463 100644 --- a/typesense_codegen/README.md +++ b/typesense_codegen/README.md @@ -9,7 +9,7 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat - API version: 30.0 - Package version: 30.0 -- Generator version: 7.14.0 +- Generator version: 7.18.0-SNAPSHOT - Build package: `org.openapitools.codegen.languages.RustClientCodegen` ## Installation diff --git a/typesense_codegen/src/apis/analytics_api.rs b/typesense_codegen/src/apis/analytics_api.rs index ef17e522..9bd7474a 100644 --- a/typesense_codegen/src/apis/analytics_api.rs +++ b/typesense_codegen/src/apis/analytics_api.rs @@ -10,137 +10,182 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; +use ::std::{borrow::Cow, marker::PhantomData}; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; /// struct for passing parameters to the method [`create_analytics_event`] #[derive(Clone, Debug)] -pub struct CreateAnalyticsEventParams { +pub struct CreateAnalyticsEventParams<'p> { /// The analytics event to be created - pub analytics_event: models::AnalyticsEvent, + pub analytics_event: models::AnalyticsEvent<'p>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`create_analytics_rule`] #[derive(Clone, Debug)] -pub struct CreateAnalyticsRuleParams { +pub struct CreateAnalyticsRuleParams<'p> { /// The analytics rule(s) to be created - pub create_analytics_rule_request: models::CreateAnalyticsRuleRequest, + pub create_analytics_rule_request: models::CreateAnalyticsRuleRequest<'p>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_analytics_rule`] #[derive(Clone, Debug)] -pub struct DeleteAnalyticsRuleParams { +pub struct DeleteAnalyticsRuleParams<'p> { /// The name of the analytics rule to delete - pub rule_name: String, + pub rule_name: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`get_analytics_events`] #[derive(Clone, Debug)] -pub struct GetAnalyticsEventsParams { - pub user_id: String, +pub struct GetAnalyticsEventsParams<'p> { + pub user_id: Cow<'p, str>, /// Analytics rule name - pub name: String, + pub name: Cow<'p, str>, /// Number of events to return (max 1000) pub n: i32, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_analytics_rule`] #[derive(Clone, Debug)] -pub struct RetrieveAnalyticsRuleParams { +pub struct RetrieveAnalyticsRuleParams<'p> { /// The name of the analytics rule to retrieve - pub rule_name: String, + pub rule_name: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_analytics_rules`] #[derive(Clone, Debug)] -pub struct RetrieveAnalyticsRulesParams { +pub struct RetrieveAnalyticsRulesParams<'p> { /// Filter rules by rule_tag - pub rule_tag: Option, + pub rule_tag: Option>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`upsert_analytics_rule`] #[derive(Clone, Debug)] -pub struct UpsertAnalyticsRuleParams { +pub struct UpsertAnalyticsRuleParams<'p> { /// The name of the analytics rule to upsert - pub rule_name: String, + pub rule_name: Cow<'p, str>, /// The Analytics rule to be upserted - pub analytics_rule_update: models::AnalyticsRuleUpdate, + pub analytics_rule_update: models::AnalyticsRuleUpdate<'p>, + pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`create_analytics_event`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CreateAnalyticsEventError { - Status400(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum CreateAnalyticsEventError<'a> { + Status400(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`create_analytics_rule`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CreateAnalyticsRuleError { - Status400(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum CreateAnalyticsRuleError<'a> { + Status400(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`delete_analytics_rule`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteAnalyticsRuleError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum DeleteAnalyticsRuleError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`flush_analytics`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum FlushAnalyticsError { - UnknownValue(serde_json::Value), +pub enum FlushAnalyticsError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`get_analytics_events`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetAnalyticsEventsError { - Status400(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum GetAnalyticsEventsError<'a> { + Status400(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`get_analytics_status`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetAnalyticsStatusError { - UnknownValue(serde_json::Value), +pub enum GetAnalyticsStatusError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_analytics_rule`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveAnalyticsRuleError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum RetrieveAnalyticsRuleError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_analytics_rules`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveAnalyticsRulesError { - UnknownValue(serde_json::Value), +pub enum RetrieveAnalyticsRulesError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`upsert_analytics_rule`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertAnalyticsRuleError { - Status400(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum UpsertAnalyticsRuleError<'a> { + Status400(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// Submit a single analytics event. The event must correspond to an existing analytics rule by name. pub async fn create_analytics_event( configuration: &configuration::Configuration, - params: &CreateAnalyticsEventParams, -) -> Result> { + params: &CreateAnalyticsEventParams<'_>, +) -> Result, Error>> +{ let uri_str = format!("{}/analytics/events", configuration.base_path); let mut req_builder = configuration .client @@ -199,8 +244,9 @@ pub async fn create_analytics_event( /// Create one or more analytics rules. You can send a single rule object or an array of rule objects. pub async fn create_analytics_rule( configuration: &configuration::Configuration, - params: &CreateAnalyticsRuleParams, -) -> Result> { + params: &CreateAnalyticsRuleParams<'_>, +) -> Result, Error>> +{ let uri_str = format!("{}/analytics/rules", configuration.base_path); let mut req_builder = configuration .client @@ -259,8 +305,8 @@ pub async fn create_analytics_rule( /// Permanently deletes an analytics rule, given it's name pub async fn delete_analytics_rule( configuration: &configuration::Configuration, - params: &DeleteAnalyticsRuleParams, -) -> Result> { + params: &DeleteAnalyticsRuleParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/analytics/rules/{ruleName}", configuration.base_path, @@ -322,7 +368,7 @@ pub async fn delete_analytics_rule( /// Triggers a flush of analytics data to persistent storage. pub async fn flush_analytics( configuration: &configuration::Configuration, -) -> Result> { +) -> Result, Error>> { let uri_str = format!("{}/analytics/flush", configuration.base_path); let mut req_builder = configuration .client @@ -380,8 +426,8 @@ pub async fn flush_analytics( /// Retrieve the most recent events for a user and rule. pub async fn get_analytics_events( configuration: &configuration::Configuration, - params: &GetAnalyticsEventsParams, -) -> Result> { + params: &GetAnalyticsEventsParams<'_>, +) -> Result, Error>> { let uri_str = format!("{}/analytics/events", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -440,7 +486,7 @@ pub async fn get_analytics_events( /// Returns sizes of internal analytics buffers and queues. pub async fn get_analytics_status( configuration: &configuration::Configuration, -) -> Result> { +) -> Result, Error>> { let uri_str = format!("{}/analytics/status", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -496,8 +542,8 @@ pub async fn get_analytics_status( /// Retrieve the details of an analytics rule, given it's name pub async fn retrieve_analytics_rule( configuration: &configuration::Configuration, - params: &RetrieveAnalyticsRuleParams, -) -> Result> { + params: &RetrieveAnalyticsRuleParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/analytics/rules/{ruleName}", configuration.base_path, @@ -557,8 +603,8 @@ pub async fn retrieve_analytics_rule( /// Retrieve all analytics rules. Use the optional rule_tag filter to narrow down results. pub async fn retrieve_analytics_rules( configuration: &configuration::Configuration, - params: &RetrieveAnalyticsRulesParams, -) -> Result, Error> { + params: &RetrieveAnalyticsRulesParams<'_>, +) -> Result>, Error>> { let uri_str = format!("{}/analytics/rules", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -617,8 +663,8 @@ pub async fn retrieve_analytics_rules( /// Upserts an analytics rule with the given name. pub async fn upsert_analytics_rule( configuration: &configuration::Configuration, - params: &UpsertAnalyticsRuleParams, -) -> Result> { + params: &UpsertAnalyticsRuleParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/analytics/rules/{ruleName}", configuration.base_path, diff --git a/typesense_codegen/src/apis/collections_api.rs b/typesense_codegen/src/apis/collections_api.rs index b965f8cf..70b8367d 100644 --- a/typesense_codegen/src/apis/collections_api.rs +++ b/typesense_codegen/src/apis/collections_api.rs @@ -10,148 +10,193 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; +use ::std::{borrow::Cow, marker::PhantomData}; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; /// struct for passing parameters to the method [`create_collection`] #[derive(Clone, Debug)] -pub struct CreateCollectionParams { +pub struct CreateCollectionParams<'p> { /// The collection object to be created - pub collection_schema: models::CollectionSchema, + pub collection_schema: models::CollectionSchema<'p>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_alias`] #[derive(Clone, Debug)] -pub struct DeleteAliasParams { +pub struct DeleteAliasParams<'p> { /// The name of the alias to delete - pub alias_name: String, + pub alias_name: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_collection`] #[derive(Clone, Debug)] -pub struct DeleteCollectionParams { +pub struct DeleteCollectionParams<'p> { /// The name of the collection to delete - pub collection_name: String, + pub collection_name: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`get_alias`] #[derive(Clone, Debug)] -pub struct GetAliasParams { +pub struct GetAliasParams<'p> { /// The name of the alias to retrieve - pub alias_name: String, + pub alias_name: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`get_collection`] #[derive(Clone, Debug)] -pub struct GetCollectionParams { +pub struct GetCollectionParams<'p> { /// The name of the collection to retrieve - pub collection_name: String, + pub collection_name: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`get_collections`] #[derive(Clone, Debug)] -pub struct GetCollectionsParams { - pub exclude_fields: Option, +pub struct GetCollectionsParams<'p> { + pub exclude_fields: Option>, pub limit: Option, pub offset: Option, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`update_collection`] #[derive(Clone, Debug)] -pub struct UpdateCollectionParams { +pub struct UpdateCollectionParams<'p> { /// The name of the collection to update - pub collection_name: String, + pub collection_name: Cow<'p, str>, /// The document object with fields to be updated - pub collection_update_schema: models::CollectionUpdateSchema, + pub collection_update_schema: models::CollectionUpdateSchema<'p>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`upsert_alias`] #[derive(Clone, Debug)] -pub struct UpsertAliasParams { +pub struct UpsertAliasParams<'p> { /// The name of the alias to create/update - pub alias_name: String, + pub alias_name: Cow<'p, str>, /// Collection alias to be created/updated - pub collection_alias_schema: Option, + pub collection_alias_schema: Option>, + pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`create_collection`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CreateCollectionError { - Status400(models::ApiResponse), - Status409(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum CreateCollectionError<'a> { + Status400(models::ApiResponse<'a>), + Status409(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`delete_alias`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteAliasError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum DeleteAliasError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`delete_collection`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteCollectionError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum DeleteCollectionError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`get_alias`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetAliasError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum GetAliasError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`get_aliases`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetAliasesError { - UnknownValue(serde_json::Value), +pub enum GetAliasesError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`get_collection`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetCollectionError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum GetCollectionError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`get_collections`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetCollectionsError { - UnknownValue(serde_json::Value), +pub enum GetCollectionsError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`update_collection`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpdateCollectionError { - Status400(models::ApiResponse), - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum UpdateCollectionError<'a> { + Status400(models::ApiResponse<'a>), + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`upsert_alias`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertAliasError { - Status400(models::ApiResponse), - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum UpsertAliasError<'a> { + Status400(models::ApiResponse<'a>), + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// When a collection is created, we give it a name and describe the fields that will be indexed from the documents added to the collection. pub async fn create_collection( configuration: &configuration::Configuration, - params: &CreateCollectionParams, -) -> Result> { + params: &CreateCollectionParams<'_>, +) -> Result, Error>> { let uri_str = format!("{}/collections", configuration.base_path); let mut req_builder = configuration .client @@ -209,8 +254,8 @@ pub async fn create_collection( pub async fn delete_alias( configuration: &configuration::Configuration, - params: &DeleteAliasParams, -) -> Result> { + params: &DeleteAliasParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/aliases/{aliasName}", configuration.base_path, @@ -272,8 +317,8 @@ pub async fn delete_alias( /// Permanently drops a collection. This action cannot be undone. For large collections, this might have an impact on read latencies. pub async fn delete_collection( configuration: &configuration::Configuration, - params: &DeleteCollectionParams, -) -> Result> { + params: &DeleteCollectionParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/collections/{collectionName}", configuration.base_path, @@ -335,8 +380,8 @@ pub async fn delete_collection( /// Find out which collection an alias points to by fetching it pub async fn get_alias( configuration: &configuration::Configuration, - params: &GetAliasParams, -) -> Result> { + params: &GetAliasParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/aliases/{aliasName}", configuration.base_path, @@ -396,7 +441,7 @@ pub async fn get_alias( /// List all aliases and the corresponding collections that they map to. pub async fn get_aliases( configuration: &configuration::Configuration, -) -> Result> { +) -> Result, Error>> { let uri_str = format!("{}/aliases", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -452,8 +497,8 @@ pub async fn get_aliases( /// Retrieve the details of a collection, given its name. pub async fn get_collection( configuration: &configuration::Configuration, - params: &GetCollectionParams, -) -> Result> { + params: &GetCollectionParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/collections/{collectionName}", configuration.base_path, @@ -513,8 +558,8 @@ pub async fn get_collection( /// Returns a summary of all your collections. The collections are returned sorted by creation date, with the most recent collections appearing first. pub async fn get_collections( configuration: &configuration::Configuration, - params: &GetCollectionsParams, -) -> Result, Error> { + params: &GetCollectionsParams<'_>, +) -> Result>, Error>> { let uri_str = format!("{}/collections", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -579,8 +624,8 @@ pub async fn get_collections( /// Update a collection's schema to modify the fields and their types. pub async fn update_collection( configuration: &configuration::Configuration, - params: &UpdateCollectionParams, -) -> Result> { + params: &UpdateCollectionParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/collections/{collectionName}", configuration.base_path, @@ -643,8 +688,8 @@ pub async fn update_collection( /// Create or update a collection alias. An alias is a virtual collection name that points to a real collection. If you're familiar with symbolic links on Linux, it's very similar to that. Aliases are useful when you want to reindex your data in the background on a new collection and switch your application to it without any changes to your code. pub async fn upsert_alias( configuration: &configuration::Configuration, - params: &UpsertAliasParams, -) -> Result> { + params: &UpsertAliasParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/aliases/{aliasName}", configuration.base_path, diff --git a/typesense_codegen/src/apis/conversations_api.rs b/typesense_codegen/src/apis/conversations_api.rs index c495f6b4..64c58c47 100644 --- a/typesense_codegen/src/apis/conversations_api.rs +++ b/typesense_codegen/src/apis/conversations_api.rs @@ -10,78 +10,104 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; +use ::std::{borrow::Cow, marker::PhantomData}; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; /// struct for passing parameters to the method [`create_conversation_model`] #[derive(Clone, Debug)] -pub struct CreateConversationModelParams { - pub conversation_model_create_schema: models::ConversationModelCreateSchema, +pub struct CreateConversationModelParams<'p> { + pub conversation_model_create_schema: models::ConversationModelCreateSchema<'p>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_conversation_model`] #[derive(Clone, Debug)] -pub struct DeleteConversationModelParams { +pub struct DeleteConversationModelParams<'p> { /// The id of the conversation model to delete - pub model_id: String, + pub model_id: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_conversation_model`] #[derive(Clone, Debug)] -pub struct RetrieveConversationModelParams { +pub struct RetrieveConversationModelParams<'p> { /// The id of the conversation model to retrieve - pub model_id: String, + pub model_id: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`update_conversation_model`] #[derive(Clone, Debug)] -pub struct UpdateConversationModelParams { +pub struct UpdateConversationModelParams<'p> { /// The id of the conversation model to update - pub model_id: String, - pub conversation_model_update_schema: models::ConversationModelUpdateSchema, + pub model_id: Cow<'p, str>, + pub conversation_model_update_schema: models::ConversationModelUpdateSchema<'p>, + pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`create_conversation_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CreateConversationModelError { - Status400(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum CreateConversationModelError<'a> { + Status400(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`delete_conversation_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteConversationModelError { - UnknownValue(serde_json::Value), +pub enum DeleteConversationModelError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_all_conversation_models`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveAllConversationModelsError { - UnknownValue(serde_json::Value), +pub enum RetrieveAllConversationModelsError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_conversation_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveConversationModelError { - UnknownValue(serde_json::Value), +pub enum RetrieveConversationModelError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`update_conversation_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpdateConversationModelError { - UnknownValue(serde_json::Value), +pub enum UpdateConversationModelError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// Create a Conversation Model pub async fn create_conversation_model( configuration: &configuration::Configuration, - params: &CreateConversationModelParams, -) -> Result> { + params: &CreateConversationModelParams<'_>, +) -> Result, Error>> +{ let uri_str = format!("{}/conversations/models", configuration.base_path); let mut req_builder = configuration .client @@ -140,8 +166,9 @@ pub async fn create_conversation_model( /// Delete a conversation model pub async fn delete_conversation_model( configuration: &configuration::Configuration, - params: &DeleteConversationModelParams, -) -> Result> { + params: &DeleteConversationModelParams<'_>, +) -> Result, Error>> +{ let uri_str = format!( "{}/conversations/models/{modelId}", configuration.base_path, @@ -203,7 +230,10 @@ pub async fn delete_conversation_model( /// Retrieve all conversation models pub async fn retrieve_all_conversation_models( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result< + Vec>, + Error>, +> { let uri_str = format!("{}/conversations/models", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -260,8 +290,9 @@ pub async fn retrieve_all_conversation_models( /// Retrieve a conversation model pub async fn retrieve_conversation_model( configuration: &configuration::Configuration, - params: &RetrieveConversationModelParams, -) -> Result> { + params: &RetrieveConversationModelParams<'_>, +) -> Result, Error>> +{ let uri_str = format!( "{}/conversations/models/{modelId}", configuration.base_path, @@ -321,8 +352,9 @@ pub async fn retrieve_conversation_model( /// Update a conversation model pub async fn update_conversation_model( configuration: &configuration::Configuration, - params: &UpdateConversationModelParams, -) -> Result> { + params: &UpdateConversationModelParams<'_>, +) -> Result, Error>> +{ let uri_str = format!( "{}/conversations/models/{modelId}", configuration.base_path, diff --git a/typesense_codegen/src/apis/curation_sets_api.rs b/typesense_codegen/src/apis/curation_sets_api.rs index 87a253f8..eef5faf2 100644 --- a/typesense_codegen/src/apis/curation_sets_api.rs +++ b/typesense_codegen/src/apis/curation_sets_api.rs @@ -10,136 +10,176 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; +use ::std::{borrow::Cow, marker::PhantomData}; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; /// struct for passing parameters to the method [`delete_curation_set`] #[derive(Clone, Debug)] -pub struct DeleteCurationSetParams { +pub struct DeleteCurationSetParams<'p> { /// The name of the curation set to delete - pub curation_set_name: String, + pub curation_set_name: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_curation_set_item`] #[derive(Clone, Debug)] -pub struct DeleteCurationSetItemParams { +pub struct DeleteCurationSetItemParams<'p> { /// The name of the curation set - pub curation_set_name: String, + pub curation_set_name: Cow<'p, str>, /// The id of the curation item to delete - pub item_id: String, + pub item_id: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_curation_set`] #[derive(Clone, Debug)] -pub struct RetrieveCurationSetParams { +pub struct RetrieveCurationSetParams<'p> { /// The name of the curation set to retrieve - pub curation_set_name: String, + pub curation_set_name: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_curation_set_item`] #[derive(Clone, Debug)] -pub struct RetrieveCurationSetItemParams { +pub struct RetrieveCurationSetItemParams<'p> { /// The name of the curation set - pub curation_set_name: String, + pub curation_set_name: Cow<'p, str>, /// The id of the curation item to retrieve - pub item_id: String, + pub item_id: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_curation_set_items`] #[derive(Clone, Debug)] -pub struct RetrieveCurationSetItemsParams { +pub struct RetrieveCurationSetItemsParams<'p> { /// The name of the curation set to retrieve items for - pub curation_set_name: String, + pub curation_set_name: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`upsert_curation_set`] #[derive(Clone, Debug)] -pub struct UpsertCurationSetParams { +pub struct UpsertCurationSetParams<'p> { /// The name of the curation set to create/update - pub curation_set_name: String, + pub curation_set_name: Cow<'p, str>, /// The curation set to be created/updated - pub curation_set_create_schema: models::CurationSetCreateSchema, + pub curation_set_create_schema: models::CurationSetCreateSchema<'p>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`upsert_curation_set_item`] #[derive(Clone, Debug)] -pub struct UpsertCurationSetItemParams { +pub struct UpsertCurationSetItemParams<'p> { /// The name of the curation set - pub curation_set_name: String, + pub curation_set_name: Cow<'p, str>, /// The id of the curation item to upsert - pub item_id: String, + pub item_id: Cow<'p, str>, /// The curation item to be created/updated - pub curation_item_create_schema: models::CurationItemCreateSchema, + pub curation_item_create_schema: models::CurationItemCreateSchema<'p>, + pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`delete_curation_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteCurationSetError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum DeleteCurationSetError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`delete_curation_set_item`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteCurationSetItemError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum DeleteCurationSetItemError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_curation_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveCurationSetError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum RetrieveCurationSetError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_curation_set_item`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveCurationSetItemError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum RetrieveCurationSetItemError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_curation_set_items`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveCurationSetItemsError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum RetrieveCurationSetItemsError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_curation_sets`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveCurationSetsError { - UnknownValue(serde_json::Value), +pub enum RetrieveCurationSetsError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`upsert_curation_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertCurationSetError { - Status400(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum UpsertCurationSetError<'a> { + Status400(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`upsert_curation_set_item`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertCurationSetItemError { - Status400(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum UpsertCurationSetItemError<'a> { + Status400(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// Delete a specific curation set by its name pub async fn delete_curation_set( configuration: &configuration::Configuration, - params: &DeleteCurationSetParams, -) -> Result> { + params: &DeleteCurationSetParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/curation_sets/{curationSetName}", configuration.base_path, @@ -201,8 +241,8 @@ pub async fn delete_curation_set( /// Delete a specific curation item by its id pub async fn delete_curation_set_item( configuration: &configuration::Configuration, - params: &DeleteCurationSetItemParams, -) -> Result> { + params: &DeleteCurationSetItemParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/curation_sets/{curationSetName}/items/{itemId}", configuration.base_path, @@ -265,8 +305,8 @@ pub async fn delete_curation_set_item( /// Retrieve a specific curation set by its name pub async fn retrieve_curation_set( configuration: &configuration::Configuration, - params: &RetrieveCurationSetParams, -) -> Result> { + params: &RetrieveCurationSetParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/curation_sets/{curationSetName}", configuration.base_path, @@ -326,8 +366,8 @@ pub async fn retrieve_curation_set( /// Retrieve a specific curation item by its id pub async fn retrieve_curation_set_item( configuration: &configuration::Configuration, - params: &RetrieveCurationSetItemParams, -) -> Result> { + params: &RetrieveCurationSetItemParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/curation_sets/{curationSetName}/items/{itemId}", configuration.base_path, @@ -388,8 +428,9 @@ pub async fn retrieve_curation_set_item( /// Retrieve all curation items in a set pub async fn retrieve_curation_set_items( configuration: &configuration::Configuration, - params: &RetrieveCurationSetItemsParams, -) -> Result, Error> { + params: &RetrieveCurationSetItemsParams<'_>, +) -> Result>, Error>> +{ let uri_str = format!( "{}/curation_sets/{curationSetName}/items", configuration.base_path, @@ -449,7 +490,7 @@ pub async fn retrieve_curation_set_items( /// Retrieve all curation sets pub async fn retrieve_curation_sets( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result>, Error>> { let uri_str = format!("{}/curation_sets", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -505,8 +546,8 @@ pub async fn retrieve_curation_sets( /// Create or update a curation set with the given name pub async fn upsert_curation_set( configuration: &configuration::Configuration, - params: &UpsertCurationSetParams, -) -> Result> { + params: &UpsertCurationSetParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/curation_sets/{curationSetName}", configuration.base_path, @@ -567,8 +608,8 @@ pub async fn upsert_curation_set( /// Create or update a curation set item with the given id pub async fn upsert_curation_set_item( configuration: &configuration::Configuration, - params: &UpsertCurationSetItemParams, -) -> Result> { + params: &UpsertCurationSetItemParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/curation_sets/{curationSetName}/items/{itemId}", configuration.base_path, diff --git a/typesense_codegen/src/apis/debug_api.rs b/typesense_codegen/src/apis/debug_api.rs index 73a5dba1..074d81dc 100644 --- a/typesense_codegen/src/apis/debug_api.rs +++ b/typesense_codegen/src/apis/debug_api.rs @@ -10,20 +10,25 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; +use ::std::{borrow::Cow, marker::PhantomData}; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; /// struct for typed errors of method [`debug`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DebugError { - UnknownValue(serde_json::Value), +pub enum DebugError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// Print debugging information pub async fn debug( configuration: &configuration::Configuration, -) -> Result> { +) -> Result, Error>> { let uri_str = format!("{}/debug", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); diff --git a/typesense_codegen/src/apis/documents_api.rs b/typesense_codegen/src/apis/documents_api.rs index eb146e3b..02591a75 100644 --- a/typesense_codegen/src/apis/documents_api.rs +++ b/typesense_codegen/src/apis/documents_api.rs @@ -10,106 +10,113 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; +use ::std::{borrow::Cow, marker::PhantomData}; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; /// struct for passing parameters to the method [`delete_document`] #[derive(Clone, Debug)] -pub struct DeleteDocumentParams { +pub struct DeleteDocumentParams<'p> { /// The name of the collection to search for the document under - pub collection_name: String, + pub collection_name: Cow<'p, str>, /// The Document ID - pub document_id: String, + pub document_id: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_documents`] #[derive(Clone, Debug)] -pub struct DeleteDocumentsParams { +pub struct DeleteDocumentsParams<'p> { /// The name of the collection to delete documents from - pub collection_name: String, - pub filter_by: Option, + pub collection_name: Cow<'p, str>, + pub filter_by: Option>, pub batch_size: Option, pub ignore_not_found: Option, pub truncate: Option, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`export_documents`] #[derive(Clone, Debug)] -pub struct ExportDocumentsParams { +pub struct ExportDocumentsParams<'p> { /// The name of the collection - pub collection_name: String, - pub filter_by: Option, - pub include_fields: Option, - pub exclude_fields: Option, + pub collection_name: Cow<'p, str>, + pub filter_by: Option>, + pub include_fields: Option>, + pub exclude_fields: Option>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`get_document`] #[derive(Clone, Debug)] -pub struct GetDocumentParams { +pub struct GetDocumentParams<'p> { /// The name of the collection to search for the document under - pub collection_name: String, + pub collection_name: Cow<'p, str>, /// The Document ID - pub document_id: String, + pub document_id: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`import_documents`] #[derive(Clone, Debug)] -pub struct ImportDocumentsParams { +pub struct ImportDocumentsParams<'p> { /// The name of the collection - pub collection_name: String, + pub collection_name: Cow<'p, str>, /// The json array of documents or the JSONL file to import - pub body: String, + pub body: Cow<'p, str>, pub batch_size: Option, pub return_id: Option, pub remote_embedding_batch_size: Option, pub return_doc: Option, pub action: Option, pub dirty_values: Option, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`index_document`] #[derive(Clone, Debug)] -pub struct IndexDocumentParams { +pub struct IndexDocumentParams<'p> { /// The name of the collection to add the document to - pub collection_name: String, + pub collection_name: Cow<'p, str>, /// The document object to be indexed pub body: serde_json::Value, /// Additional action to perform - pub action: Option, + pub action: Option>, /// Dealing with Dirty Data pub dirty_values: Option, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`multi_search`] #[derive(Clone, Debug)] -pub struct MultiSearchParams { - pub q: Option, - pub query_by: Option, - pub query_by_weights: Option, - pub text_match_type: Option, - pub prefix: Option, - pub infix: Option, +pub struct MultiSearchParams<'p> { + pub q: Option>, + pub query_by: Option>, + pub query_by_weights: Option>, + pub text_match_type: Option>, + pub prefix: Option>, + pub infix: Option>, pub max_extra_prefix: Option, pub max_extra_suffix: Option, - pub filter_by: Option, - pub sort_by: Option, - pub facet_by: Option, + pub filter_by: Option>, + pub sort_by: Option>, + pub facet_by: Option>, pub max_facet_values: Option, - pub facet_query: Option, - pub num_typos: Option, + pub facet_query: Option>, + pub num_typos: Option>, pub page: Option, pub per_page: Option, pub limit: Option, pub offset: Option, - pub group_by: Option, + pub group_by: Option>, pub group_limit: Option, pub group_missing_values: Option, - pub include_fields: Option, - pub exclude_fields: Option, - pub highlight_full_fields: Option, + pub include_fields: Option>, + pub exclude_fields: Option>, + pub highlight_full_fields: Option>, pub highlight_affix_num_tokens: Option, - pub highlight_start_tag: Option, - pub highlight_end_tag: Option, + pub highlight_start_tag: Option>, + pub highlight_end_tag: Option>, pub snippet_threshold: Option, pub drop_tokens_threshold: Option, pub drop_tokens_mode: Option, @@ -120,12 +127,12 @@ pub struct MultiSearchParams { pub enable_analytics: Option, pub synonym_prefix: Option, pub synonym_num_typos: Option, - pub pinned_hits: Option, - pub hidden_hits: Option, - pub override_tags: Option, - pub highlight_fields: Option, + pub pinned_hits: Option>, + pub hidden_hits: Option>, + pub override_tags: Option>, + pub highlight_fields: Option>, pub pre_segmented_query: Option, - pub preset: Option, + pub preset: Option>, pub enable_overrides: Option, pub prioritize_exact_match: Option, pub prioritize_token_position: Option, @@ -137,58 +144,59 @@ pub struct MultiSearchParams { pub cache_ttl: Option, pub min_len_1typo: Option, pub min_len_2typo: Option, - pub vector_query: Option, + pub vector_query: Option>, pub remote_embedding_timeout_ms: Option, pub remote_embedding_num_tries: Option, - pub facet_strategy: Option, - pub stopwords: Option, - pub facet_return_parent: Option, - pub voice_query: Option, + pub facet_strategy: Option>, + pub stopwords: Option>, + pub facet_return_parent: Option>, + pub voice_query: Option>, pub conversation: Option, - pub conversation_model_id: Option, - pub conversation_id: Option, - pub multi_search_searches_parameter: Option, + pub conversation_model_id: Option>, + pub conversation_id: Option>, + pub multi_search_searches_parameter: Option>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`search_collection`] #[derive(Clone, Debug)] -pub struct SearchCollectionParams { +pub struct SearchCollectionParams<'p> { /// The name of the collection to search for the document under - pub collection_name: String, - pub q: Option, - pub query_by: Option, + pub collection_name: Cow<'p, str>, + pub q: Option>, + pub query_by: Option>, pub nl_query: Option, - pub nl_model_id: Option, - pub query_by_weights: Option, - pub text_match_type: Option, - pub prefix: Option, - pub infix: Option, + pub nl_model_id: Option>, + pub query_by_weights: Option>, + pub text_match_type: Option>, + pub prefix: Option>, + pub infix: Option>, pub max_extra_prefix: Option, pub max_extra_suffix: Option, - pub filter_by: Option, + pub filter_by: Option>, pub max_filter_by_candidates: Option, - pub sort_by: Option, - pub facet_by: Option, + pub sort_by: Option>, + pub facet_by: Option>, pub max_facet_values: Option, - pub facet_query: Option, - pub num_typos: Option, + pub facet_query: Option>, + pub num_typos: Option>, pub page: Option, pub per_page: Option, pub limit: Option, pub offset: Option, - pub group_by: Option, + pub group_by: Option>, pub group_limit: Option, pub group_missing_values: Option, - pub include_fields: Option, - pub exclude_fields: Option, - pub highlight_full_fields: Option, + pub include_fields: Option>, + pub exclude_fields: Option>, + pub highlight_full_fields: Option>, pub highlight_affix_num_tokens: Option, - pub highlight_start_tag: Option, - pub highlight_end_tag: Option, + pub highlight_start_tag: Option>, + pub highlight_end_tag: Option>, pub enable_highlight_v1: Option, pub enable_analytics: Option, pub snippet_threshold: Option, - pub synonym_sets: Option, + pub synonym_sets: Option>, pub drop_tokens_threshold: Option, pub drop_tokens_mode: Option, pub typo_tokens_threshold: Option, @@ -197,13 +205,13 @@ pub struct SearchCollectionParams { pub enable_synonyms: Option, pub synonym_prefix: Option, pub synonym_num_typos: Option, - pub pinned_hits: Option, - pub hidden_hits: Option, - pub override_tags: Option, - pub highlight_fields: Option, - pub split_join_tokens: Option, + pub pinned_hits: Option>, + pub hidden_hits: Option>, + pub override_tags: Option>, + pub highlight_fields: Option>, + pub split_join_tokens: Option>, pub pre_segmented_query: Option, - pub preset: Option, + pub preset: Option>, pub enable_overrides: Option, pub prioritize_exact_match: Option, pub max_candidates: Option, @@ -216,129 +224,172 @@ pub struct SearchCollectionParams { pub cache_ttl: Option, pub min_len_1typo: Option, pub min_len_2typo: Option, - pub vector_query: Option, + pub vector_query: Option>, pub remote_embedding_timeout_ms: Option, pub remote_embedding_num_tries: Option, - pub facet_strategy: Option, - pub stopwords: Option, - pub facet_return_parent: Option, - pub voice_query: Option, + pub facet_strategy: Option>, + pub stopwords: Option>, + pub facet_return_parent: Option>, + pub voice_query: Option>, pub conversation: Option, - pub conversation_model_id: Option, - pub conversation_id: Option, + pub conversation_model_id: Option>, + pub conversation_id: Option>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`update_document`] #[derive(Clone, Debug)] -pub struct UpdateDocumentParams { +pub struct UpdateDocumentParams<'p, B> { /// The name of the collection to search for the document under - pub collection_name: String, + pub collection_name: Cow<'p, str>, /// The Document ID - pub document_id: String, + pub document_id: Cow<'p, str>, /// The document object with fields to be updated pub body: B, /// Dealing with Dirty Data pub dirty_values: Option, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`update_documents`] #[derive(Clone, Debug)] -pub struct UpdateDocumentsParams { +pub struct UpdateDocumentsParams<'p, B> { /// The name of the collection to update documents in - pub collection_name: String, + pub collection_name: Cow<'p, str>, /// The document fields to be updated pub body: B, - pub filter_by: Option, + pub filter_by: Option>, + pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`delete_document`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteDocumentError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum DeleteDocumentError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`delete_documents`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteDocumentsError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum DeleteDocumentsError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`export_documents`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum ExportDocumentsError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum ExportDocumentsError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`get_document`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetDocumentError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum GetDocumentError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`import_documents`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum ImportDocumentsError { - Status400(models::ApiResponse), - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum ImportDocumentsError<'a> { + Status400(models::ApiResponse<'a>), + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`index_document`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum IndexDocumentError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum IndexDocumentError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`multi_search`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum MultiSearchError { - Status400(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum MultiSearchError<'a> { + Status400(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`search_collection`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum SearchCollectionError { - Status400(models::ApiResponse), - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum SearchCollectionError<'a> { + Status400(models::ApiResponse<'a>), + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`update_document`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpdateDocumentError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum UpdateDocumentError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`update_documents`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpdateDocumentsError { - Status400(models::ApiResponse), - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum UpdateDocumentsError<'a> { + Status400(models::ApiResponse<'a>), + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// Delete an individual document from a collection by using its ID. pub async fn delete_document( configuration: &configuration::Configuration, - params: &DeleteDocumentParams, -) -> Result> { + params: &DeleteDocumentParams<'_>, +) -> Result>> { let uri_str = format!( "{}/collections/{collectionName}/documents/{documentId}", configuration.base_path, @@ -401,8 +452,8 @@ pub async fn delete_document( /// Delete a bunch of documents that match a specific filter condition. Use the `batch_size` parameter to control the number of documents that should deleted at a time. A larger value will speed up deletions, but will impact performance of other operations running on the server. pub async fn delete_documents( configuration: &configuration::Configuration, - params: &DeleteDocumentsParams, -) -> Result> { + params: &DeleteDocumentsParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/collections/{collectionName}/documents", configuration.base_path, @@ -476,8 +527,8 @@ pub async fn delete_documents( /// Export all documents in a collection in JSON lines format. pub async fn export_documents( configuration: &configuration::Configuration, - params: &ExportDocumentsParams, -) -> Result> { + params: &ExportDocumentsParams<'_>, +) -> Result>> { let uri_str = format!( "{}/collections/{collectionName}/documents/export", configuration.base_path, @@ -541,8 +592,8 @@ pub async fn export_documents( /// Fetch an individual document from a collection by using its ID. pub async fn get_document( configuration: &configuration::Configuration, - params: &GetDocumentParams, -) -> Result> { + params: &GetDocumentParams<'_>, +) -> Result>> { let uri_str = format!( "{}/collections/{collectionName}/documents/{documentId}", configuration.base_path, @@ -603,8 +654,8 @@ pub async fn get_document( /// The documents to be imported must be formatted in a newline delimited JSON structure. You can feed the output file from a Typesense export operation directly as import. pub async fn import_documents( configuration: &configuration::Configuration, - params: &ImportDocumentsParams, -) -> Result> { + params: &ImportDocumentsParams<'_>, +) -> Result>> { let uri_str = format!( "{}/collections/{collectionName}/documents/import", configuration.base_path, @@ -646,7 +697,7 @@ pub async fn import_documents( }; req_builder = req_builder .header(reqwest::header::CONTENT_TYPE, "text/plain") - .body(params.body.to_owned()); + .body(params.body.clone().into_owned()); let req = req_builder.build()?; let resp = configuration.client.execute(req).await?; @@ -683,8 +734,8 @@ pub async fn import_documents( /// A document to be indexed in a given collection must conform to the schema of the collection. pub async fn index_document( configuration: &configuration::Configuration, - params: &IndexDocumentParams, -) -> Result> { + params: &IndexDocumentParams<'_>, +) -> Result>> { let uri_str = format!( "{}/collections/{collectionName}/documents", configuration.base_path, @@ -753,8 +804,8 @@ pub async fn index_document( /// This is especially useful to avoid round-trip network latencies incurred otherwise if each of these requests are sent in separate HTTP requests. You can also use this feature to do a federated search across multiple collections in a single HTTP request. pub async fn multi_search( configuration: &configuration::Configuration, - params: &MultiSearchParams, -) -> Result> { + params: &MultiSearchParams<'_>, +) -> Result>> { let uri_str = format!("{}/multi_search", configuration.base_path); let mut req_builder = configuration .client @@ -1015,8 +1066,8 @@ pub async fn multi_search( /// Search for documents in a collection that match the search criteria. pub async fn search_collection serde::Deserialize<'de> + Serialize>( configuration: &configuration::Configuration, - params: &SearchCollectionParams, -) -> Result, Error> { + params: &SearchCollectionParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/collections/{collectionName}/documents/search", configuration.base_path, @@ -1276,12 +1327,12 @@ pub async fn search_collection serde::Deserialize<'de> + Serialize>( ContentType::Json => serde_json::from_str(&content).map_err(Error::from), ContentType::Text => { return Err(Error::from(serde_json::Error::custom( - "Received `text/plain` content type response that cannot be converted to `models::SearchResult`", + "Received `text/plain` content type response that cannot be converted to `models::SearchResult<'static, D>`", ))); } ContentType::Unsupported(unknown_type) => { return Err(Error::from(serde_json::Error::custom(format!( - "Received `{unknown_type}` content type response that cannot be converted to `models::SearchResult`" + "Received `{unknown_type}` content type response that cannot be converted to `models::SearchResult<'static, D>`" )))); } } @@ -1299,8 +1350,8 @@ pub async fn search_collection serde::Deserialize<'de> + Serialize>( /// Update an individual document from a collection by using its ID. The update can be partial. pub async fn update_document( configuration: &configuration::Configuration, - params: &UpdateDocumentParams, -) -> Result> { + params: &UpdateDocumentParams<'_, B>, +) -> Result>> { let uri_str = format!( "{}/collections/{collectionName}/documents/{documentId}", configuration.base_path, @@ -1367,8 +1418,8 @@ pub async fn update_document( /// The filter_by query parameter is used to filter to specify a condition against which the documents are matched. The request body contains the fields that should be updated for any documents that match the filter condition. This endpoint is only available if the Typesense server is version `0.25.0.rc12` or later. pub async fn update_documents( configuration: &configuration::Configuration, - params: &UpdateDocumentsParams, -) -> Result> { + params: &UpdateDocumentsParams<'_, B>, +) -> Result, Error>> { let uri_str = format!( "{}/collections/{collectionName}/documents", configuration.base_path, diff --git a/typesense_codegen/src/apis/health_api.rs b/typesense_codegen/src/apis/health_api.rs index 8cc1524d..e0fb7879 100644 --- a/typesense_codegen/src/apis/health_api.rs +++ b/typesense_codegen/src/apis/health_api.rs @@ -10,20 +10,25 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; +use ::std::{borrow::Cow, marker::PhantomData}; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; /// struct for typed errors of method [`health`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum HealthError { - UnknownValue(serde_json::Value), +pub enum HealthError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// Checks if Typesense server is ready to accept requests. pub async fn health( configuration: &configuration::Configuration, -) -> Result> { +) -> Result, Error>> { let uri_str = format!("{}/health", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); diff --git a/typesense_codegen/src/apis/keys_api.rs b/typesense_codegen/src/apis/keys_api.rs index c7024921..ceb6af3e 100644 --- a/typesense_codegen/src/apis/keys_api.rs +++ b/typesense_codegen/src/apis/keys_api.rs @@ -10,68 +10,88 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; +use ::std::{borrow::Cow, marker::PhantomData}; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; /// struct for passing parameters to the method [`create_key`] #[derive(Clone, Debug)] -pub struct CreateKeyParams { +pub struct CreateKeyParams<'p> { /// The object that describes API key scope - pub api_key_schema: Option, + pub api_key_schema: Option>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_key`] #[derive(Clone, Debug)] -pub struct DeleteKeyParams { +pub struct DeleteKeyParams<'p> { /// The ID of the key to delete pub key_id: i64, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`get_key`] #[derive(Clone, Debug)] -pub struct GetKeyParams { +pub struct GetKeyParams<'p> { /// The ID of the key to retrieve pub key_id: i64, + pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`create_key`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CreateKeyError { - Status400(models::ApiResponse), - Status409(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum CreateKeyError<'a> { + Status400(models::ApiResponse<'a>), + Status409(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`delete_key`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteKeyError { - Status400(models::ApiResponse), - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum DeleteKeyError<'a> { + Status400(models::ApiResponse<'a>), + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`get_key`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetKeyError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum GetKeyError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`get_keys`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetKeysError { - UnknownValue(serde_json::Value), +pub enum GetKeysError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// Create an API Key with fine-grain access control. You can restrict access on both a per-collection and per-action level. The generated key is returned only during creation. You want to store this key carefully in a secure place. pub async fn create_key( configuration: &configuration::Configuration, - params: &CreateKeyParams, -) -> Result> { + params: &CreateKeyParams<'_>, +) -> Result, Error>> { let uri_str = format!("{}/keys", configuration.base_path); let mut req_builder = configuration .client @@ -129,8 +149,8 @@ pub async fn create_key( pub async fn delete_key( configuration: &configuration::Configuration, - params: &DeleteKeyParams, -) -> Result> { + params: &DeleteKeyParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/keys/{keyId}", configuration.base_path, @@ -192,8 +212,8 @@ pub async fn delete_key( /// Retrieve (metadata about) a key. Only the key prefix is returned when you retrieve a key. Due to security reasons, only the create endpoint returns the full API key. pub async fn get_key( configuration: &configuration::Configuration, - params: &GetKeyParams, -) -> Result> { + params: &GetKeyParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/keys/{keyId}", configuration.base_path, @@ -252,7 +272,7 @@ pub async fn get_key( pub async fn get_keys( configuration: &configuration::Configuration, -) -> Result> { +) -> Result, Error>> { let uri_str = format!("{}/keys", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); diff --git a/typesense_codegen/src/apis/nl_search_models_api.rs b/typesense_codegen/src/apis/nl_search_models_api.rs index 5458cbb5..fb7ef1ff 100644 --- a/typesense_codegen/src/apis/nl_search_models_api.rs +++ b/typesense_codegen/src/apis/nl_search_models_api.rs @@ -10,84 +10,109 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; +use ::std::{borrow::Cow, marker::PhantomData}; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; /// struct for passing parameters to the method [`create_nl_search_model`] #[derive(Clone, Debug)] -pub struct CreateNlSearchModelParams { +pub struct CreateNlSearchModelParams<'p> { /// The NL search model to be created - pub nl_search_model_create_schema: models::NlSearchModelCreateSchema, + pub nl_search_model_create_schema: models::NlSearchModelCreateSchema<'p>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_nl_search_model`] #[derive(Clone, Debug)] -pub struct DeleteNlSearchModelParams { +pub struct DeleteNlSearchModelParams<'p> { /// The ID of the NL search model to delete - pub model_id: String, + pub model_id: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_nl_search_model`] #[derive(Clone, Debug)] -pub struct RetrieveNlSearchModelParams { +pub struct RetrieveNlSearchModelParams<'p> { /// The ID of the NL search model to retrieve - pub model_id: String, + pub model_id: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`update_nl_search_model`] #[derive(Clone, Debug)] -pub struct UpdateNlSearchModelParams { +pub struct UpdateNlSearchModelParams<'p> { /// The ID of the NL search model to update - pub model_id: String, + pub model_id: Cow<'p, str>, /// The NL search model fields to update - pub body: models::NlSearchModelCreateSchema, + pub body: models::NlSearchModelCreateSchema<'p>, + pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`create_nl_search_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CreateNlSearchModelError { - Status400(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum CreateNlSearchModelError<'a> { + Status400(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`delete_nl_search_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteNlSearchModelError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum DeleteNlSearchModelError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_all_nl_search_models`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveAllNlSearchModelsError { - UnknownValue(serde_json::Value), +pub enum RetrieveAllNlSearchModelsError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_nl_search_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveNlSearchModelError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum RetrieveNlSearchModelError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`update_nl_search_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpdateNlSearchModelError { - Status400(models::ApiResponse), - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum UpdateNlSearchModelError<'a> { + Status400(models::ApiResponse<'a>), + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// Create a new NL search model. pub async fn create_nl_search_model( configuration: &configuration::Configuration, - params: &CreateNlSearchModelParams, -) -> Result> { + params: &CreateNlSearchModelParams<'_>, +) -> Result, Error>> { let uri_str = format!("{}/nl_search_models", configuration.base_path); let mut req_builder = configuration .client @@ -146,8 +171,8 @@ pub async fn create_nl_search_model( /// Delete a specific NL search model by its ID. pub async fn delete_nl_search_model( configuration: &configuration::Configuration, - params: &DeleteNlSearchModelParams, -) -> Result> { + params: &DeleteNlSearchModelParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/nl_search_models/{modelId}", configuration.base_path, @@ -209,7 +234,8 @@ pub async fn delete_nl_search_model( /// Retrieve all NL search models. pub async fn retrieve_all_nl_search_models( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result>, Error>> +{ let uri_str = format!("{}/nl_search_models", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -265,8 +291,8 @@ pub async fn retrieve_all_nl_search_models( /// Retrieve a specific NL search model by its ID. pub async fn retrieve_nl_search_model( configuration: &configuration::Configuration, - params: &RetrieveNlSearchModelParams, -) -> Result> { + params: &RetrieveNlSearchModelParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/nl_search_models/{modelId}", configuration.base_path, @@ -326,8 +352,8 @@ pub async fn retrieve_nl_search_model( /// Update an existing NL search model. pub async fn update_nl_search_model( configuration: &configuration::Configuration, - params: &UpdateNlSearchModelParams, -) -> Result> { + params: &UpdateNlSearchModelParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/nl_search_models/{modelId}", configuration.base_path, diff --git a/typesense_codegen/src/apis/operations_api.rs b/typesense_codegen/src/apis/operations_api.rs index defe8cb9..b7b0e86b 100644 --- a/typesense_codegen/src/apis/operations_api.rs +++ b/typesense_codegen/src/apis/operations_api.rs @@ -10,82 +10,117 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; +use ::std::{borrow::Cow, marker::PhantomData}; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; /// struct for passing parameters to the method [`take_snapshot`] #[derive(Clone, Debug)] -pub struct TakeSnapshotParams { +pub struct TakeSnapshotParams<'p> { /// The directory on the server where the snapshot should be saved. - pub snapshot_path: String, + pub snapshot_path: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`toggle_slow_request_log`] #[derive(Clone, Debug)] -pub struct ToggleSlowRequestLogParams { - pub toggle_slow_request_log_request: Option, +pub struct ToggleSlowRequestLogParams<'p> { + pub toggle_slow_request_log_request: Option>, + pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`clear_cache`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum ClearCacheError { - UnknownValue(serde_json::Value), +pub enum ClearCacheError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`compact_db`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CompactDbError { - UnknownValue(serde_json::Value), +pub enum CompactDbError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`get_schema_changes`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetSchemaChangesError { - UnknownValue(serde_json::Value), +pub enum GetSchemaChangesError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_api_stats`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveApiStatsError { - UnknownValue(serde_json::Value), +pub enum RetrieveApiStatsError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_metrics`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveMetricsError { - UnknownValue(serde_json::Value), +pub enum RetrieveMetricsError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`take_snapshot`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum TakeSnapshotError { - UnknownValue(serde_json::Value), +pub enum TakeSnapshotError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`toggle_slow_request_log`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum ToggleSlowRequestLogError { - UnknownValue(serde_json::Value), +pub enum ToggleSlowRequestLogError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`vote`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum VoteError { - UnknownValue(serde_json::Value), +pub enum VoteError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// Clear the cached responses of search requests that are sent with `use_cache` parameter in the LRU cache. pub async fn clear_cache( configuration: &configuration::Configuration, -) -> Result> { +) -> Result, Error>> { let uri_str = format!("{}/operations/cache/clear", configuration.base_path); let mut req_builder = configuration .client @@ -143,7 +178,7 @@ pub async fn clear_cache( /// Typesense uses RocksDB to store your documents on the disk. If you do frequent writes or updates, you could benefit from running a compaction of the underlying RocksDB database. This could reduce the size of the database and decrease read latency. While the database will not block during this operation, we recommend running it during off-peak hours. pub async fn compact_db( configuration: &configuration::Configuration, -) -> Result> { +) -> Result, Error>> { let uri_str = format!("{}/operations/db/compact", configuration.base_path); let mut req_builder = configuration .client @@ -201,7 +236,8 @@ pub async fn compact_db( /// Returns the status of any ongoing schema change operations. If no schema changes are in progress, returns an empty response. pub async fn get_schema_changes( configuration: &configuration::Configuration, -) -> Result>, Error> { +) -> Result>>, Error>> +{ let uri_str = format!("{}/operations/schema_changes", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -234,12 +270,12 @@ pub async fn get_schema_changes( ContentType::Json => serde_json::from_str(&content).map_err(Error::from), ContentType::Text => { return Err(Error::from(serde_json::Error::custom( - "Received `text/plain` content type response that cannot be converted to `Option>`", + "Received `text/plain` content type response that cannot be converted to `Option>>`", ))); } ContentType::Unsupported(unknown_type) => { return Err(Error::from(serde_json::Error::custom(format!( - "Received `{unknown_type}` content type response that cannot be converted to `Option>`" + "Received `{unknown_type}` content type response that cannot be converted to `Option>>`" )))); } } @@ -257,7 +293,7 @@ pub async fn get_schema_changes( /// Retrieve the stats about API endpoints. pub async fn retrieve_api_stats( configuration: &configuration::Configuration, -) -> Result> { +) -> Result, Error>> { let uri_str = format!("{}/stats.json", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -313,7 +349,7 @@ pub async fn retrieve_api_stats( /// Retrieve the metrics. pub async fn retrieve_metrics( configuration: &configuration::Configuration, -) -> Result> { +) -> Result>> { let uri_str = format!("{}/metrics.json", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -369,8 +405,8 @@ pub async fn retrieve_metrics( /// Creates a point-in-time snapshot of a Typesense node's state and data in the specified directory. You can then backup the snapshot directory that gets created and later restore it as a data directory, as needed. pub async fn take_snapshot( configuration: &configuration::Configuration, - params: &TakeSnapshotParams, -) -> Result> { + params: &TakeSnapshotParams<'_>, +) -> Result, Error>> { let uri_str = format!("{}/operations/snapshot", configuration.base_path); let mut req_builder = configuration .client @@ -429,8 +465,8 @@ pub async fn take_snapshot( /// Enable logging of requests that take over a defined threshold of time. Default is `-1` which disables slow request logging. Slow requests are logged to the primary log file, with the prefix SLOW REQUEST. pub async fn toggle_slow_request_log( configuration: &configuration::Configuration, - params: &ToggleSlowRequestLogParams, -) -> Result> { + params: &ToggleSlowRequestLogParams<'_>, +) -> Result, Error>> { let uri_str = format!("{}/config", configuration.base_path); let mut req_builder = configuration .client @@ -489,7 +525,7 @@ pub async fn toggle_slow_request_log( /// Triggers a follower node to initiate the raft voting process, which triggers leader re-election. The follower node that you run this operation against will become the new leader, once this command succeeds. pub async fn vote( configuration: &configuration::Configuration, -) -> Result> { +) -> Result, Error>> { let uri_str = format!("{}/operations/vote", configuration.base_path); let mut req_builder = configuration .client diff --git a/typesense_codegen/src/apis/presets_api.rs b/typesense_codegen/src/apis/presets_api.rs index 8b296b20..b9e4de48 100644 --- a/typesense_codegen/src/apis/presets_api.rs +++ b/typesense_codegen/src/apis/presets_api.rs @@ -10,68 +10,88 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; +use ::std::{borrow::Cow, marker::PhantomData}; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; /// struct for passing parameters to the method [`delete_preset`] #[derive(Clone, Debug)] -pub struct DeletePresetParams { +pub struct DeletePresetParams<'p> { /// The ID of the preset to delete. - pub preset_id: String, + pub preset_id: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_preset`] #[derive(Clone, Debug)] -pub struct RetrievePresetParams { +pub struct RetrievePresetParams<'p> { /// The ID of the preset to retrieve. - pub preset_id: String, + pub preset_id: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`upsert_preset`] #[derive(Clone, Debug)] -pub struct UpsertPresetParams { +pub struct UpsertPresetParams<'p> { /// The name of the preset set to upsert. - pub preset_id: String, + pub preset_id: Cow<'p, str>, /// The stopwords set to upsert. - pub preset_upsert_schema: models::PresetUpsertSchema, + pub preset_upsert_schema: models::PresetUpsertSchema<'p>, + pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`delete_preset`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeletePresetError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum DeletePresetError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_all_presets`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveAllPresetsError { - UnknownValue(serde_json::Value), +pub enum RetrieveAllPresetsError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_preset`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrievePresetError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum RetrievePresetError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`upsert_preset`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertPresetError { - Status400(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum UpsertPresetError<'a> { + Status400(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// Permanently deletes a preset, given it's name. pub async fn delete_preset( configuration: &configuration::Configuration, - params: &DeletePresetParams, -) -> Result> { + params: &DeletePresetParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/presets/{presetId}", configuration.base_path, @@ -133,7 +153,7 @@ pub async fn delete_preset( /// Retrieve the details of all presets pub async fn retrieve_all_presets( configuration: &configuration::Configuration, -) -> Result> { +) -> Result, Error>> { let uri_str = format!("{}/presets", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -189,8 +209,8 @@ pub async fn retrieve_all_presets( /// Retrieve the details of a preset, given it's name. pub async fn retrieve_preset( configuration: &configuration::Configuration, - params: &RetrievePresetParams, -) -> Result> { + params: &RetrievePresetParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/presets/{presetId}", configuration.base_path, @@ -250,8 +270,8 @@ pub async fn retrieve_preset( /// Create or update an existing preset. pub async fn upsert_preset( configuration: &configuration::Configuration, - params: &UpsertPresetParams, -) -> Result> { + params: &UpsertPresetParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/presets/{presetId}", configuration.base_path, diff --git a/typesense_codegen/src/apis/stemming_api.rs b/typesense_codegen/src/apis/stemming_api.rs index de8470f8..f5363838 100644 --- a/typesense_codegen/src/apis/stemming_api.rs +++ b/typesense_codegen/src/apis/stemming_api.rs @@ -10,53 +10,68 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; +use ::std::{borrow::Cow, marker::PhantomData}; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; /// struct for passing parameters to the method [`get_stemming_dictionary`] #[derive(Clone, Debug)] -pub struct GetStemmingDictionaryParams { +pub struct GetStemmingDictionaryParams<'p> { /// The ID of the dictionary to retrieve - pub dictionary_id: String, + pub dictionary_id: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`import_stemming_dictionary`] #[derive(Clone, Debug)] -pub struct ImportStemmingDictionaryParams { +pub struct ImportStemmingDictionaryParams<'p> { /// The ID to assign to the dictionary - pub id: String, + pub id: Cow<'p, str>, /// The JSONL file containing word mappings - pub body: String, + pub body: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`get_stemming_dictionary`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetStemmingDictionaryError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum GetStemmingDictionaryError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`import_stemming_dictionary`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum ImportStemmingDictionaryError { - Status400(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum ImportStemmingDictionaryError<'a> { + Status400(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`list_stemming_dictionaries`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum ListStemmingDictionariesError { - UnknownValue(serde_json::Value), +pub enum ListStemmingDictionariesError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// Fetch details of a specific stemming dictionary. pub async fn get_stemming_dictionary( configuration: &configuration::Configuration, - params: &GetStemmingDictionaryParams, -) -> Result> { + params: &GetStemmingDictionaryParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/stemming/dictionaries/{dictionaryId}", configuration.base_path, @@ -116,8 +131,8 @@ pub async fn get_stemming_dictionary( /// Upload a JSONL file containing word mappings to create or update a stemming dictionary. pub async fn import_stemming_dictionary( configuration: &configuration::Configuration, - params: &ImportStemmingDictionaryParams, -) -> Result> { + params: &ImportStemmingDictionaryParams<'_>, +) -> Result>> { let uri_str = format!("{}/stemming/dictionaries/import", configuration.base_path); let mut req_builder = configuration .client @@ -137,7 +152,7 @@ pub async fn import_stemming_dictionary( }; req_builder = req_builder .header(reqwest::header::CONTENT_TYPE, "text/plain") - .body(params.body.to_owned()); + .body(params.body.clone().into_owned()); let req = req_builder.build()?; let resp = configuration.client.execute(req).await?; @@ -174,7 +189,10 @@ pub async fn import_stemming_dictionary( /// Retrieve a list of all available stemming dictionaries. pub async fn list_stemming_dictionaries( configuration: &configuration::Configuration, -) -> Result> { +) -> Result< + models::ListStemmingDictionaries200Response<'static>, + Error>, +> { let uri_str = format!("{}/stemming/dictionaries", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); diff --git a/typesense_codegen/src/apis/stopwords_api.rs b/typesense_codegen/src/apis/stopwords_api.rs index 76c120be..a0c67331 100644 --- a/typesense_codegen/src/apis/stopwords_api.rs +++ b/typesense_codegen/src/apis/stopwords_api.rs @@ -10,68 +10,89 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; +use ::std::{borrow::Cow, marker::PhantomData}; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; /// struct for passing parameters to the method [`delete_stopwords_set`] #[derive(Clone, Debug)] -pub struct DeleteStopwordsSetParams { +pub struct DeleteStopwordsSetParams<'p> { /// The ID of the stopwords set to delete. - pub set_id: String, + pub set_id: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_stopwords_set`] #[derive(Clone, Debug)] -pub struct RetrieveStopwordsSetParams { +pub struct RetrieveStopwordsSetParams<'p> { /// The ID of the stopwords set to retrieve. - pub set_id: String, + pub set_id: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`upsert_stopwords_set`] #[derive(Clone, Debug)] -pub struct UpsertStopwordsSetParams { +pub struct UpsertStopwordsSetParams<'p> { /// The ID of the stopwords set to upsert. - pub set_id: String, + pub set_id: Cow<'p, str>, /// The stopwords set to upsert. - pub stopwords_set_upsert_schema: models::StopwordsSetUpsertSchema, + pub stopwords_set_upsert_schema: models::StopwordsSetUpsertSchema<'p>, + pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`delete_stopwords_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteStopwordsSetError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum DeleteStopwordsSetError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_stopwords_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveStopwordsSetError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum RetrieveStopwordsSetError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_stopwords_sets`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveStopwordsSetsError { - UnknownValue(serde_json::Value), +pub enum RetrieveStopwordsSetsError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`upsert_stopwords_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertStopwordsSetError { - Status400(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum UpsertStopwordsSetError<'a> { + Status400(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// Permanently deletes a stopwords set, given it's name. pub async fn delete_stopwords_set( configuration: &configuration::Configuration, - params: &DeleteStopwordsSetParams, -) -> Result> { + params: &DeleteStopwordsSetParams<'_>, +) -> Result, Error>> +{ let uri_str = format!( "{}/stopwords/{setId}", configuration.base_path, @@ -133,8 +154,9 @@ pub async fn delete_stopwords_set( /// Retrieve the details of a stopwords set, given it's name. pub async fn retrieve_stopwords_set( configuration: &configuration::Configuration, - params: &RetrieveStopwordsSetParams, -) -> Result> { + params: &RetrieveStopwordsSetParams<'_>, +) -> Result, Error>> +{ let uri_str = format!( "{}/stopwords/{setId}", configuration.base_path, @@ -194,7 +216,10 @@ pub async fn retrieve_stopwords_set( /// Retrieve the details of all stopwords sets pub async fn retrieve_stopwords_sets( configuration: &configuration::Configuration, -) -> Result> { +) -> Result< + models::StopwordsSetsRetrieveAllSchema<'static>, + Error>, +> { let uri_str = format!("{}/stopwords", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -250,8 +275,8 @@ pub async fn retrieve_stopwords_sets( /// When an analytics rule is created, we give it a name and describe the type, the source collections and the destination collection. pub async fn upsert_stopwords_set( configuration: &configuration::Configuration, - params: &UpsertStopwordsSetParams, -) -> Result> { + params: &UpsertStopwordsSetParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/stopwords/{setId}", configuration.base_path, diff --git a/typesense_codegen/src/apis/synonyms_api.rs b/typesense_codegen/src/apis/synonyms_api.rs index 53d5cbb9..10ee3981 100644 --- a/typesense_codegen/src/apis/synonyms_api.rs +++ b/typesense_codegen/src/apis/synonyms_api.rs @@ -10,136 +10,176 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; +use ::std::{borrow::Cow, marker::PhantomData}; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; /// struct for passing parameters to the method [`delete_synonym_set`] #[derive(Clone, Debug)] -pub struct DeleteSynonymSetParams { +pub struct DeleteSynonymSetParams<'p> { /// The name of the synonym set to delete - pub synonym_set_name: String, + pub synonym_set_name: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_synonym_set_item`] #[derive(Clone, Debug)] -pub struct DeleteSynonymSetItemParams { +pub struct DeleteSynonymSetItemParams<'p> { /// The name of the synonym set - pub synonym_set_name: String, + pub synonym_set_name: Cow<'p, str>, /// The id of the synonym item to delete - pub item_id: String, + pub item_id: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_synonym_set`] #[derive(Clone, Debug)] -pub struct RetrieveSynonymSetParams { +pub struct RetrieveSynonymSetParams<'p> { /// The name of the synonym set to retrieve - pub synonym_set_name: String, + pub synonym_set_name: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_synonym_set_item`] #[derive(Clone, Debug)] -pub struct RetrieveSynonymSetItemParams { +pub struct RetrieveSynonymSetItemParams<'p> { /// The name of the synonym set - pub synonym_set_name: String, + pub synonym_set_name: Cow<'p, str>, /// The id of the synonym item to retrieve - pub item_id: String, + pub item_id: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_synonym_set_items`] #[derive(Clone, Debug)] -pub struct RetrieveSynonymSetItemsParams { +pub struct RetrieveSynonymSetItemsParams<'p> { /// The name of the synonym set to retrieve items for - pub synonym_set_name: String, + pub synonym_set_name: Cow<'p, str>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`upsert_synonym_set`] #[derive(Clone, Debug)] -pub struct UpsertSynonymSetParams { +pub struct UpsertSynonymSetParams<'p> { /// The name of the synonym set to create/update - pub synonym_set_name: String, + pub synonym_set_name: Cow<'p, str>, /// The synonym set to be created/updated - pub synonym_set_create_schema: models::SynonymSetCreateSchema, + pub synonym_set_create_schema: models::SynonymSetCreateSchema<'p>, + pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`upsert_synonym_set_item`] #[derive(Clone, Debug)] -pub struct UpsertSynonymSetItemParams { +pub struct UpsertSynonymSetItemParams<'p> { /// The name of the synonym set - pub synonym_set_name: String, + pub synonym_set_name: Cow<'p, str>, /// The id of the synonym item to upsert - pub item_id: String, + pub item_id: Cow<'p, str>, /// The synonym item to be created/updated - pub synonym_item_schema: models::SynonymItemSchema, + pub synonym_item_schema: models::SynonymItemSchema<'p>, + pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`delete_synonym_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteSynonymSetError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum DeleteSynonymSetError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`delete_synonym_set_item`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteSynonymSetItemError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum DeleteSynonymSetItemError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_synonym_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveSynonymSetError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum RetrieveSynonymSetError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_synonym_set_item`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveSynonymSetItemError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum RetrieveSynonymSetItemError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_synonym_set_items`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveSynonymSetItemsError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum RetrieveSynonymSetItemsError<'a> { + Status404(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`retrieve_synonym_sets`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveSynonymSetsError { - UnknownValue(serde_json::Value), +pub enum RetrieveSynonymSetsError<'a> { + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`upsert_synonym_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertSynonymSetError { - Status400(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum UpsertSynonymSetError<'a> { + Status400(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// struct for typed errors of method [`upsert_synonym_set_item`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertSynonymSetItemError { - Status400(models::ApiResponse), - UnknownValue(serde_json::Value), +pub enum UpsertSynonymSetItemError<'a> { + Status400(models::ApiResponse<'a>), + UnknownValue { + value: serde_json::Value, + #[serde(skip)] + _phantom: PhantomData<&'a ()>, + }, } /// Delete a specific synonym set by its name pub async fn delete_synonym_set( configuration: &configuration::Configuration, - params: &DeleteSynonymSetParams, -) -> Result> { + params: &DeleteSynonymSetParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}", configuration.base_path, @@ -201,8 +241,8 @@ pub async fn delete_synonym_set( /// Delete a specific synonym item by its id pub async fn delete_synonym_set_item( configuration: &configuration::Configuration, - params: &DeleteSynonymSetItemParams, -) -> Result> { + params: &DeleteSynonymSetItemParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}/items/{itemId}", configuration.base_path, @@ -265,8 +305,8 @@ pub async fn delete_synonym_set_item( /// Retrieve a specific synonym set by its name pub async fn retrieve_synonym_set( configuration: &configuration::Configuration, - params: &RetrieveSynonymSetParams, -) -> Result> { + params: &RetrieveSynonymSetParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}", configuration.base_path, @@ -326,8 +366,8 @@ pub async fn retrieve_synonym_set( /// Retrieve a specific synonym item by its id pub async fn retrieve_synonym_set_item( configuration: &configuration::Configuration, - params: &RetrieveSynonymSetItemParams, -) -> Result> { + params: &RetrieveSynonymSetItemParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}/items/{itemId}", configuration.base_path, @@ -388,8 +428,8 @@ pub async fn retrieve_synonym_set_item( /// Retrieve all synonym items in a set pub async fn retrieve_synonym_set_items( configuration: &configuration::Configuration, - params: &RetrieveSynonymSetItemsParams, -) -> Result, Error> { + params: &RetrieveSynonymSetItemsParams<'_>, +) -> Result>, Error>> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}/items", configuration.base_path, @@ -449,7 +489,7 @@ pub async fn retrieve_synonym_set_items( /// Retrieve all synonym sets pub async fn retrieve_synonym_sets( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result>, Error>> { let uri_str = format!("{}/synonym_sets", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -505,8 +545,8 @@ pub async fn retrieve_synonym_sets( /// Create or update a synonym set with the given name pub async fn upsert_synonym_set( configuration: &configuration::Configuration, - params: &UpsertSynonymSetParams, -) -> Result> { + params: &UpsertSynonymSetParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}", configuration.base_path, @@ -567,8 +607,8 @@ pub async fn upsert_synonym_set( /// Create or update a synonym set item with the given id pub async fn upsert_synonym_set_item( configuration: &configuration::Configuration, - params: &UpsertSynonymSetItemParams, -) -> Result> { + params: &UpsertSynonymSetItemParams<'_>, +) -> Result, Error>> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}/items/{itemId}", configuration.base_path, diff --git a/typesense_codegen/src/models/analytics_event.rs b/typesense_codegen/src/models/analytics_event.rs index 7ab05e0e..fe6617a3 100644 --- a/typesense_codegen/src/models/analytics_event.rs +++ b/typesense_codegen/src/models/analytics_event.rs @@ -9,30 +9,34 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AnalyticsEvent { +pub struct AnalyticsEvent<'a> { /// Name of the analytics rule this event corresponds to #[serde(rename = "name")] - pub name: String, + pub name: Cow<'a, str>, /// Type of event (e.g., click, conversion, query, visit) #[serde(rename = "event_type")] - pub event_type: String, + pub event_type: Cow<'a, str>, #[serde(rename = "data")] - pub data: Box, + pub data: Box>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl AnalyticsEvent { +impl<'a> AnalyticsEvent<'a> { pub fn new( - name: String, - event_type: String, - data: models::AnalyticsEventData, - ) -> AnalyticsEvent { - AnalyticsEvent { + name: Cow<'a, str>, + event_type: Cow<'a, str>, + data: models::AnalyticsEventData<'a>, + ) -> Self { + Self { name, event_type, data: Box::new(data), + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/analytics_event_create_response.rs b/typesense_codegen/src/models/analytics_event_create_response.rs index 20182909..ec776abd 100644 --- a/typesense_codegen/src/models/analytics_event_create_response.rs +++ b/typesense_codegen/src/models/analytics_event_create_response.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AnalyticsEventCreateResponse { +pub struct AnalyticsEventCreateResponse<'a> { #[serde(rename = "ok")] pub ok: bool, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl AnalyticsEventCreateResponse { - pub fn new(ok: bool) -> AnalyticsEventCreateResponse { - AnalyticsEventCreateResponse { ok } +impl<'a> AnalyticsEventCreateResponse<'a> { + pub fn new(ok: bool) -> Self { + Self { + ok, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/analytics_event_data.rs b/typesense_codegen/src/models/analytics_event_data.rs index 7c282411..75b536e7 100644 --- a/typesense_codegen/src/models/analytics_event_data.rs +++ b/typesense_codegen/src/models/analytics_event_data.rs @@ -9,32 +9,36 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; /// AnalyticsEventData : Event payload #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AnalyticsEventData { +pub struct AnalyticsEventData<'a> { #[serde(rename = "user_id", skip_serializing_if = "Option::is_none")] - pub user_id: Option, + pub user_id: Option>, #[serde(rename = "doc_id", skip_serializing_if = "Option::is_none")] - pub doc_id: Option, + pub doc_id: Option>, #[serde(rename = "doc_ids", skip_serializing_if = "Option::is_none")] pub doc_ids: Option>, #[serde(rename = "q", skip_serializing_if = "Option::is_none")] - pub q: Option, + pub q: Option>, #[serde(rename = "analytics_tag", skip_serializing_if = "Option::is_none")] - pub analytics_tag: Option, + pub analytics_tag: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl AnalyticsEventData { +impl<'a> AnalyticsEventData<'a> { /// Event payload - pub fn new() -> AnalyticsEventData { - AnalyticsEventData { + pub fn new() -> Self { + Self { user_id: None, doc_id: None, doc_ids: None, q: None, analytics_tag: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/analytics_events_response.rs b/typesense_codegen/src/models/analytics_events_response.rs index a0de4e05..f50647ed 100644 --- a/typesense_codegen/src/models/analytics_events_response.rs +++ b/typesense_codegen/src/models/analytics_events_response.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AnalyticsEventsResponse { +pub struct AnalyticsEventsResponse<'a> { #[serde(rename = "events")] - pub events: Vec, + pub events: Vec>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl AnalyticsEventsResponse { - pub fn new(events: Vec) -> AnalyticsEventsResponse { - AnalyticsEventsResponse { events } +impl<'a> AnalyticsEventsResponse<'a> { + pub fn new(events: Vec>) -> Self { + Self { + events, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/analytics_events_response_events_inner.rs b/typesense_codegen/src/models/analytics_events_response_events_inner.rs index 9744a202..042edea0 100644 --- a/typesense_codegen/src/models/analytics_events_response_events_inner.rs +++ b/typesense_codegen/src/models/analytics_events_response_events_inner.rs @@ -9,31 +9,34 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AnalyticsEventsResponseEventsInner { +pub struct AnalyticsEventsResponseEventsInner<'a> { #[serde(rename = "name", skip_serializing_if = "Option::is_none")] - pub name: Option, + pub name: Option>, #[serde(rename = "event_type", skip_serializing_if = "Option::is_none")] - pub event_type: Option, + pub event_type: Option>, #[serde(rename = "collection", skip_serializing_if = "Option::is_none")] - pub collection: Option, + pub collection: Option>, #[serde(rename = "timestamp", skip_serializing_if = "Option::is_none")] pub timestamp: Option, #[serde(rename = "user_id", skip_serializing_if = "Option::is_none")] - pub user_id: Option, + pub user_id: Option>, #[serde(rename = "doc_id", skip_serializing_if = "Option::is_none")] - pub doc_id: Option, + pub doc_id: Option>, #[serde(rename = "doc_ids", skip_serializing_if = "Option::is_none")] pub doc_ids: Option>, #[serde(rename = "query", skip_serializing_if = "Option::is_none")] - pub query: Option, + pub query: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl AnalyticsEventsResponseEventsInner { - pub fn new() -> AnalyticsEventsResponseEventsInner { - AnalyticsEventsResponseEventsInner { +impl<'a> AnalyticsEventsResponseEventsInner<'a> { + pub fn new() -> Self { + Self { name: None, event_type: None, collection: None, @@ -42,6 +45,7 @@ impl AnalyticsEventsResponseEventsInner { doc_id: None, doc_ids: None, query: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/analytics_rule.rs b/typesense_codegen/src/models/analytics_rule.rs index 4c011970..809e8fda 100644 --- a/typesense_codegen/src/models/analytics_rule.rs +++ b/typesense_codegen/src/models/analytics_rule.rs @@ -9,38 +9,42 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AnalyticsRule { +pub struct AnalyticsRule<'a> { #[serde(rename = "name")] - pub name: String, + pub name: Cow<'a, str>, #[serde(rename = "type")] pub r#type: Type, #[serde(rename = "collection")] - pub collection: String, + pub collection: Cow<'a, str>, #[serde(rename = "event_type")] - pub event_type: String, + pub event_type: Cow<'a, str>, #[serde(rename = "rule_tag", skip_serializing_if = "Option::is_none")] - pub rule_tag: Option, + pub rule_tag: Option>, #[serde(rename = "params", skip_serializing_if = "Option::is_none")] - pub params: Option>, + pub params: Option>>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl AnalyticsRule { +impl<'a> AnalyticsRule<'a> { pub fn new( - name: String, + name: Cow<'a, str>, r#type: Type, - collection: String, - event_type: String, - ) -> AnalyticsRule { - AnalyticsRule { + collection: Cow<'a, str>, + event_type: Cow<'a, str>, + ) -> Self { + Self { name, r#type, collection, event_type, rule_tag: None, params: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/analytics_rule_create.rs b/typesense_codegen/src/models/analytics_rule_create.rs index b9f8993c..39cfdc91 100644 --- a/typesense_codegen/src/models/analytics_rule_create.rs +++ b/typesense_codegen/src/models/analytics_rule_create.rs @@ -9,38 +9,42 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AnalyticsRuleCreate { +pub struct AnalyticsRuleCreate<'a> { #[serde(rename = "name")] - pub name: String, + pub name: Cow<'a, str>, #[serde(rename = "type")] pub r#type: Type, #[serde(rename = "collection")] - pub collection: String, + pub collection: Cow<'a, str>, #[serde(rename = "event_type")] - pub event_type: String, + pub event_type: Cow<'a, str>, #[serde(rename = "rule_tag", skip_serializing_if = "Option::is_none")] - pub rule_tag: Option, + pub rule_tag: Option>, #[serde(rename = "params", skip_serializing_if = "Option::is_none")] - pub params: Option>, + pub params: Option>>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl AnalyticsRuleCreate { +impl<'a> AnalyticsRuleCreate<'a> { pub fn new( - name: String, + name: Cow<'a, str>, r#type: Type, - collection: String, - event_type: String, - ) -> AnalyticsRuleCreate { - AnalyticsRuleCreate { + collection: Cow<'a, str>, + event_type: Cow<'a, str>, + ) -> Self { + Self { name, r#type, collection, event_type, rule_tag: None, params: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/analytics_rule_create_params.rs b/typesense_codegen/src/models/analytics_rule_create_params.rs index 6127dd32..1ead1648 100644 --- a/typesense_codegen/src/models/analytics_rule_create_params.rs +++ b/typesense_codegen/src/models/analytics_rule_create_params.rs @@ -9,15 +9,16 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AnalyticsRuleCreateParams { +pub struct AnalyticsRuleCreateParams<'a> { #[serde( rename = "destination_collection", skip_serializing_if = "Option::is_none" )] - pub destination_collection: Option, + pub destination_collection: Option>, #[serde(rename = "limit", skip_serializing_if = "Option::is_none")] pub limit: Option, #[serde( @@ -30,14 +31,16 @@ pub struct AnalyticsRuleCreateParams { #[serde(rename = "expand_query", skip_serializing_if = "Option::is_none")] pub expand_query: Option, #[serde(rename = "counter_field", skip_serializing_if = "Option::is_none")] - pub counter_field: Option, + pub counter_field: Option>, #[serde(rename = "weight", skip_serializing_if = "Option::is_none")] pub weight: Option, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl AnalyticsRuleCreateParams { - pub fn new() -> AnalyticsRuleCreateParams { - AnalyticsRuleCreateParams { +impl<'a> AnalyticsRuleCreateParams<'a> { + pub fn new() -> Self { + Self { destination_collection: None, limit: None, capture_search_requests: None, @@ -45,6 +48,7 @@ impl AnalyticsRuleCreateParams { expand_query: None, counter_field: None, weight: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/analytics_rule_update.rs b/typesense_codegen/src/models/analytics_rule_update.rs index 3a42cc4f..603ec796 100644 --- a/typesense_codegen/src/models/analytics_rule_update.rs +++ b/typesense_codegen/src/models/analytics_rule_update.rs @@ -9,26 +9,30 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; /// AnalyticsRuleUpdate : Fields allowed to update on an analytics rule #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AnalyticsRuleUpdate { +pub struct AnalyticsRuleUpdate<'a> { #[serde(rename = "name", skip_serializing_if = "Option::is_none")] - pub name: Option, + pub name: Option>, #[serde(rename = "rule_tag", skip_serializing_if = "Option::is_none")] - pub rule_tag: Option, + pub rule_tag: Option>, #[serde(rename = "params", skip_serializing_if = "Option::is_none")] - pub params: Option>, + pub params: Option>>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl AnalyticsRuleUpdate { +impl<'a> AnalyticsRuleUpdate<'a> { /// Fields allowed to update on an analytics rule - pub fn new() -> AnalyticsRuleUpdate { - AnalyticsRuleUpdate { + pub fn new() -> Self { + Self { name: None, rule_tag: None, params: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/analytics_status.rs b/typesense_codegen/src/models/analytics_status.rs index ee3f1516..81096011 100644 --- a/typesense_codegen/src/models/analytics_status.rs +++ b/typesense_codegen/src/models/analytics_status.rs @@ -9,10 +9,11 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AnalyticsStatus { +pub struct AnalyticsStatus<'a> { #[serde( rename = "popular_prefix_queries", skip_serializing_if = "Option::is_none" @@ -36,11 +37,13 @@ pub struct AnalyticsStatus { pub doc_log_events: Option, #[serde(rename = "doc_counter_events", skip_serializing_if = "Option::is_none")] pub doc_counter_events: Option, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl AnalyticsStatus { - pub fn new() -> AnalyticsStatus { - AnalyticsStatus { +impl<'a> AnalyticsStatus<'a> { + pub fn new() -> Self { + Self { popular_prefix_queries: None, nohits_prefix_queries: None, log_prefix_queries: None, @@ -48,6 +51,7 @@ impl AnalyticsStatus { query_counter_events: None, doc_log_events: None, doc_counter_events: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/api_key.rs b/typesense_codegen/src/models/api_key.rs index 511f8b9d..ffe460bc 100644 --- a/typesense_codegen/src/models/api_key.rs +++ b/typesense_codegen/src/models/api_key.rs @@ -9,14 +9,15 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ApiKey { +pub struct ApiKey<'a> { #[serde(rename = "value", skip_serializing_if = "Option::is_none")] - pub value: Option, + pub value: Option>, #[serde(rename = "description")] - pub description: String, + pub description: Cow<'a, str>, #[serde(rename = "actions")] pub actions: Vec, #[serde(rename = "collections")] @@ -26,12 +27,14 @@ pub struct ApiKey { #[serde(rename = "id", skip_serializing_if = "Option::is_none")] pub id: Option, #[serde(rename = "value_prefix", skip_serializing_if = "Option::is_none")] - pub value_prefix: Option, + pub value_prefix: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl ApiKey { - pub fn new(description: String, actions: Vec, collections: Vec) -> ApiKey { - ApiKey { +impl<'a> ApiKey<'a> { + pub fn new(description: Cow<'a, str>, actions: Vec, collections: Vec) -> Self { + Self { value: None, description, actions, @@ -39,6 +42,7 @@ impl ApiKey { expires_at: None, id: None, value_prefix: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/api_key_delete_response.rs b/typesense_codegen/src/models/api_key_delete_response.rs index b9b453eb..e7c501cd 100644 --- a/typesense_codegen/src/models/api_key_delete_response.rs +++ b/typesense_codegen/src/models/api_key_delete_response.rs @@ -9,17 +9,23 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ApiKeyDeleteResponse { +pub struct ApiKeyDeleteResponse<'a> { /// The id of the API key that was deleted #[serde(rename = "id")] pub id: i64, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl ApiKeyDeleteResponse { - pub fn new(id: i64) -> ApiKeyDeleteResponse { - ApiKeyDeleteResponse { id } +impl<'a> ApiKeyDeleteResponse<'a> { + pub fn new(id: i64) -> Self { + Self { + id, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/api_key_schema.rs b/typesense_codegen/src/models/api_key_schema.rs index 095e5ec4..a3ff5463 100644 --- a/typesense_codegen/src/models/api_key_schema.rs +++ b/typesense_codegen/src/models/api_key_schema.rs @@ -9,34 +9,34 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ApiKeySchema { +pub struct ApiKeySchema<'a> { #[serde(rename = "value", skip_serializing_if = "Option::is_none")] - pub value: Option, + pub value: Option>, #[serde(rename = "description")] - pub description: String, + pub description: Cow<'a, str>, #[serde(rename = "actions")] pub actions: Vec, #[serde(rename = "collections")] pub collections: Vec, #[serde(rename = "expires_at", skip_serializing_if = "Option::is_none")] pub expires_at: Option, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl ApiKeySchema { - pub fn new( - description: String, - actions: Vec, - collections: Vec, - ) -> ApiKeySchema { - ApiKeySchema { +impl<'a> ApiKeySchema<'a> { + pub fn new(description: Cow<'a, str>, actions: Vec, collections: Vec) -> Self { + Self { value: None, description, actions, collections, expires_at: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/api_keys_response.rs b/typesense_codegen/src/models/api_keys_response.rs index 784a6bfc..3844ca97 100644 --- a/typesense_codegen/src/models/api_keys_response.rs +++ b/typesense_codegen/src/models/api_keys_response.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ApiKeysResponse { +pub struct ApiKeysResponse<'a> { #[serde(rename = "keys")] - pub keys: Vec, + pub keys: Vec>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl ApiKeysResponse { - pub fn new(keys: Vec) -> ApiKeysResponse { - ApiKeysResponse { keys } +impl<'a> ApiKeysResponse<'a> { + pub fn new(keys: Vec>) -> Self { + Self { + keys, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/api_response.rs b/typesense_codegen/src/models/api_response.rs index 0a27c4f9..eb5910b8 100644 --- a/typesense_codegen/src/models/api_response.rs +++ b/typesense_codegen/src/models/api_response.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ApiResponse { +pub struct ApiResponse<'a> { #[serde(rename = "message")] - pub message: String, + pub message: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl ApiResponse { - pub fn new(message: String) -> ApiResponse { - ApiResponse { message } +impl<'a> ApiResponse<'a> { + pub fn new(message: Cow<'a, str>) -> Self { + Self { + message, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/api_stats_response.rs b/typesense_codegen/src/models/api_stats_response.rs index c35c77ad..3013c114 100644 --- a/typesense_codegen/src/models/api_stats_response.rs +++ b/typesense_codegen/src/models/api_stats_response.rs @@ -9,10 +9,11 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ApiStatsResponse { +pub struct ApiStatsResponse<'a> { #[serde(rename = "delete_latency_ms", skip_serializing_if = "Option::is_none")] pub delete_latency_ms: Option, #[serde( @@ -63,11 +64,13 @@ pub struct ApiStatsResponse { skip_serializing_if = "Option::is_none" )] pub write_requests_per_second: Option, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl ApiStatsResponse { - pub fn new() -> ApiStatsResponse { - ApiStatsResponse { +impl<'a> ApiStatsResponse<'a> { + pub fn new() -> Self { + Self { delete_latency_ms: None, delete_requests_per_second: None, import_latency_ms: None, @@ -81,6 +84,7 @@ impl ApiStatsResponse { total_requests_per_second: None, write_latency_ms: None, write_requests_per_second: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/collection_alias.rs b/typesense_codegen/src/models/collection_alias.rs index b5a61fe6..957a6076 100644 --- a/typesense_codegen/src/models/collection_alias.rs +++ b/typesense_codegen/src/models/collection_alias.rs @@ -9,23 +9,27 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CollectionAlias { +pub struct CollectionAlias<'a> { /// Name of the collection alias #[serde(rename = "name")] - pub name: String, + pub name: Cow<'a, str>, /// Name of the collection the alias mapped to #[serde(rename = "collection_name")] - pub collection_name: String, + pub collection_name: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CollectionAlias { - pub fn new(name: String, collection_name: String) -> CollectionAlias { - CollectionAlias { +impl<'a> CollectionAlias<'a> { + pub fn new(name: Cow<'a, str>, collection_name: Cow<'a, str>) -> Self { + Self { name, collection_name, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/collection_alias_schema.rs b/typesense_codegen/src/models/collection_alias_schema.rs index b35d641e..6f441ea4 100644 --- a/typesense_codegen/src/models/collection_alias_schema.rs +++ b/typesense_codegen/src/models/collection_alias_schema.rs @@ -9,17 +9,23 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CollectionAliasSchema { +pub struct CollectionAliasSchema<'a> { /// Name of the collection you wish to map the alias to #[serde(rename = "collection_name")] - pub collection_name: String, + pub collection_name: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CollectionAliasSchema { - pub fn new(collection_name: String) -> CollectionAliasSchema { - CollectionAliasSchema { collection_name } +impl<'a> CollectionAliasSchema<'a> { + pub fn new(collection_name: Cow<'a, str>) -> Self { + Self { + collection_name, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/collection_aliases_response.rs b/typesense_codegen/src/models/collection_aliases_response.rs index 3cf2d252..55a45fd2 100644 --- a/typesense_codegen/src/models/collection_aliases_response.rs +++ b/typesense_codegen/src/models/collection_aliases_response.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CollectionAliasesResponse { +pub struct CollectionAliasesResponse<'a> { #[serde(rename = "aliases")] - pub aliases: Vec, + pub aliases: Vec>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CollectionAliasesResponse { - pub fn new(aliases: Vec) -> CollectionAliasesResponse { - CollectionAliasesResponse { aliases } +impl<'a> CollectionAliasesResponse<'a> { + pub fn new(aliases: Vec>) -> Self { + Self { + aliases, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/collection_response.rs b/typesense_codegen/src/models/collection_response.rs index 1039909f..4bd20f9b 100644 --- a/typesense_codegen/src/models/collection_response.rs +++ b/typesense_codegen/src/models/collection_response.rs @@ -9,22 +9,23 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CollectionResponse { +pub struct CollectionResponse<'a> { /// Name of the collection #[serde(rename = "name")] - pub name: String, + pub name: Cow<'a, str>, /// A list of fields for querying, filtering and faceting #[serde(rename = "fields")] - pub fields: Vec, + pub fields: Vec>, /// The name of an int32 / float field that determines the order in which the search results are ranked when a sort_by clause is not provided during searching. This field must indicate some kind of popularity. #[serde( rename = "default_sorting_field", skip_serializing_if = "Option::is_none" )] - pub default_sorting_field: Option, + pub default_sorting_field: Option>, /// List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters. #[serde(rename = "token_separators", skip_serializing_if = "Option::is_none")] pub token_separators: Option>, @@ -41,7 +42,7 @@ pub struct CollectionResponse { #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] pub symbols_to_index: Option>, #[serde(rename = "voice_query_model", skip_serializing_if = "Option::is_none")] - pub voice_query_model: Option>, + pub voice_query_model: Option>>, /// Optional details about the collection, e.g., when it was created, who created it etc. #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] pub metadata: Option, @@ -51,16 +52,18 @@ pub struct CollectionResponse { /// Timestamp of when the collection was created (Unix epoch in seconds) #[serde(rename = "created_at")] pub created_at: i64, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CollectionResponse { +impl<'a> CollectionResponse<'a> { pub fn new( - name: String, - fields: Vec, + name: Cow<'a, str>, + fields: Vec>, num_documents: i64, created_at: i64, - ) -> CollectionResponse { - CollectionResponse { + ) -> Self { + Self { name, fields, default_sorting_field: None, @@ -72,6 +75,7 @@ impl CollectionResponse { metadata: None, num_documents, created_at, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/collection_schema.rs b/typesense_codegen/src/models/collection_schema.rs index 703febef..d8224445 100644 --- a/typesense_codegen/src/models/collection_schema.rs +++ b/typesense_codegen/src/models/collection_schema.rs @@ -9,26 +9,26 @@ */ use crate::models; -use ::std::borrow::Cow; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(bon::Builder)] #[builder(on(Cow<'_, str>, into))] #[builder(on(String, into))] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CollectionSchema { +pub struct CollectionSchema<'a> { /// Name of the collection #[serde(rename = "name")] - pub name: Cow<'static, str>, + pub name: Cow<'a, str>, /// A list of fields for querying, filtering and faceting #[serde(rename = "fields")] - pub fields: Vec, + pub fields: Vec>, /// The name of an int32 / float field that determines the order in which the search results are ranked when a sort_by clause is not provided during searching. This field must indicate some kind of popularity. #[serde( rename = "default_sorting_field", skip_serializing_if = "Option::is_none" )] - pub default_sorting_field: Option, + pub default_sorting_field: Option>, /// List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters. #[serde(rename = "token_separators", skip_serializing_if = "Option::is_none")] pub token_separators: Option>, @@ -45,16 +45,19 @@ pub struct CollectionSchema { #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] pub symbols_to_index: Option>, #[serde(rename = "voice_query_model", skip_serializing_if = "Option::is_none")] - pub voice_query_model: Option>, + pub voice_query_model: Option>>, /// Optional details about the collection, e.g., when it was created, who created it etc. #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] pub metadata: Option, + #[serde(skip)] + #[builder(default)] + pub _phantom: PhantomData<&'a ()>, } -impl CollectionSchema { - pub fn new(name: impl Into>, fields: Vec) -> CollectionSchema { - CollectionSchema { - name: name.into(), +impl<'a> CollectionSchema<'a> { + pub fn new(name: Cow<'a, str>, fields: Vec>) -> Self { + Self { + name, fields, default_sorting_field: None, token_separators: None, @@ -63,6 +66,7 @@ impl CollectionSchema { symbols_to_index: None, voice_query_model: None, metadata: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/collection_update_schema.rs b/typesense_codegen/src/models/collection_update_schema.rs index 27a4d098..be5b7503 100644 --- a/typesense_codegen/src/models/collection_update_schema.rs +++ b/typesense_codegen/src/models/collection_update_schema.rs @@ -9,27 +9,31 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CollectionUpdateSchema { +pub struct CollectionUpdateSchema<'a> { /// A list of fields for querying, filtering and faceting #[serde(rename = "fields")] - pub fields: Vec, + pub fields: Vec>, /// List of synonym set names to associate with this collection #[serde(rename = "synonym_sets", skip_serializing_if = "Option::is_none")] pub synonym_sets: Option>, /// Optional details about the collection, e.g., when it was created, who created it etc. #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] pub metadata: Option, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CollectionUpdateSchema { - pub fn new(fields: Vec) -> CollectionUpdateSchema { - CollectionUpdateSchema { +impl<'a> CollectionUpdateSchema<'a> { + pub fn new(fields: Vec>) -> Self { + Self { fields, synonym_sets: None, metadata: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/conversation_model_create_schema.rs b/typesense_codegen/src/models/conversation_model_create_schema.rs index fc587c3f..0ac56ec0 100644 --- a/typesense_codegen/src/models/conversation_model_create_schema.rs +++ b/typesense_codegen/src/models/conversation_model_create_schema.rs @@ -9,28 +9,29 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ConversationModelCreateSchema { +pub struct ConversationModelCreateSchema<'a> { /// An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - pub id: Option, + pub id: Option>, /// Name of the LLM model offered by OpenAI, Cloudflare or vLLM #[serde(rename = "model_name")] - pub model_name: String, + pub model_name: Cow<'a, str>, /// The LLM service's API Key #[serde(rename = "api_key", skip_serializing_if = "Option::is_none")] - pub api_key: Option, + pub api_key: Option>, /// Typesense collection that stores the historical conversations #[serde(rename = "history_collection")] - pub history_collection: String, + pub history_collection: Cow<'a, str>, /// LLM service's account ID (only applicable for Cloudflare) #[serde(rename = "account_id", skip_serializing_if = "Option::is_none")] - pub account_id: Option, + pub account_id: Option>, /// The system prompt that contains special instructions to the LLM #[serde(rename = "system_prompt", skip_serializing_if = "Option::is_none")] - pub system_prompt: Option, + pub system_prompt: Option>, /// Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) #[serde(rename = "ttl", skip_serializing_if = "Option::is_none")] pub ttl: Option, @@ -39,16 +40,14 @@ pub struct ConversationModelCreateSchema { pub max_bytes: i32, /// URL of vLLM service #[serde(rename = "vllm_url", skip_serializing_if = "Option::is_none")] - pub vllm_url: Option, + pub vllm_url: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl ConversationModelCreateSchema { - pub fn new( - model_name: String, - history_collection: String, - max_bytes: i32, - ) -> ConversationModelCreateSchema { - ConversationModelCreateSchema { +impl<'a> ConversationModelCreateSchema<'a> { + pub fn new(model_name: Cow<'a, str>, history_collection: Cow<'a, str>, max_bytes: i32) -> Self { + Self { id: None, model_name, api_key: None, @@ -58,6 +57,7 @@ impl ConversationModelCreateSchema { ttl: None, max_bytes, vllm_url: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/conversation_model_schema.rs b/typesense_codegen/src/models/conversation_model_schema.rs index 1738f77f..dd0cd164 100644 --- a/typesense_codegen/src/models/conversation_model_schema.rs +++ b/typesense_codegen/src/models/conversation_model_schema.rs @@ -9,28 +9,29 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ConversationModelSchema { +pub struct ConversationModelSchema<'a> { /// An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. #[serde(rename = "id")] - pub id: String, + pub id: Cow<'a, str>, /// Name of the LLM model offered by OpenAI, Cloudflare or vLLM #[serde(rename = "model_name")] - pub model_name: String, + pub model_name: Cow<'a, str>, /// The LLM service's API Key #[serde(rename = "api_key", skip_serializing_if = "Option::is_none")] - pub api_key: Option, + pub api_key: Option>, /// Typesense collection that stores the historical conversations #[serde(rename = "history_collection")] - pub history_collection: String, + pub history_collection: Cow<'a, str>, /// LLM service's account ID (only applicable for Cloudflare) #[serde(rename = "account_id", skip_serializing_if = "Option::is_none")] - pub account_id: Option, + pub account_id: Option>, /// The system prompt that contains special instructions to the LLM #[serde(rename = "system_prompt", skip_serializing_if = "Option::is_none")] - pub system_prompt: Option, + pub system_prompt: Option>, /// Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) #[serde(rename = "ttl", skip_serializing_if = "Option::is_none")] pub ttl: Option, @@ -39,17 +40,19 @@ pub struct ConversationModelSchema { pub max_bytes: i32, /// URL of vLLM service #[serde(rename = "vllm_url", skip_serializing_if = "Option::is_none")] - pub vllm_url: Option, + pub vllm_url: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl ConversationModelSchema { +impl<'a> ConversationModelSchema<'a> { pub fn new( - id: String, - model_name: String, - history_collection: String, + id: Cow<'a, str>, + model_name: Cow<'a, str>, + history_collection: Cow<'a, str>, max_bytes: i32, - ) -> ConversationModelSchema { - ConversationModelSchema { + ) -> Self { + Self { id, model_name, api_key: None, @@ -59,6 +62,7 @@ impl ConversationModelSchema { ttl: None, max_bytes, vllm_url: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/conversation_model_update_schema.rs b/typesense_codegen/src/models/conversation_model_update_schema.rs index 13350199..1a75819c 100644 --- a/typesense_codegen/src/models/conversation_model_update_schema.rs +++ b/typesense_codegen/src/models/conversation_model_update_schema.rs @@ -9,28 +9,29 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ConversationModelUpdateSchema { +pub struct ConversationModelUpdateSchema<'a> { /// An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - pub id: Option, + pub id: Option>, /// Name of the LLM model offered by OpenAI, Cloudflare or vLLM #[serde(rename = "model_name", skip_serializing_if = "Option::is_none")] - pub model_name: Option, + pub model_name: Option>, /// The LLM service's API Key #[serde(rename = "api_key", skip_serializing_if = "Option::is_none")] - pub api_key: Option, + pub api_key: Option>, /// Typesense collection that stores the historical conversations #[serde(rename = "history_collection", skip_serializing_if = "Option::is_none")] - pub history_collection: Option, + pub history_collection: Option>, /// LLM service's account ID (only applicable for Cloudflare) #[serde(rename = "account_id", skip_serializing_if = "Option::is_none")] - pub account_id: Option, + pub account_id: Option>, /// The system prompt that contains special instructions to the LLM #[serde(rename = "system_prompt", skip_serializing_if = "Option::is_none")] - pub system_prompt: Option, + pub system_prompt: Option>, /// Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) #[serde(rename = "ttl", skip_serializing_if = "Option::is_none")] pub ttl: Option, @@ -39,12 +40,14 @@ pub struct ConversationModelUpdateSchema { pub max_bytes: Option, /// URL of vLLM service #[serde(rename = "vllm_url", skip_serializing_if = "Option::is_none")] - pub vllm_url: Option, + pub vllm_url: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl ConversationModelUpdateSchema { - pub fn new() -> ConversationModelUpdateSchema { - ConversationModelUpdateSchema { +impl<'a> ConversationModelUpdateSchema<'a> { + pub fn new() -> Self { + Self { id: None, model_name: None, api_key: None, @@ -54,6 +57,7 @@ impl ConversationModelUpdateSchema { ttl: None, max_bytes: None, vllm_url: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/create_analytics_rule_200_response.rs b/typesense_codegen/src/models/create_analytics_rule_200_response.rs index 80053caa..e8fe0e0a 100644 --- a/typesense_codegen/src/models/create_analytics_rule_200_response.rs +++ b/typesense_codegen/src/models/create_analytics_rule_200_response.rs @@ -9,16 +9,17 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum CreateAnalyticsRule200Response { - AnalyticsRule(Box), - Array(Vec), +pub enum CreateAnalyticsRule200Response<'a> { + AnalyticsRule(Box>), + Array(Vec>), } -impl Default for CreateAnalyticsRule200Response { +impl Default for CreateAnalyticsRule200Response<'_> { fn default() -> Self { Self::AnalyticsRule(Default::default()) } diff --git a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs index bb9f0012..32fd6ec1 100644 --- a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs +++ b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs @@ -9,34 +9,37 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CreateAnalyticsRule200ResponseOneOfInner { +pub struct CreateAnalyticsRule200ResponseOneOfInner<'a> { #[serde(rename = "name")] - pub name: String, + pub name: Cow<'a, str>, #[serde(rename = "type")] pub r#type: Type, #[serde(rename = "collection")] - pub collection: String, + pub collection: Cow<'a, str>, #[serde(rename = "event_type")] - pub event_type: String, + pub event_type: Cow<'a, str>, #[serde(rename = "rule_tag", skip_serializing_if = "Option::is_none")] - pub rule_tag: Option, + pub rule_tag: Option>, #[serde(rename = "params", skip_serializing_if = "Option::is_none")] - pub params: Option>, + pub params: Option>>, #[serde(rename = "error", skip_serializing_if = "Option::is_none")] - pub error: Option, + pub error: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CreateAnalyticsRule200ResponseOneOfInner { +impl<'a> CreateAnalyticsRule200ResponseOneOfInner<'a> { pub fn new( - name: String, + name: Cow<'a, str>, r#type: Type, - collection: String, - event_type: String, - ) -> CreateAnalyticsRule200ResponseOneOfInner { - CreateAnalyticsRule200ResponseOneOfInner { + collection: Cow<'a, str>, + event_type: Cow<'a, str>, + ) -> Self { + Self { name, r#type, collection, @@ -44,6 +47,7 @@ impl CreateAnalyticsRule200ResponseOneOfInner { rule_tag: None, params: None, error: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs index 08500ef4..48dcb036 100644 --- a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs +++ b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CreateAnalyticsRule200ResponseOneOfInnerAnyOf { +pub struct CreateAnalyticsRule200ResponseOneOfInnerAnyOf<'a> { #[serde(rename = "error", skip_serializing_if = "Option::is_none")] - pub error: Option, + pub error: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CreateAnalyticsRule200ResponseOneOfInnerAnyOf { - pub fn new() -> CreateAnalyticsRule200ResponseOneOfInnerAnyOf { - CreateAnalyticsRule200ResponseOneOfInnerAnyOf { error: None } +impl<'a> CreateAnalyticsRule200ResponseOneOfInnerAnyOf<'a> { + pub fn new() -> Self { + Self { + error: None, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/create_analytics_rule_request.rs b/typesense_codegen/src/models/create_analytics_rule_request.rs index 262570e1..21830411 100644 --- a/typesense_codegen/src/models/create_analytics_rule_request.rs +++ b/typesense_codegen/src/models/create_analytics_rule_request.rs @@ -9,16 +9,17 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum CreateAnalyticsRuleRequest { - AnalyticsRuleCreate(Box), - Array(Vec), +pub enum CreateAnalyticsRuleRequest<'a> { + AnalyticsRuleCreate(Box>), + Array(Vec>), } -impl Default for CreateAnalyticsRuleRequest { +impl Default for CreateAnalyticsRuleRequest<'_> { fn default() -> Self { Self::AnalyticsRuleCreate(Default::default()) } diff --git a/typesense_codegen/src/models/curation_exclude.rs b/typesense_codegen/src/models/curation_exclude.rs index af70fa34..8941518d 100644 --- a/typesense_codegen/src/models/curation_exclude.rs +++ b/typesense_codegen/src/models/curation_exclude.rs @@ -9,17 +9,23 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationExclude { +pub struct CurationExclude<'a> { /// document id that should be excluded from the search results. #[serde(rename = "id")] - pub id: String, + pub id: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CurationExclude { - pub fn new(id: String) -> CurationExclude { - CurationExclude { id } +impl<'a> CurationExclude<'a> { + pub fn new(id: Cow<'a, str>) -> Self { + Self { + id, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/curation_include.rs b/typesense_codegen/src/models/curation_include.rs index 5f9c2e56..8ba943f5 100644 --- a/typesense_codegen/src/models/curation_include.rs +++ b/typesense_codegen/src/models/curation_include.rs @@ -9,20 +9,27 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationInclude { +pub struct CurationInclude<'a> { /// document id that should be included #[serde(rename = "id")] - pub id: String, + pub id: Cow<'a, str>, /// position number where document should be included in the search results #[serde(rename = "position")] pub position: i32, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CurationInclude { - pub fn new(id: String, position: i32) -> CurationInclude { - CurationInclude { id, position } +impl<'a> CurationInclude<'a> { + pub fn new(id: Cow<'a, str>, position: i32) -> Self { + Self { + id, + position, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/curation_item_create_schema.rs b/typesense_codegen/src/models/curation_item_create_schema.rs index 7f4f9753..da1a5cc2 100644 --- a/typesense_codegen/src/models/curation_item_create_schema.rs +++ b/typesense_codegen/src/models/curation_item_create_schema.rs @@ -9,21 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationItemCreateSchema { +pub struct CurationItemCreateSchema<'a> { #[serde(rename = "rule")] - pub rule: Box, + pub rule: Box>, /// List of document `id`s that should be included in the search results with their corresponding `position`s. #[serde(rename = "includes", skip_serializing_if = "Option::is_none")] - pub includes: Option>, + pub includes: Option>>, /// List of document `id`s that should be excluded from the search results. #[serde(rename = "excludes", skip_serializing_if = "Option::is_none")] - pub excludes: Option>, + pub excludes: Option>>, /// A filter by clause that is applied to any search query that matches the curation rule. #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] - pub filter_by: Option, + pub filter_by: Option>, /// Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. #[serde( rename = "remove_matched_tokens", @@ -35,10 +36,10 @@ pub struct CurationItemCreateSchema { pub metadata: Option, /// A sort by clause that is applied to any search query that matches the curation rule. #[serde(rename = "sort_by", skip_serializing_if = "Option::is_none")] - pub sort_by: Option, + pub sort_by: Option>, /// Replaces the current search query with this value, when the search query matches the curation rule. #[serde(rename = "replace_query", skip_serializing_if = "Option::is_none")] - pub replace_query: Option, + pub replace_query: Option>, /// When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. #[serde( rename = "filter_curated_hits", @@ -56,12 +57,14 @@ pub struct CurationItemCreateSchema { pub stop_processing: Option, /// ID of the curation item #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - pub id: Option, + pub id: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CurationItemCreateSchema { - pub fn new(rule: models::CurationRule) -> CurationItemCreateSchema { - CurationItemCreateSchema { +impl<'a> CurationItemCreateSchema<'a> { + pub fn new(rule: models::CurationRule<'a>) -> Self { + Self { rule: Box::new(rule), includes: None, excludes: None, @@ -75,6 +78,7 @@ impl CurationItemCreateSchema { effective_to_ts: None, stop_processing: None, id: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/curation_item_delete_schema.rs b/typesense_codegen/src/models/curation_item_delete_schema.rs index 9bdf0c5b..ad1abd08 100644 --- a/typesense_codegen/src/models/curation_item_delete_schema.rs +++ b/typesense_codegen/src/models/curation_item_delete_schema.rs @@ -9,17 +9,23 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationItemDeleteSchema { +pub struct CurationItemDeleteSchema<'a> { /// ID of the deleted curation item #[serde(rename = "id")] - pub id: String, + pub id: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CurationItemDeleteSchema { - pub fn new(id: String) -> CurationItemDeleteSchema { - CurationItemDeleteSchema { id } +impl<'a> CurationItemDeleteSchema<'a> { + pub fn new(id: Cow<'a, str>) -> Self { + Self { + id, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/curation_item_schema.rs b/typesense_codegen/src/models/curation_item_schema.rs index 74c3d4e8..705879fe 100644 --- a/typesense_codegen/src/models/curation_item_schema.rs +++ b/typesense_codegen/src/models/curation_item_schema.rs @@ -9,21 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationItemSchema { +pub struct CurationItemSchema<'a> { #[serde(rename = "rule")] - pub rule: Box, + pub rule: Box>, /// List of document `id`s that should be included in the search results with their corresponding `position`s. #[serde(rename = "includes", skip_serializing_if = "Option::is_none")] - pub includes: Option>, + pub includes: Option>>, /// List of document `id`s that should be excluded from the search results. #[serde(rename = "excludes", skip_serializing_if = "Option::is_none")] - pub excludes: Option>, + pub excludes: Option>>, /// A filter by clause that is applied to any search query that matches the curation rule. #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] - pub filter_by: Option, + pub filter_by: Option>, /// Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. #[serde( rename = "remove_matched_tokens", @@ -35,10 +36,10 @@ pub struct CurationItemSchema { pub metadata: Option, /// A sort by clause that is applied to any search query that matches the curation rule. #[serde(rename = "sort_by", skip_serializing_if = "Option::is_none")] - pub sort_by: Option, + pub sort_by: Option>, /// Replaces the current search query with this value, when the search query matches the curation rule. #[serde(rename = "replace_query", skip_serializing_if = "Option::is_none")] - pub replace_query: Option, + pub replace_query: Option>, /// When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. #[serde( rename = "filter_curated_hits", @@ -55,12 +56,14 @@ pub struct CurationItemSchema { #[serde(rename = "stop_processing", skip_serializing_if = "Option::is_none")] pub stop_processing: Option, #[serde(rename = "id")] - pub id: String, + pub id: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CurationItemSchema { - pub fn new(rule: models::CurationRule, id: String) -> CurationItemSchema { - CurationItemSchema { +impl<'a> CurationItemSchema<'a> { + pub fn new(rule: models::CurationRule<'a>, id: Cow<'a, str>) -> Self { + Self { rule: Box::new(rule), includes: None, excludes: None, @@ -74,6 +77,7 @@ impl CurationItemSchema { effective_to_ts: None, stop_processing: None, id, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/curation_rule.rs b/typesense_codegen/src/models/curation_rule.rs index 45db3a02..9bff89bd 100644 --- a/typesense_codegen/src/models/curation_rule.rs +++ b/typesense_codegen/src/models/curation_rule.rs @@ -9,31 +9,35 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationRule { +pub struct CurationRule<'a> { /// List of tag values to associate with this curation rule. #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] pub tags: Option>, /// Indicates what search queries should be curated #[serde(rename = "query", skip_serializing_if = "Option::is_none")] - pub query: Option, + pub query: Option>, /// Indicates whether the match on the query term should be `exact` or `contains`. If we want to match all queries that contained the word `apple`, we will use the `contains` match instead. #[serde(rename = "match", skip_serializing_if = "Option::is_none")] pub r#match: Option, /// Indicates that the curation should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc). #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] - pub filter_by: Option, + pub filter_by: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CurationRule { - pub fn new() -> CurationRule { - CurationRule { +impl<'a> CurationRule<'a> { + pub fn new() -> Self { + Self { tags: None, query: None, r#match: None, filter_by: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/curation_set_create_schema.rs b/typesense_codegen/src/models/curation_set_create_schema.rs index 8676aaa9..49d72211 100644 --- a/typesense_codegen/src/models/curation_set_create_schema.rs +++ b/typesense_codegen/src/models/curation_set_create_schema.rs @@ -9,23 +9,27 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationSetCreateSchema { +pub struct CurationSetCreateSchema<'a> { /// Array of curation items #[serde(rename = "items")] - pub items: Vec, + pub items: Vec>, /// Optional description for the curation set #[serde(rename = "description", skip_serializing_if = "Option::is_none")] - pub description: Option, + pub description: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CurationSetCreateSchema { - pub fn new(items: Vec) -> CurationSetCreateSchema { - CurationSetCreateSchema { +impl<'a> CurationSetCreateSchema<'a> { + pub fn new(items: Vec>) -> Self { + Self { items, description: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/curation_set_delete_schema.rs b/typesense_codegen/src/models/curation_set_delete_schema.rs index d57d6832..c022df41 100644 --- a/typesense_codegen/src/models/curation_set_delete_schema.rs +++ b/typesense_codegen/src/models/curation_set_delete_schema.rs @@ -9,17 +9,23 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationSetDeleteSchema { +pub struct CurationSetDeleteSchema<'a> { /// Name of the deleted curation set #[serde(rename = "name")] - pub name: String, + pub name: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CurationSetDeleteSchema { - pub fn new(name: String) -> CurationSetDeleteSchema { - CurationSetDeleteSchema { name } +impl<'a> CurationSetDeleteSchema<'a> { + pub fn new(name: Cow<'a, str>) -> Self { + Self { + name, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/curation_set_schema.rs b/typesense_codegen/src/models/curation_set_schema.rs index 70f5e540..50742584 100644 --- a/typesense_codegen/src/models/curation_set_schema.rs +++ b/typesense_codegen/src/models/curation_set_schema.rs @@ -9,26 +9,30 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationSetSchema { +pub struct CurationSetSchema<'a> { /// Array of curation items #[serde(rename = "items")] - pub items: Vec, + pub items: Vec>, /// Optional description for the curation set #[serde(rename = "description", skip_serializing_if = "Option::is_none")] - pub description: Option, + pub description: Option>, #[serde(rename = "name")] - pub name: String, + pub name: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl CurationSetSchema { - pub fn new(items: Vec, name: String) -> CurationSetSchema { - CurationSetSchema { +impl<'a> CurationSetSchema<'a> { + pub fn new(items: Vec>, name: Cow<'a, str>) -> Self { + Self { items, description: None, name, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/debug_200_response.rs b/typesense_codegen/src/models/debug_200_response.rs index 946d84e4..0ae00b80 100644 --- a/typesense_codegen/src/models/debug_200_response.rs +++ b/typesense_codegen/src/models/debug_200_response.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct Debug200Response { +pub struct Debug200Response<'a> { #[serde(rename = "version", skip_serializing_if = "Option::is_none")] - pub version: Option, + pub version: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl Debug200Response { - pub fn new() -> Debug200Response { - Debug200Response { version: None } +impl<'a> Debug200Response<'a> { + pub fn new() -> Self { + Self { + version: None, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/delete_documents_200_response.rs b/typesense_codegen/src/models/delete_documents_200_response.rs index 169020c5..ac78b8f3 100644 --- a/typesense_codegen/src/models/delete_documents_200_response.rs +++ b/typesense_codegen/src/models/delete_documents_200_response.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct DeleteDocuments200Response { +pub struct DeleteDocuments200Response<'a> { #[serde(rename = "num_deleted")] pub num_deleted: i32, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl DeleteDocuments200Response { - pub fn new(num_deleted: i32) -> DeleteDocuments200Response { - DeleteDocuments200Response { num_deleted } +impl<'a> DeleteDocuments200Response<'a> { + pub fn new(num_deleted: i32) -> Self { + Self { + num_deleted, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/delete_documents_parameters.rs b/typesense_codegen/src/models/delete_documents_parameters.rs index 55e82413..5fa32e89 100644 --- a/typesense_codegen/src/models/delete_documents_parameters.rs +++ b/typesense_codegen/src/models/delete_documents_parameters.rs @@ -9,12 +9,13 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct DeleteDocumentsParameters { +pub struct DeleteDocumentsParameters<'a> { #[serde(rename = "filter_by")] - pub filter_by: String, + pub filter_by: Cow<'a, str>, /// Batch size parameter controls the number of documents that should be deleted at a time. A larger value will speed up deletions, but will impact performance of other operations running on the server. #[serde(rename = "batch_size", skip_serializing_if = "Option::is_none")] pub batch_size: Option, @@ -23,15 +24,18 @@ pub struct DeleteDocumentsParameters { /// When true, removes all documents from the collection while preserving the collection and its schema. #[serde(rename = "truncate", skip_serializing_if = "Option::is_none")] pub truncate: Option, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl DeleteDocumentsParameters { - pub fn new(filter_by: String) -> DeleteDocumentsParameters { - DeleteDocumentsParameters { +impl<'a> DeleteDocumentsParameters<'a> { + pub fn new(filter_by: Cow<'a, str>) -> Self { + Self { filter_by, batch_size: None, ignore_not_found: None, truncate: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/delete_stopwords_set_200_response.rs b/typesense_codegen/src/models/delete_stopwords_set_200_response.rs index 03b93ef5..2a4d584a 100644 --- a/typesense_codegen/src/models/delete_stopwords_set_200_response.rs +++ b/typesense_codegen/src/models/delete_stopwords_set_200_response.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct DeleteStopwordsSet200Response { +pub struct DeleteStopwordsSet200Response<'a> { #[serde(rename = "id")] - pub id: String, + pub id: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl DeleteStopwordsSet200Response { - pub fn new(id: String) -> DeleteStopwordsSet200Response { - DeleteStopwordsSet200Response { id } +impl<'a> DeleteStopwordsSet200Response<'a> { + pub fn new(id: Cow<'a, str>) -> Self { + Self { + id, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/dirty_values.rs b/typesense_codegen/src/models/dirty_values.rs index 8caeab91..0963b9f6 100644 --- a/typesense_codegen/src/models/dirty_values.rs +++ b/typesense_codegen/src/models/dirty_values.rs @@ -9,6 +9,7 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; /// diff --git a/typesense_codegen/src/models/drop_tokens_mode.rs b/typesense_codegen/src/models/drop_tokens_mode.rs index 5b8ba011..12e14f36 100644 --- a/typesense_codegen/src/models/drop_tokens_mode.rs +++ b/typesense_codegen/src/models/drop_tokens_mode.rs @@ -9,6 +9,7 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; /// DropTokensMode : Dictates the direction in which the words in the query must be dropped when the original words in the query do not appear in any document. Values: right_to_left (default), left_to_right, both_sides:3 A note on both_sides:3 - for queries up to 3 tokens (words) in length, this mode will drop tokens from both sides and exhaustively rank all matching results. If query length is greater than 3 words, Typesense will just fallback to default behavior of right_to_left diff --git a/typesense_codegen/src/models/export_documents_parameters.rs b/typesense_codegen/src/models/export_documents_parameters.rs index 36984f84..db2a08fc 100644 --- a/typesense_codegen/src/models/export_documents_parameters.rs +++ b/typesense_codegen/src/models/export_documents_parameters.rs @@ -9,27 +9,31 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ExportDocumentsParameters { +pub struct ExportDocumentsParameters<'a> { /// Filter conditions for refining your search results. Separate multiple conditions with &&. #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] - pub filter_by: Option, + pub filter_by: Option>, /// List of fields from the document to include in the search result #[serde(rename = "include_fields", skip_serializing_if = "Option::is_none")] - pub include_fields: Option, + pub include_fields: Option>, /// List of fields from the document to exclude in the search result #[serde(rename = "exclude_fields", skip_serializing_if = "Option::is_none")] - pub exclude_fields: Option, + pub exclude_fields: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl ExportDocumentsParameters { - pub fn new() -> ExportDocumentsParameters { - ExportDocumentsParameters { +impl<'a> ExportDocumentsParameters<'a> { + pub fn new() -> Self { + Self { filter_by: None, include_fields: None, exclude_fields: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/facet_counts.rs b/typesense_codegen/src/models/facet_counts.rs index d9cbdf38..fd17a05b 100644 --- a/typesense_codegen/src/models/facet_counts.rs +++ b/typesense_codegen/src/models/facet_counts.rs @@ -9,24 +9,28 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct FacetCounts { +pub struct FacetCounts<'a> { #[serde(rename = "counts", skip_serializing_if = "Option::is_none")] - pub counts: Option>, + pub counts: Option>>, #[serde(rename = "field_name", skip_serializing_if = "Option::is_none")] - pub field_name: Option, + pub field_name: Option>, #[serde(rename = "stats", skip_serializing_if = "Option::is_none")] - pub stats: Option>, + pub stats: Option>>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl FacetCounts { - pub fn new() -> FacetCounts { - FacetCounts { +impl<'a> FacetCounts<'a> { + pub fn new() -> Self { + Self { counts: None, field_name: None, stats: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/facet_counts_counts_inner.rs b/typesense_codegen/src/models/facet_counts_counts_inner.rs index bc6ede27..1e657025 100644 --- a/typesense_codegen/src/models/facet_counts_counts_inner.rs +++ b/typesense_codegen/src/models/facet_counts_counts_inner.rs @@ -9,27 +9,31 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct FacetCountsCountsInner { +pub struct FacetCountsCountsInner<'a> { #[serde(rename = "count", skip_serializing_if = "Option::is_none")] pub count: Option, #[serde(rename = "highlighted", skip_serializing_if = "Option::is_none")] - pub highlighted: Option, + pub highlighted: Option>, #[serde(rename = "value", skip_serializing_if = "Option::is_none")] - pub value: Option, + pub value: Option>, #[serde(rename = "parent", skip_serializing_if = "Option::is_none")] pub parent: Option, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl FacetCountsCountsInner { - pub fn new() -> FacetCountsCountsInner { - FacetCountsCountsInner { +impl<'a> FacetCountsCountsInner<'a> { + pub fn new() -> Self { + Self { count: None, highlighted: None, value: None, parent: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/facet_counts_stats.rs b/typesense_codegen/src/models/facet_counts_stats.rs index 7f0d9dd3..8fc473b6 100644 --- a/typesense_codegen/src/models/facet_counts_stats.rs +++ b/typesense_codegen/src/models/facet_counts_stats.rs @@ -9,10 +9,11 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct FacetCountsStats { +pub struct FacetCountsStats<'a> { #[serde(rename = "max", skip_serializing_if = "Option::is_none")] pub max: Option, #[serde(rename = "min", skip_serializing_if = "Option::is_none")] @@ -23,16 +24,19 @@ pub struct FacetCountsStats { pub total_values: Option, #[serde(rename = "avg", skip_serializing_if = "Option::is_none")] pub avg: Option, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl FacetCountsStats { - pub fn new() -> FacetCountsStats { - FacetCountsStats { +impl<'a> FacetCountsStats<'a> { + pub fn new() -> Self { + Self { max: None, min: None, sum: None, total_values: None, avg: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/field.rs b/typesense_codegen/src/models/field.rs index 57a42150..e1013819 100644 --- a/typesense_codegen/src/models/field.rs +++ b/typesense_codegen/src/models/field.rs @@ -9,17 +9,18 @@ */ use crate::models; -use ::std::borrow::Cow; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(bon::Builder)] #[builder(on(Cow<'_, str>, into))] +#[builder(on(String, into))] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct Field { +pub struct Field<'a> { #[serde(rename = "name")] - pub name: Cow<'static, str>, + pub name: Cow<'a, str>, #[serde(rename = "type")] - pub r#type: Cow<'static, str>, + pub r#type: Cow<'a, str>, #[serde(rename = "optional", skip_serializing_if = "Option::is_none")] pub optional: Option, #[serde(rename = "facet", skip_serializing_if = "Option::is_none")] @@ -27,14 +28,14 @@ pub struct Field { #[serde(rename = "index", skip_serializing_if = "Option::is_none")] pub index: Option, #[serde(rename = "locale", skip_serializing_if = "Option::is_none")] - pub locale: Option>, + pub locale: Option>, #[serde(rename = "sort", skip_serializing_if = "Option::is_none")] pub sort: Option, #[serde(rename = "infix", skip_serializing_if = "Option::is_none")] pub infix: Option, /// Name of a field in another collection that should be linked to this collection so that it can be joined during query. #[serde(rename = "reference", skip_serializing_if = "Option::is_none")] - pub reference: Option>, + pub reference: Option>, #[serde(rename = "num_dim", skip_serializing_if = "Option::is_none")] pub num_dim: Option, #[serde(rename = "drop", skip_serializing_if = "Option::is_none")] @@ -44,7 +45,7 @@ pub struct Field { pub store: Option, /// The distance metric to be used for vector search. Default: `cosine`. You can also use `ip` for inner product. #[serde(rename = "vec_dist", skip_serializing_if = "Option::is_none")] - pub vec_dist: Option>, + pub vec_dist: Option>, /// Enables an index optimized for range filtering on numerical fields (e.g. rating:>3.5). Default: false. #[serde(rename = "range_index", skip_serializing_if = "Option::is_none")] pub range_index: Option, @@ -53,22 +54,25 @@ pub struct Field { pub stem: Option, /// Name of the stemming dictionary to use for this field #[serde(rename = "stem_dictionary", skip_serializing_if = "Option::is_none")] - pub stem_dictionary: Option>, + pub stem_dictionary: Option>, /// List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters. #[serde(rename = "token_separators", skip_serializing_if = "Option::is_none")] - pub token_separators: Option>>, + pub token_separators: Option>, /// List of symbols or special characters to be indexed. #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] - pub symbols_to_index: Option>>, + pub symbols_to_index: Option>, #[serde(rename = "embed", skip_serializing_if = "Option::is_none")] - pub embed: Option>, + pub embed: Option>>, + #[serde(skip)] + #[builder(default)] + pub _phantom: PhantomData<&'a ()>, } -impl Field { - pub fn new(name: impl Into>, r#type: impl Into>) -> Field { - Field { - name: name.into(), - r#type: r#type.into(), +impl<'a> Field<'a> { + pub fn new(name: Cow<'a, str>, r#type: Cow<'a, str>) -> Self { + Self { + name, + r#type, optional: None, facet: None, index: None, @@ -86,6 +90,7 @@ impl Field { token_separators: None, symbols_to_index: None, embed: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/field_embed.rs b/typesense_codegen/src/models/field_embed.rs index 0e84fd9f..9c7b96ba 100644 --- a/typesense_codegen/src/models/field_embed.rs +++ b/typesense_codegen/src/models/field_embed.rs @@ -9,21 +9,25 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct FieldEmbed { +pub struct FieldEmbed<'a> { #[serde(rename = "from")] pub from: Vec, #[serde(rename = "model_config")] - pub model_config: Box, + pub model_config: Box>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl FieldEmbed { - pub fn new(from: Vec, model_config: models::FieldEmbedModelConfig) -> FieldEmbed { - FieldEmbed { +impl<'a> FieldEmbed<'a> { + pub fn new(from: Vec, model_config: models::FieldEmbedModelConfig<'a>) -> Self { + Self { from, model_config: Box::new(model_config), + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/field_embed_model_config.rs b/typesense_codegen/src/models/field_embed_model_config.rs index ee40bea5..19f89744 100644 --- a/typesense_codegen/src/models/field_embed_model_config.rs +++ b/typesense_codegen/src/models/field_embed_model_config.rs @@ -9,35 +9,38 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct FieldEmbedModelConfig { +pub struct FieldEmbedModelConfig<'a> { #[serde(rename = "model_name")] - pub model_name: String, + pub model_name: Cow<'a, str>, #[serde(rename = "api_key", skip_serializing_if = "Option::is_none")] - pub api_key: Option, + pub api_key: Option>, #[serde(rename = "url", skip_serializing_if = "Option::is_none")] - pub url: Option, + pub url: Option>, #[serde(rename = "access_token", skip_serializing_if = "Option::is_none")] - pub access_token: Option, + pub access_token: Option>, #[serde(rename = "refresh_token", skip_serializing_if = "Option::is_none")] - pub refresh_token: Option, + pub refresh_token: Option>, #[serde(rename = "client_id", skip_serializing_if = "Option::is_none")] - pub client_id: Option, + pub client_id: Option>, #[serde(rename = "client_secret", skip_serializing_if = "Option::is_none")] - pub client_secret: Option, + pub client_secret: Option>, #[serde(rename = "project_id", skip_serializing_if = "Option::is_none")] - pub project_id: Option, + pub project_id: Option>, #[serde(rename = "indexing_prefix", skip_serializing_if = "Option::is_none")] - pub indexing_prefix: Option, + pub indexing_prefix: Option>, #[serde(rename = "query_prefix", skip_serializing_if = "Option::is_none")] - pub query_prefix: Option, + pub query_prefix: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl FieldEmbedModelConfig { - pub fn new(model_name: String) -> FieldEmbedModelConfig { - FieldEmbedModelConfig { +impl<'a> FieldEmbedModelConfig<'a> { + pub fn new(model_name: Cow<'a, str>) -> Self { + Self { model_name, api_key: None, url: None, @@ -48,6 +51,7 @@ impl FieldEmbedModelConfig { project_id: None, indexing_prefix: None, query_prefix: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/get_collections_parameters.rs b/typesense_codegen/src/models/get_collections_parameters.rs index 02497f6c..f7b3a5fa 100644 --- a/typesense_codegen/src/models/get_collections_parameters.rs +++ b/typesense_codegen/src/models/get_collections_parameters.rs @@ -9,27 +9,31 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct GetCollectionsParameters { +pub struct GetCollectionsParameters<'a> { /// Comma-separated list of fields from the collection to exclude from the response #[serde(rename = "exclude_fields", skip_serializing_if = "Option::is_none")] - pub exclude_fields: Option, + pub exclude_fields: Option>, /// Number of collections to fetch. Default: returns all collections. #[serde(rename = "limit", skip_serializing_if = "Option::is_none")] pub limit: Option, /// Identifies the starting point to return collections when paginating. #[serde(rename = "offset", skip_serializing_if = "Option::is_none")] pub offset: Option, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl GetCollectionsParameters { - pub fn new() -> GetCollectionsParameters { - GetCollectionsParameters { +impl<'a> GetCollectionsParameters<'a> { + pub fn new() -> Self { + Self { exclude_fields: None, limit: None, offset: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/health_status.rs b/typesense_codegen/src/models/health_status.rs index 66cdf6b3..8e0ca531 100644 --- a/typesense_codegen/src/models/health_status.rs +++ b/typesense_codegen/src/models/health_status.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct HealthStatus { +pub struct HealthStatus<'a> { #[serde(rename = "ok")] pub ok: bool, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl HealthStatus { - pub fn new(ok: bool) -> HealthStatus { - HealthStatus { ok } +impl<'a> HealthStatus<'a> { + pub fn new(ok: bool) -> Self { + Self { + ok, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/import_documents_parameters.rs b/typesense_codegen/src/models/import_documents_parameters.rs index e17494a8..db226911 100644 --- a/typesense_codegen/src/models/import_documents_parameters.rs +++ b/typesense_codegen/src/models/import_documents_parameters.rs @@ -9,10 +9,11 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ImportDocumentsParameters { +pub struct ImportDocumentsParameters<'a> { #[serde(rename = "batch_size", skip_serializing_if = "Option::is_none")] pub batch_size: Option, /// Returning the id of the imported documents. If you want the import response to return the ingested document's id in the response, you can use the return_id parameter. @@ -29,17 +30,20 @@ pub struct ImportDocumentsParameters { pub action: Option, #[serde(rename = "dirty_values", skip_serializing_if = "Option::is_none")] pub dirty_values: Option, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl ImportDocumentsParameters { - pub fn new() -> ImportDocumentsParameters { - ImportDocumentsParameters { +impl<'a> ImportDocumentsParameters<'a> { + pub fn new() -> Self { + Self { batch_size: None, return_id: None, remote_embedding_batch_size: None, return_doc: None, action: None, dirty_values: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/index_action.rs b/typesense_codegen/src/models/index_action.rs index eb521743..ef739239 100644 --- a/typesense_codegen/src/models/index_action.rs +++ b/typesense_codegen/src/models/index_action.rs @@ -9,6 +9,7 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; /// diff --git a/typesense_codegen/src/models/list_stemming_dictionaries_200_response.rs b/typesense_codegen/src/models/list_stemming_dictionaries_200_response.rs index 9985e0d3..02f676cd 100644 --- a/typesense_codegen/src/models/list_stemming_dictionaries_200_response.rs +++ b/typesense_codegen/src/models/list_stemming_dictionaries_200_response.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ListStemmingDictionaries200Response { +pub struct ListStemmingDictionaries200Response<'a> { #[serde(rename = "dictionaries", skip_serializing_if = "Option::is_none")] pub dictionaries: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl ListStemmingDictionaries200Response { - pub fn new() -> ListStemmingDictionaries200Response { - ListStemmingDictionaries200Response { dictionaries: None } +impl<'a> ListStemmingDictionaries200Response<'a> { + pub fn new() -> Self { + Self { + dictionaries: None, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/multi_search_collection_parameters.rs b/typesense_codegen/src/models/multi_search_collection_parameters.rs index 76f99e07..5d5a3e3c 100644 --- a/typesense_codegen/src/models/multi_search_collection_parameters.rs +++ b/typesense_codegen/src/models/multi_search_collection_parameters.rs @@ -9,30 +9,32 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(bon::Builder)] +#[builder(on(Cow<'_, str>, into))] #[builder(on(String, into))] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct MultiSearchCollectionParameters { +pub struct MultiSearchCollectionParameters<'a> { /// The query text to search for in the collection. Use * as the search string to return all documents. This is typically useful when used in conjunction with filter_by. #[serde(rename = "q", skip_serializing_if = "Option::is_none")] - pub q: Option, + pub q: Option>, /// A list of `string` fields that should be queried against. Multiple fields are separated with a comma. #[serde(rename = "query_by", skip_serializing_if = "Option::is_none")] - pub query_by: Option, + pub query_by: Option>, /// The relative weight to give each `query_by` field when ranking results. This can be used to boost fields in priority, when looking for matches. Multiple fields are separated with a comma. #[serde(rename = "query_by_weights", skip_serializing_if = "Option::is_none")] - pub query_by_weights: Option, + pub query_by_weights: Option>, /// In a multi-field matching context, this parameter determines how the representative text match score of a record is calculated. Possible values are max_score (default) or max_weight. #[serde(rename = "text_match_type", skip_serializing_if = "Option::is_none")] - pub text_match_type: Option, + pub text_match_type: Option>, /// Boolean field to indicate that the last word in the query should be treated as a prefix, and not as a whole word. This is used for building autocomplete and instant search interfaces. Defaults to true. #[serde(rename = "prefix", skip_serializing_if = "Option::is_none")] - pub prefix: Option, + pub prefix: Option>, /// If infix index is enabled for this field, infix searching can be done on a per-field basis by sending a comma separated string parameter called infix to the search query. This parameter can have 3 values; `off` infix search is disabled, which is default `always` infix search is performed along with regular search `fallback` infix search is performed if regular search does not produce results #[serde(rename = "infix", skip_serializing_if = "Option::is_none")] - pub infix: Option, + pub infix: Option>, /// There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query \"K2100\" has 2 extra symbols in \"6PK2100\". By default, any number of prefixes/suffixes can be present for a match. #[serde(rename = "max_extra_prefix", skip_serializing_if = "Option::is_none")] pub max_extra_prefix: Option, @@ -41,22 +43,22 @@ pub struct MultiSearchCollectionParameters { pub max_extra_suffix: Option, /// Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] - pub filter_by: Option, + pub filter_by: Option>, /// A list of numerical fields and their corresponding sort orders that will be used for ordering your results. Up to 3 sort fields can be specified. The text similarity score is exposed as a special `_text_match` field that you can use in the list of sorting fields. If no `sort_by` parameter is specified, results are sorted by `_text_match:desc,default_sorting_field:desc` #[serde(rename = "sort_by", skip_serializing_if = "Option::is_none")] - pub sort_by: Option, + pub sort_by: Option>, /// A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. #[serde(rename = "facet_by", skip_serializing_if = "Option::is_none")] - pub facet_by: Option, + pub facet_by: Option>, /// Maximum number of facet values to be returned. #[serde(rename = "max_facet_values", skip_serializing_if = "Option::is_none")] pub max_facet_values: Option, /// Facet values that are returned can now be filtered via this parameter. The matching facet text is also highlighted. For example, when faceting by `category`, you can set `facet_query=category:shoe` to return only facet values that contain the prefix \"shoe\". #[serde(rename = "facet_query", skip_serializing_if = "Option::is_none")] - pub facet_query: Option, + pub facet_query: Option>, /// The number of typographical errors (1 or 2) that would be tolerated. Default: 2 #[serde(rename = "num_typos", skip_serializing_if = "Option::is_none")] - pub num_typos: Option, + pub num_typos: Option>, /// Results from this specific page number would be fetched. #[serde(rename = "page", skip_serializing_if = "Option::is_none")] pub page: Option, @@ -71,7 +73,7 @@ pub struct MultiSearchCollectionParameters { pub offset: Option, /// You can aggregate search results into groups or buckets by specify one or more `group_by` fields. Separate multiple fields with a comma. To group on a particular field, it must be a faceted field. #[serde(rename = "group_by", skip_serializing_if = "Option::is_none")] - pub group_by: Option, + pub group_by: Option>, /// Maximum number of hits to be returned for every group. If the `group_limit` is set as `K` then only the top K hits in each group are returned in the response. Default: 3 #[serde(rename = "group_limit", skip_serializing_if = "Option::is_none")] pub group_limit: Option, @@ -83,16 +85,16 @@ pub struct MultiSearchCollectionParameters { pub group_missing_values: Option, /// List of fields from the document to include in the search result #[serde(rename = "include_fields", skip_serializing_if = "Option::is_none")] - pub include_fields: Option, + pub include_fields: Option>, /// List of fields from the document to exclude in the search result #[serde(rename = "exclude_fields", skip_serializing_if = "Option::is_none")] - pub exclude_fields: Option, + pub exclude_fields: Option>, /// List of fields which should be highlighted fully without snippeting #[serde( rename = "highlight_full_fields", skip_serializing_if = "Option::is_none" )] - pub highlight_full_fields: Option, + pub highlight_full_fields: Option>, /// The number of tokens that should surround the highlighted text on each side. Default: 4 #[serde( rename = "highlight_affix_num_tokens", @@ -104,10 +106,10 @@ pub struct MultiSearchCollectionParameters { rename = "highlight_start_tag", skip_serializing_if = "Option::is_none" )] - pub highlight_start_tag: Option, + pub highlight_start_tag: Option>, /// The end tag used for the highlighted snippets. Default: `` #[serde(rename = "highlight_end_tag", skip_serializing_if = "Option::is_none")] - pub highlight_end_tag: Option, + pub highlight_end_tag: Option>, /// Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 #[serde(rename = "snippet_threshold", skip_serializing_if = "Option::is_none")] pub snippet_threshold: Option, @@ -151,16 +153,16 @@ pub struct MultiSearchCollectionParameters { pub synonym_num_typos: Option, /// A list of records to unconditionally include in the search results at specific positions. An example use case would be to feature or promote certain items on the top of search results. A list of `record_id:hit_position`. Eg: to include a record with ID 123 at Position 1 and another record with ID 456 at Position 5, you'd specify `123:1,456:5`. You could also use the Overrides feature to override search results based on rules. Overrides are applied first, followed by `pinned_hits` and finally `hidden_hits`. #[serde(rename = "pinned_hits", skip_serializing_if = "Option::is_none")] - pub pinned_hits: Option, + pub pinned_hits: Option>, /// A list of records to unconditionally hide from search results. A list of `record_id`s to hide. Eg: to hide records with IDs 123 and 456, you'd specify `123,456`. You could also use the Overrides feature to override search results based on rules. Overrides are applied first, followed by `pinned_hits` and finally `hidden_hits`. #[serde(rename = "hidden_hits", skip_serializing_if = "Option::is_none")] - pub hidden_hits: Option, + pub hidden_hits: Option>, /// Comma separated list of tags to trigger the curations rules that match the tags. #[serde(rename = "override_tags", skip_serializing_if = "Option::is_none")] - pub override_tags: Option, + pub override_tags: Option>, /// A list of custom fields that must be highlighted even if you don't query for them #[serde(rename = "highlight_fields", skip_serializing_if = "Option::is_none")] - pub highlight_fields: Option, + pub highlight_fields: Option>, /// You can index content from any logographic language into Typesense if you are able to segment / split the text into space-separated words yourself before indexing and querying. Set this parameter to true to do the same #[serde( rename = "pre_segmented_query", @@ -169,7 +171,7 @@ pub struct MultiSearchCollectionParameters { pub pre_segmented_query: Option, /// Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. #[serde(rename = "preset", skip_serializing_if = "Option::is_none")] - pub preset: Option, + pub preset: Option>, /// If you have some overrides defined but want to disable all of them during query time, you can do that by setting this parameter to false #[serde(rename = "enable_overrides", skip_serializing_if = "Option::is_none")] pub enable_overrides: Option, @@ -217,7 +219,7 @@ pub struct MultiSearchCollectionParameters { pub min_len_2typo: Option, /// Vector query expression for fetching documents \"closest\" to a given query/document vector. #[serde(rename = "vector_query", skip_serializing_if = "Option::is_none")] - pub vector_query: Option, + pub vector_query: Option>, /// Timeout (in milliseconds) for fetching remote embeddings. #[serde( rename = "remote_embedding_timeout_ms", @@ -232,19 +234,19 @@ pub struct MultiSearchCollectionParameters { pub remote_embedding_num_tries: Option, /// Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). #[serde(rename = "facet_strategy", skip_serializing_if = "Option::is_none")] - pub facet_strategy: Option, + pub facet_strategy: Option>, /// Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query. #[serde(rename = "stopwords", skip_serializing_if = "Option::is_none")] - pub stopwords: Option, + pub stopwords: Option>, /// Comma separated string of nested facet fields whose parent object should be returned in facet response. #[serde( rename = "facet_return_parent", skip_serializing_if = "Option::is_none" )] - pub facet_return_parent: Option, + pub facet_return_parent: Option>, /// The base64 encoded audio file in 16 khz 16-bit WAV format. #[serde(rename = "voice_query", skip_serializing_if = "Option::is_none")] - pub voice_query: Option, + pub voice_query: Option>, /// Enable conversational search. #[serde(rename = "conversation", skip_serializing_if = "Option::is_none")] pub conversation: Option, @@ -253,30 +255,33 @@ pub struct MultiSearchCollectionParameters { rename = "conversation_model_id", skip_serializing_if = "Option::is_none" )] - pub conversation_model_id: Option, + pub conversation_model_id: Option>, /// The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. #[serde(rename = "conversation_id", skip_serializing_if = "Option::is_none")] - pub conversation_id: Option, + pub conversation_id: Option>, /// The collection to search in. #[serde(rename = "collection", skip_serializing_if = "Option::is_none")] - pub collection: Option, + pub collection: Option>, /// A separate search API key for each search within a multi_search request #[serde( rename = "x-typesense-api-key", skip_serializing_if = "Option::is_none" )] - pub x_typesense_api_key: Option, + pub x_typesense_api_key: Option>, /// When true, computes both text match and vector distance scores for all matches in hybrid search. Documents found only through keyword search will get a vector distance score, and documents found only through vector search will get a text match score. #[serde( rename = "rerank_hybrid_matches", skip_serializing_if = "Option::is_none" )] pub rerank_hybrid_matches: Option, + #[serde(skip)] + #[builder(default)] + pub _phantom: PhantomData<&'a ()>, } -impl MultiSearchCollectionParameters { - pub fn new() -> MultiSearchCollectionParameters { - MultiSearchCollectionParameters { +impl<'a> MultiSearchCollectionParameters<'a> { + pub fn new() -> Self { + Self { q: None, query_by: None, query_by_weights: None, @@ -344,6 +349,7 @@ impl MultiSearchCollectionParameters { collection: None, x_typesense_api_key: None, rerank_hybrid_matches: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/multi_search_parameters.rs b/typesense_codegen/src/models/multi_search_parameters.rs index 21b2db07..c4164753 100644 --- a/typesense_codegen/src/models/multi_search_parameters.rs +++ b/typesense_codegen/src/models/multi_search_parameters.rs @@ -9,31 +9,33 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; /// MultiSearchParameters : Parameters for the multi search API. #[derive(bon::Builder)] +#[builder(on(Cow<'_, str>, into))] #[builder(on(String, into))] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct MultiSearchParameters { +pub struct MultiSearchParameters<'a> { /// The query text to search for in the collection. Use * as the search string to return all documents. This is typically useful when used in conjunction with filter_by. #[serde(rename = "q", skip_serializing_if = "Option::is_none")] - pub q: Option, + pub q: Option>, /// A list of `string` fields that should be queried against. Multiple fields are separated with a comma. #[serde(rename = "query_by", skip_serializing_if = "Option::is_none")] - pub query_by: Option, + pub query_by: Option>, /// The relative weight to give each `query_by` field when ranking results. This can be used to boost fields in priority, when looking for matches. Multiple fields are separated with a comma. #[serde(rename = "query_by_weights", skip_serializing_if = "Option::is_none")] - pub query_by_weights: Option, + pub query_by_weights: Option>, /// In a multi-field matching context, this parameter determines how the representative text match score of a record is calculated. Possible values are max_score (default) or max_weight. #[serde(rename = "text_match_type", skip_serializing_if = "Option::is_none")] - pub text_match_type: Option, + pub text_match_type: Option>, /// Boolean field to indicate that the last word in the query should be treated as a prefix, and not as a whole word. This is used for building autocomplete and instant search interfaces. Defaults to true. #[serde(rename = "prefix", skip_serializing_if = "Option::is_none")] - pub prefix: Option, + pub prefix: Option>, /// If infix index is enabled for this field, infix searching can be done on a per-field basis by sending a comma separated string parameter called infix to the search query. This parameter can have 3 values; `off` infix search is disabled, which is default `always` infix search is performed along with regular search `fallback` infix search is performed if regular search does not produce results #[serde(rename = "infix", skip_serializing_if = "Option::is_none")] - pub infix: Option, + pub infix: Option>, /// There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query \"K2100\" has 2 extra symbols in \"6PK2100\". By default, any number of prefixes/suffixes can be present for a match. #[serde(rename = "max_extra_prefix", skip_serializing_if = "Option::is_none")] pub max_extra_prefix: Option, @@ -42,22 +44,22 @@ pub struct MultiSearchParameters { pub max_extra_suffix: Option, /// Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] - pub filter_by: Option, + pub filter_by: Option>, /// A list of numerical fields and their corresponding sort orders that will be used for ordering your results. Up to 3 sort fields can be specified. The text similarity score is exposed as a special `_text_match` field that you can use in the list of sorting fields. If no `sort_by` parameter is specified, results are sorted by `_text_match:desc,default_sorting_field:desc` #[serde(rename = "sort_by", skip_serializing_if = "Option::is_none")] - pub sort_by: Option, + pub sort_by: Option>, /// A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. #[serde(rename = "facet_by", skip_serializing_if = "Option::is_none")] - pub facet_by: Option, + pub facet_by: Option>, /// Maximum number of facet values to be returned. #[serde(rename = "max_facet_values", skip_serializing_if = "Option::is_none")] pub max_facet_values: Option, /// Facet values that are returned can now be filtered via this parameter. The matching facet text is also highlighted. For example, when faceting by `category`, you can set `facet_query=category:shoe` to return only facet values that contain the prefix \"shoe\". #[serde(rename = "facet_query", skip_serializing_if = "Option::is_none")] - pub facet_query: Option, + pub facet_query: Option>, /// The number of typographical errors (1 or 2) that would be tolerated. Default: 2 #[serde(rename = "num_typos", skip_serializing_if = "Option::is_none")] - pub num_typos: Option, + pub num_typos: Option>, /// Results from this specific page number would be fetched. #[serde(rename = "page", skip_serializing_if = "Option::is_none")] pub page: Option, @@ -72,7 +74,7 @@ pub struct MultiSearchParameters { pub offset: Option, /// You can aggregate search results into groups or buckets by specify one or more `group_by` fields. Separate multiple fields with a comma. To group on a particular field, it must be a faceted field. #[serde(rename = "group_by", skip_serializing_if = "Option::is_none")] - pub group_by: Option, + pub group_by: Option>, /// Maximum number of hits to be returned for every group. If the `group_limit` is set as `K` then only the top K hits in each group are returned in the response. Default: 3 #[serde(rename = "group_limit", skip_serializing_if = "Option::is_none")] pub group_limit: Option, @@ -84,16 +86,16 @@ pub struct MultiSearchParameters { pub group_missing_values: Option, /// List of fields from the document to include in the search result #[serde(rename = "include_fields", skip_serializing_if = "Option::is_none")] - pub include_fields: Option, + pub include_fields: Option>, /// List of fields from the document to exclude in the search result #[serde(rename = "exclude_fields", skip_serializing_if = "Option::is_none")] - pub exclude_fields: Option, + pub exclude_fields: Option>, /// List of fields which should be highlighted fully without snippeting #[serde( rename = "highlight_full_fields", skip_serializing_if = "Option::is_none" )] - pub highlight_full_fields: Option, + pub highlight_full_fields: Option>, /// The number of tokens that should surround the highlighted text on each side. Default: 4 #[serde( rename = "highlight_affix_num_tokens", @@ -105,10 +107,10 @@ pub struct MultiSearchParameters { rename = "highlight_start_tag", skip_serializing_if = "Option::is_none" )] - pub highlight_start_tag: Option, + pub highlight_start_tag: Option>, /// The end tag used for the highlighted snippets. Default: `` #[serde(rename = "highlight_end_tag", skip_serializing_if = "Option::is_none")] - pub highlight_end_tag: Option, + pub highlight_end_tag: Option>, /// Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 #[serde(rename = "snippet_threshold", skip_serializing_if = "Option::is_none")] pub snippet_threshold: Option, @@ -152,16 +154,16 @@ pub struct MultiSearchParameters { pub synonym_num_typos: Option, /// A list of records to unconditionally include in the search results at specific positions. An example use case would be to feature or promote certain items on the top of search results. A list of `record_id:hit_position`. Eg: to include a record with ID 123 at Position 1 and another record with ID 456 at Position 5, you'd specify `123:1,456:5`. You could also use the Overrides feature to override search results based on rules. Overrides are applied first, followed by `pinned_hits` and finally `hidden_hits`. #[serde(rename = "pinned_hits", skip_serializing_if = "Option::is_none")] - pub pinned_hits: Option, + pub pinned_hits: Option>, /// A list of records to unconditionally hide from search results. A list of `record_id`s to hide. Eg: to hide records with IDs 123 and 456, you'd specify `123,456`. You could also use the Overrides feature to override search results based on rules. Overrides are applied first, followed by `pinned_hits` and finally `hidden_hits`. #[serde(rename = "hidden_hits", skip_serializing_if = "Option::is_none")] - pub hidden_hits: Option, + pub hidden_hits: Option>, /// Comma separated list of tags to trigger the curations rules that match the tags. #[serde(rename = "override_tags", skip_serializing_if = "Option::is_none")] - pub override_tags: Option, + pub override_tags: Option>, /// A list of custom fields that must be highlighted even if you don't query for them #[serde(rename = "highlight_fields", skip_serializing_if = "Option::is_none")] - pub highlight_fields: Option, + pub highlight_fields: Option>, /// You can index content from any logographic language into Typesense if you are able to segment / split the text into space-separated words yourself before indexing and querying. Set this parameter to true to do the same #[serde( rename = "pre_segmented_query", @@ -170,7 +172,7 @@ pub struct MultiSearchParameters { pub pre_segmented_query: Option, /// Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. #[serde(rename = "preset", skip_serializing_if = "Option::is_none")] - pub preset: Option, + pub preset: Option>, /// If you have some overrides defined but want to disable all of them during query time, you can do that by setting this parameter to false #[serde(rename = "enable_overrides", skip_serializing_if = "Option::is_none")] pub enable_overrides: Option, @@ -218,7 +220,7 @@ pub struct MultiSearchParameters { pub min_len_2typo: Option, /// Vector query expression for fetching documents \"closest\" to a given query/document vector. #[serde(rename = "vector_query", skip_serializing_if = "Option::is_none")] - pub vector_query: Option, + pub vector_query: Option>, /// Timeout (in milliseconds) for fetching remote embeddings. #[serde( rename = "remote_embedding_timeout_ms", @@ -233,19 +235,19 @@ pub struct MultiSearchParameters { pub remote_embedding_num_tries: Option, /// Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). #[serde(rename = "facet_strategy", skip_serializing_if = "Option::is_none")] - pub facet_strategy: Option, + pub facet_strategy: Option>, /// Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query. #[serde(rename = "stopwords", skip_serializing_if = "Option::is_none")] - pub stopwords: Option, + pub stopwords: Option>, /// Comma separated string of nested facet fields whose parent object should be returned in facet response. #[serde( rename = "facet_return_parent", skip_serializing_if = "Option::is_none" )] - pub facet_return_parent: Option, + pub facet_return_parent: Option>, /// The base64 encoded audio file in 16 khz 16-bit WAV format. #[serde(rename = "voice_query", skip_serializing_if = "Option::is_none")] - pub voice_query: Option, + pub voice_query: Option>, /// Enable conversational search. #[serde(rename = "conversation", skip_serializing_if = "Option::is_none")] pub conversation: Option, @@ -254,16 +256,19 @@ pub struct MultiSearchParameters { rename = "conversation_model_id", skip_serializing_if = "Option::is_none" )] - pub conversation_model_id: Option, + pub conversation_model_id: Option>, /// The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. #[serde(rename = "conversation_id", skip_serializing_if = "Option::is_none")] - pub conversation_id: Option, + pub conversation_id: Option>, + #[serde(skip)] + #[builder(default)] + pub _phantom: PhantomData<&'a ()>, } -impl MultiSearchParameters { +impl<'a> MultiSearchParameters<'a> { /// Parameters for the multi search API. - pub fn new() -> MultiSearchParameters { - MultiSearchParameters { + pub fn new() -> Self { + Self { q: None, query_by: None, query_by_weights: None, @@ -328,6 +333,7 @@ impl MultiSearchParameters { conversation: None, conversation_model_id: None, conversation_id: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/multi_search_result.rs b/typesense_codegen/src/models/multi_search_result.rs index bef67801..5c2093ef 100644 --- a/typesense_codegen/src/models/multi_search_result.rs +++ b/typesense_codegen/src/models/multi_search_result.rs @@ -9,21 +9,25 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct MultiSearchResult { +pub struct MultiSearchResult<'a, D> { #[serde(rename = "results")] - pub results: Vec>, + pub results: Vec>, #[serde(rename = "conversation", skip_serializing_if = "Option::is_none")] - pub conversation: Option>, + pub conversation: Option>>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl MultiSearchResult { - pub fn new(results: Vec>) -> MultiSearchResult { - MultiSearchResult { +impl<'a, D> MultiSearchResult<'a, D> { + pub fn new(results: Vec>) -> Self { + Self { results, conversation: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/multi_search_result_item.rs b/typesense_codegen/src/models/multi_search_result_item.rs index daa3024b..cde46996 100644 --- a/typesense_codegen/src/models/multi_search_result_item.rs +++ b/typesense_codegen/src/models/multi_search_result_item.rs @@ -9,12 +9,13 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct MultiSearchResultItem { +pub struct MultiSearchResultItem<'a, D> { #[serde(rename = "facet_counts", skip_serializing_if = "Option::is_none")] - pub facet_counts: Option>, + pub facet_counts: Option>>, /// The number of documents found #[serde(rename = "found", skip_serializing_if = "Option::is_none")] pub found: Option, @@ -33,20 +34,20 @@ pub struct MultiSearchResultItem { #[serde(rename = "page", skip_serializing_if = "Option::is_none")] pub page: Option, #[serde(rename = "grouped_hits", skip_serializing_if = "Option::is_none")] - pub grouped_hits: Option>>, + pub grouped_hits: Option>>, /// The documents that matched the search query #[serde(rename = "hits", skip_serializing_if = "Option::is_none")] - pub hits: Option>>, + pub hits: Option>>, #[serde(rename = "request_params", skip_serializing_if = "Option::is_none")] - pub request_params: Option>, + pub request_params: Option>>, #[serde(rename = "conversation", skip_serializing_if = "Option::is_none")] - pub conversation: Option>, + pub conversation: Option>>, /// Returned only for union query response. #[serde( rename = "union_request_params", skip_serializing_if = "Option::is_none" )] - pub union_request_params: Option>, + pub union_request_params: Option>>, /// Custom JSON object that can be returned in the search response #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] pub metadata: Option>, @@ -55,12 +56,14 @@ pub struct MultiSearchResultItem { pub code: Option, /// Error description #[serde(rename = "error", skip_serializing_if = "Option::is_none")] - pub error: Option, + pub error: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl MultiSearchResultItem { - pub fn new() -> MultiSearchResultItem { - MultiSearchResultItem { +impl<'a, D> MultiSearchResultItem<'a, D> { + pub fn new() -> Self { + Self { facet_counts: None, found: None, found_docs: None, @@ -76,6 +79,7 @@ impl MultiSearchResultItem { metadata: None, code: None, error: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/multi_search_searches_parameter.rs b/typesense_codegen/src/models/multi_search_searches_parameter.rs index 36cd0624..649f5166 100644 --- a/typesense_codegen/src/models/multi_search_searches_parameter.rs +++ b/typesense_codegen/src/models/multi_search_searches_parameter.rs @@ -9,24 +9,26 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct MultiSearchSearchesParameter { +pub struct MultiSearchSearchesParameter<'a> { /// When true, merges the search results from each search query into a single ordered set of hits. #[serde(rename = "union", skip_serializing_if = "Option::is_none")] pub union: Option, #[serde(rename = "searches")] - pub searches: Vec, + pub searches: Vec>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl MultiSearchSearchesParameter { - pub fn new( - searches: Vec, - ) -> MultiSearchSearchesParameter { - MultiSearchSearchesParameter { +impl<'a> MultiSearchSearchesParameter<'a> { + pub fn new(searches: Vec>) -> Self { + Self { union: None, searches, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/nl_search_model_base.rs b/typesense_codegen/src/models/nl_search_model_base.rs index 5bb066f2..e899ee04 100644 --- a/typesense_codegen/src/models/nl_search_model_base.rs +++ b/typesense_codegen/src/models/nl_search_model_base.rs @@ -9,19 +9,20 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct NlSearchModelBase { +pub struct NlSearchModelBase<'a> { /// Name of the NL model to use #[serde(rename = "model_name", skip_serializing_if = "Option::is_none")] - pub model_name: Option, + pub model_name: Option>, /// API key for the NL model service #[serde(rename = "api_key", skip_serializing_if = "Option::is_none")] - pub api_key: Option, + pub api_key: Option>, /// Custom API URL for the NL model service #[serde(rename = "api_url", skip_serializing_if = "Option::is_none")] - pub api_url: Option, + pub api_url: Option>, /// Maximum number of bytes to process #[serde(rename = "max_bytes", skip_serializing_if = "Option::is_none")] pub max_bytes: Option, @@ -30,7 +31,7 @@ pub struct NlSearchModelBase { pub temperature: Option, /// System prompt for the NL model #[serde(rename = "system_prompt", skip_serializing_if = "Option::is_none")] - pub system_prompt: Option, + pub system_prompt: Option>, /// Top-p parameter for the NL model (Google-specific) #[serde(rename = "top_p", skip_serializing_if = "Option::is_none")] pub top_p: Option, @@ -42,36 +43,38 @@ pub struct NlSearchModelBase { pub stop_sequences: Option>, /// API version for the NL model service #[serde(rename = "api_version", skip_serializing_if = "Option::is_none")] - pub api_version: Option, + pub api_version: Option>, /// Project ID for GCP Vertex AI #[serde(rename = "project_id", skip_serializing_if = "Option::is_none")] - pub project_id: Option, + pub project_id: Option>, /// Access token for GCP Vertex AI #[serde(rename = "access_token", skip_serializing_if = "Option::is_none")] - pub access_token: Option, + pub access_token: Option>, /// Refresh token for GCP Vertex AI #[serde(rename = "refresh_token", skip_serializing_if = "Option::is_none")] - pub refresh_token: Option, + pub refresh_token: Option>, /// Client ID for GCP Vertex AI #[serde(rename = "client_id", skip_serializing_if = "Option::is_none")] - pub client_id: Option, + pub client_id: Option>, /// Client secret for GCP Vertex AI #[serde(rename = "client_secret", skip_serializing_if = "Option::is_none")] - pub client_secret: Option, + pub client_secret: Option>, /// Region for GCP Vertex AI #[serde(rename = "region", skip_serializing_if = "Option::is_none")] - pub region: Option, + pub region: Option>, /// Maximum output tokens for GCP Vertex AI #[serde(rename = "max_output_tokens", skip_serializing_if = "Option::is_none")] pub max_output_tokens: Option, /// Account ID for Cloudflare-specific models #[serde(rename = "account_id", skip_serializing_if = "Option::is_none")] - pub account_id: Option, + pub account_id: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl NlSearchModelBase { - pub fn new() -> NlSearchModelBase { - NlSearchModelBase { +impl<'a> NlSearchModelBase<'a> { + pub fn new() -> Self { + Self { model_name: None, api_key: None, api_url: None, @@ -90,6 +93,7 @@ impl NlSearchModelBase { region: None, max_output_tokens: None, account_id: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/nl_search_model_create_schema.rs b/typesense_codegen/src/models/nl_search_model_create_schema.rs index 34cb2d42..32882a2c 100644 --- a/typesense_codegen/src/models/nl_search_model_create_schema.rs +++ b/typesense_codegen/src/models/nl_search_model_create_schema.rs @@ -9,19 +9,20 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct NlSearchModelCreateSchema { +pub struct NlSearchModelCreateSchema<'a> { /// Name of the NL model to use #[serde(rename = "model_name", skip_serializing_if = "Option::is_none")] - pub model_name: Option, + pub model_name: Option>, /// API key for the NL model service #[serde(rename = "api_key", skip_serializing_if = "Option::is_none")] - pub api_key: Option, + pub api_key: Option>, /// Custom API URL for the NL model service #[serde(rename = "api_url", skip_serializing_if = "Option::is_none")] - pub api_url: Option, + pub api_url: Option>, /// Maximum number of bytes to process #[serde(rename = "max_bytes", skip_serializing_if = "Option::is_none")] pub max_bytes: Option, @@ -30,7 +31,7 @@ pub struct NlSearchModelCreateSchema { pub temperature: Option, /// System prompt for the NL model #[serde(rename = "system_prompt", skip_serializing_if = "Option::is_none")] - pub system_prompt: Option, + pub system_prompt: Option>, /// Top-p parameter for the NL model (Google-specific) #[serde(rename = "top_p", skip_serializing_if = "Option::is_none")] pub top_p: Option, @@ -42,39 +43,41 @@ pub struct NlSearchModelCreateSchema { pub stop_sequences: Option>, /// API version for the NL model service #[serde(rename = "api_version", skip_serializing_if = "Option::is_none")] - pub api_version: Option, + pub api_version: Option>, /// Project ID for GCP Vertex AI #[serde(rename = "project_id", skip_serializing_if = "Option::is_none")] - pub project_id: Option, + pub project_id: Option>, /// Access token for GCP Vertex AI #[serde(rename = "access_token", skip_serializing_if = "Option::is_none")] - pub access_token: Option, + pub access_token: Option>, /// Refresh token for GCP Vertex AI #[serde(rename = "refresh_token", skip_serializing_if = "Option::is_none")] - pub refresh_token: Option, + pub refresh_token: Option>, /// Client ID for GCP Vertex AI #[serde(rename = "client_id", skip_serializing_if = "Option::is_none")] - pub client_id: Option, + pub client_id: Option>, /// Client secret for GCP Vertex AI #[serde(rename = "client_secret", skip_serializing_if = "Option::is_none")] - pub client_secret: Option, + pub client_secret: Option>, /// Region for GCP Vertex AI #[serde(rename = "region", skip_serializing_if = "Option::is_none")] - pub region: Option, + pub region: Option>, /// Maximum output tokens for GCP Vertex AI #[serde(rename = "max_output_tokens", skip_serializing_if = "Option::is_none")] pub max_output_tokens: Option, /// Account ID for Cloudflare-specific models #[serde(rename = "account_id", skip_serializing_if = "Option::is_none")] - pub account_id: Option, + pub account_id: Option>, /// Optional ID for the NL search model #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - pub id: Option, + pub id: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl NlSearchModelCreateSchema { - pub fn new() -> NlSearchModelCreateSchema { - NlSearchModelCreateSchema { +impl<'a> NlSearchModelCreateSchema<'a> { + pub fn new() -> Self { + Self { model_name: None, api_key: None, api_url: None, @@ -94,6 +97,7 @@ impl NlSearchModelCreateSchema { max_output_tokens: None, account_id: None, id: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/nl_search_model_delete_schema.rs b/typesense_codegen/src/models/nl_search_model_delete_schema.rs index f31df7d6..fa187d83 100644 --- a/typesense_codegen/src/models/nl_search_model_delete_schema.rs +++ b/typesense_codegen/src/models/nl_search_model_delete_schema.rs @@ -9,17 +9,23 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct NlSearchModelDeleteSchema { +pub struct NlSearchModelDeleteSchema<'a> { /// ID of the deleted NL search model #[serde(rename = "id")] - pub id: String, + pub id: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl NlSearchModelDeleteSchema { - pub fn new(id: String) -> NlSearchModelDeleteSchema { - NlSearchModelDeleteSchema { id } +impl<'a> NlSearchModelDeleteSchema<'a> { + pub fn new(id: Cow<'a, str>) -> Self { + Self { + id, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/nl_search_model_schema.rs b/typesense_codegen/src/models/nl_search_model_schema.rs index b2066e06..76a616d3 100644 --- a/typesense_codegen/src/models/nl_search_model_schema.rs +++ b/typesense_codegen/src/models/nl_search_model_schema.rs @@ -9,19 +9,20 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct NlSearchModelSchema { +pub struct NlSearchModelSchema<'a> { /// Name of the NL model to use #[serde(rename = "model_name", skip_serializing_if = "Option::is_none")] - pub model_name: Option, + pub model_name: Option>, /// API key for the NL model service #[serde(rename = "api_key", skip_serializing_if = "Option::is_none")] - pub api_key: Option, + pub api_key: Option>, /// Custom API URL for the NL model service #[serde(rename = "api_url", skip_serializing_if = "Option::is_none")] - pub api_url: Option, + pub api_url: Option>, /// Maximum number of bytes to process #[serde(rename = "max_bytes", skip_serializing_if = "Option::is_none")] pub max_bytes: Option, @@ -30,7 +31,7 @@ pub struct NlSearchModelSchema { pub temperature: Option, /// System prompt for the NL model #[serde(rename = "system_prompt", skip_serializing_if = "Option::is_none")] - pub system_prompt: Option, + pub system_prompt: Option>, /// Top-p parameter for the NL model (Google-specific) #[serde(rename = "top_p", skip_serializing_if = "Option::is_none")] pub top_p: Option, @@ -42,39 +43,41 @@ pub struct NlSearchModelSchema { pub stop_sequences: Option>, /// API version for the NL model service #[serde(rename = "api_version", skip_serializing_if = "Option::is_none")] - pub api_version: Option, + pub api_version: Option>, /// Project ID for GCP Vertex AI #[serde(rename = "project_id", skip_serializing_if = "Option::is_none")] - pub project_id: Option, + pub project_id: Option>, /// Access token for GCP Vertex AI #[serde(rename = "access_token", skip_serializing_if = "Option::is_none")] - pub access_token: Option, + pub access_token: Option>, /// Refresh token for GCP Vertex AI #[serde(rename = "refresh_token", skip_serializing_if = "Option::is_none")] - pub refresh_token: Option, + pub refresh_token: Option>, /// Client ID for GCP Vertex AI #[serde(rename = "client_id", skip_serializing_if = "Option::is_none")] - pub client_id: Option, + pub client_id: Option>, /// Client secret for GCP Vertex AI #[serde(rename = "client_secret", skip_serializing_if = "Option::is_none")] - pub client_secret: Option, + pub client_secret: Option>, /// Region for GCP Vertex AI #[serde(rename = "region", skip_serializing_if = "Option::is_none")] - pub region: Option, + pub region: Option>, /// Maximum output tokens for GCP Vertex AI #[serde(rename = "max_output_tokens", skip_serializing_if = "Option::is_none")] pub max_output_tokens: Option, /// Account ID for Cloudflare-specific models #[serde(rename = "account_id", skip_serializing_if = "Option::is_none")] - pub account_id: Option, + pub account_id: Option>, /// ID of the NL search model #[serde(rename = "id")] - pub id: String, + pub id: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl NlSearchModelSchema { - pub fn new(id: String) -> NlSearchModelSchema { - NlSearchModelSchema { +impl<'a> NlSearchModelSchema<'a> { + pub fn new(id: Cow<'a, str>) -> Self { + Self { model_name: None, api_key: None, api_url: None, @@ -94,6 +97,7 @@ impl NlSearchModelSchema { max_output_tokens: None, account_id: None, id, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/preset_delete_schema.rs b/typesense_codegen/src/models/preset_delete_schema.rs index 52037962..a3607b83 100644 --- a/typesense_codegen/src/models/preset_delete_schema.rs +++ b/typesense_codegen/src/models/preset_delete_schema.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct PresetDeleteSchema { +pub struct PresetDeleteSchema<'a> { #[serde(rename = "name")] - pub name: String, + pub name: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl PresetDeleteSchema { - pub fn new(name: String) -> PresetDeleteSchema { - PresetDeleteSchema { name } +impl<'a> PresetDeleteSchema<'a> { + pub fn new(name: Cow<'a, str>) -> Self { + Self { + name, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/preset_schema.rs b/typesense_codegen/src/models/preset_schema.rs index c12caca5..5233007b 100644 --- a/typesense_codegen/src/models/preset_schema.rs +++ b/typesense_codegen/src/models/preset_schema.rs @@ -9,21 +9,25 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct PresetSchema { +pub struct PresetSchema<'a> { #[serde(rename = "value")] - pub value: Box, + pub value: Box>, #[serde(rename = "name")] - pub name: String, + pub name: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl PresetSchema { - pub fn new(value: models::PresetUpsertSchemaValue, name: String) -> PresetSchema { - PresetSchema { +impl<'a> PresetSchema<'a> { + pub fn new(value: models::PresetUpsertSchemaValue<'a>, name: Cow<'a, str>) -> Self { + Self { value: Box::new(value), name, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/preset_upsert_schema.rs b/typesense_codegen/src/models/preset_upsert_schema.rs index 92eff0dc..b9fb8a05 100644 --- a/typesense_codegen/src/models/preset_upsert_schema.rs +++ b/typesense_codegen/src/models/preset_upsert_schema.rs @@ -9,18 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct PresetUpsertSchema { +pub struct PresetUpsertSchema<'a> { #[serde(rename = "value")] - pub value: Box, + pub value: Box>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl PresetUpsertSchema { - pub fn new(value: models::PresetUpsertSchemaValue) -> PresetUpsertSchema { - PresetUpsertSchema { +impl<'a> PresetUpsertSchema<'a> { + pub fn new(value: models::PresetUpsertSchemaValue<'a>) -> Self { + Self { value: Box::new(value), + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/preset_upsert_schema_value.rs b/typesense_codegen/src/models/preset_upsert_schema_value.rs index 43335aa6..b5800d88 100644 --- a/typesense_codegen/src/models/preset_upsert_schema_value.rs +++ b/typesense_codegen/src/models/preset_upsert_schema_value.rs @@ -9,16 +9,17 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum PresetUpsertSchemaValue { - SearchParameters(Box), - MultiSearchSearchesParameter(Box), +pub enum PresetUpsertSchemaValue<'a> { + SearchParameters(Box>), + MultiSearchSearchesParameter(Box>), } -impl Default for PresetUpsertSchemaValue { +impl Default for PresetUpsertSchemaValue<'_> { fn default() -> Self { Self::SearchParameters(Default::default()) } diff --git a/typesense_codegen/src/models/presets_retrieve_schema.rs b/typesense_codegen/src/models/presets_retrieve_schema.rs index e64ecf18..5f6dffe8 100644 --- a/typesense_codegen/src/models/presets_retrieve_schema.rs +++ b/typesense_codegen/src/models/presets_retrieve_schema.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct PresetsRetrieveSchema { +pub struct PresetsRetrieveSchema<'a> { #[serde(rename = "presets")] - pub presets: Vec, + pub presets: Vec>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl PresetsRetrieveSchema { - pub fn new(presets: Vec) -> PresetsRetrieveSchema { - PresetsRetrieveSchema { presets } +impl<'a> PresetsRetrieveSchema<'a> { + pub fn new(presets: Vec>) -> Self { + Self { + presets, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/schema_change_status.rs b/typesense_codegen/src/models/schema_change_status.rs index 22bb4109..726d8132 100644 --- a/typesense_codegen/src/models/schema_change_status.rs +++ b/typesense_codegen/src/models/schema_change_status.rs @@ -9,27 +9,31 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SchemaChangeStatus { +pub struct SchemaChangeStatus<'a> { /// Name of the collection being modified #[serde(rename = "collection", skip_serializing_if = "Option::is_none")] - pub collection: Option, + pub collection: Option>, /// Number of documents that have been validated #[serde(rename = "validated_docs", skip_serializing_if = "Option::is_none")] pub validated_docs: Option, /// Number of documents that have been altered #[serde(rename = "altered_docs", skip_serializing_if = "Option::is_none")] pub altered_docs: Option, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SchemaChangeStatus { - pub fn new() -> SchemaChangeStatus { - SchemaChangeStatus { +impl<'a> SchemaChangeStatus<'a> { + pub fn new() -> Self { + Self { collection: None, validated_docs: None, altered_docs: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_grouped_hit.rs b/typesense_codegen/src/models/search_grouped_hit.rs index 434b8fcd..9401a5f7 100644 --- a/typesense_codegen/src/models/search_grouped_hit.rs +++ b/typesense_codegen/src/models/search_grouped_hit.rs @@ -9,28 +9,32 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchGroupedHit { +pub struct SearchGroupedHit<'a, D> { #[serde(rename = "found", skip_serializing_if = "Option::is_none")] pub found: Option, #[serde(rename = "group_key")] pub group_key: Vec, /// The documents that matched the search query #[serde(rename = "hits")] - pub hits: Vec>, + pub hits: Vec>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SearchGroupedHit { +impl<'a, D> SearchGroupedHit<'a, D> { pub fn new( group_key: Vec, - hits: Vec>, - ) -> SearchGroupedHit { - SearchGroupedHit { + hits: Vec>, + ) -> Self { + Self { found: None, group_key, hits, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_highlight.rs b/typesense_codegen/src/models/search_highlight.rs index c45afcc4..ae05e107 100644 --- a/typesense_codegen/src/models/search_highlight.rs +++ b/typesense_codegen/src/models/search_highlight.rs @@ -9,21 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchHighlight { +pub struct SearchHighlight<'a> { #[serde(rename = "field", skip_serializing_if = "Option::is_none")] - pub field: Option, + pub field: Option>, /// Present only for (non-array) string fields #[serde(rename = "snippet", skip_serializing_if = "Option::is_none")] - pub snippet: Option, + pub snippet: Option>, /// Present only for (array) string[] fields #[serde(rename = "snippets", skip_serializing_if = "Option::is_none")] pub snippets: Option>, /// Full field value with highlighting, present only for (non-array) string fields #[serde(rename = "value", skip_serializing_if = "Option::is_none")] - pub value: Option, + pub value: Option>, /// Full field value with highlighting, present only for (array) string[] fields #[serde(rename = "values", skip_serializing_if = "Option::is_none")] pub values: Option>, @@ -32,11 +33,13 @@ pub struct SearchHighlight { pub indices: Option>, #[serde(rename = "matched_tokens", skip_serializing_if = "Option::is_none")] pub matched_tokens: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SearchHighlight { - pub fn new() -> SearchHighlight { - SearchHighlight { +impl<'a> SearchHighlight<'a> { + pub fn new() -> Self { + Self { field: None, snippet: None, snippets: None, @@ -44,6 +47,7 @@ impl SearchHighlight { values: None, indices: None, matched_tokens: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_parameters.rs b/typesense_codegen/src/models/search_parameters.rs index 860beff3..be6c4052 100644 --- a/typesense_codegen/src/models/search_parameters.rs +++ b/typesense_codegen/src/models/search_parameters.rs @@ -9,36 +9,38 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(bon::Builder)] +#[builder(on(Cow<'_, str>, into))] #[builder(on(String, into))] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchParameters { +pub struct SearchParameters<'a> { /// The query text to search for in the collection. Use * as the search string to return all documents. This is typically useful when used in conjunction with filter_by. #[serde(rename = "q", skip_serializing_if = "Option::is_none")] - pub q: Option, + pub q: Option>, /// A list of `string` fields that should be queried against. Multiple fields are separated with a comma. #[serde(rename = "query_by", skip_serializing_if = "Option::is_none")] - pub query_by: Option, + pub query_by: Option>, /// Whether to use natural language processing to parse the query. #[serde(rename = "nl_query", skip_serializing_if = "Option::is_none")] pub nl_query: Option, /// The ID of the natural language model to use. #[serde(rename = "nl_model_id", skip_serializing_if = "Option::is_none")] - pub nl_model_id: Option, + pub nl_model_id: Option>, /// The relative weight to give each `query_by` field when ranking results. This can be used to boost fields in priority, when looking for matches. Multiple fields are separated with a comma. #[serde(rename = "query_by_weights", skip_serializing_if = "Option::is_none")] - pub query_by_weights: Option, + pub query_by_weights: Option>, /// In a multi-field matching context, this parameter determines how the representative text match score of a record is calculated. Possible values are max_score (default) or max_weight. #[serde(rename = "text_match_type", skip_serializing_if = "Option::is_none")] - pub text_match_type: Option, + pub text_match_type: Option>, /// Boolean field to indicate that the last word in the query should be treated as a prefix, and not as a whole word. This is used for building autocomplete and instant search interfaces. Defaults to true. #[serde(rename = "prefix", skip_serializing_if = "Option::is_none")] - pub prefix: Option, + pub prefix: Option>, /// If infix index is enabled for this field, infix searching can be done on a per-field basis by sending a comma separated string parameter called infix to the search query. This parameter can have 3 values; `off` infix search is disabled, which is default `always` infix search is performed along with regular search `fallback` infix search is performed if regular search does not produce results #[serde(rename = "infix", skip_serializing_if = "Option::is_none")] - pub infix: Option, + pub infix: Option>, /// There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query \"K2100\" has 2 extra symbols in \"6PK2100\". By default, any number of prefixes/suffixes can be present for a match. #[serde(rename = "max_extra_prefix", skip_serializing_if = "Option::is_none")] pub max_extra_prefix: Option, @@ -47,7 +49,7 @@ pub struct SearchParameters { pub max_extra_suffix: Option, /// Filter conditions for refining your open api validator search results. Separate multiple conditions with &&. #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] - pub filter_by: Option, + pub filter_by: Option>, /// Controls the number of similar words that Typesense considers during fuzzy search on filter_by values. Useful for controlling prefix matches like company_name:Acm*. #[serde( rename = "max_filter_by_candidates", @@ -56,19 +58,19 @@ pub struct SearchParameters { pub max_filter_by_candidates: Option, /// A list of numerical fields and their corresponding sort orders that will be used for ordering your results. Up to 3 sort fields can be specified. The text similarity score is exposed as a special `_text_match` field that you can use in the list of sorting fields. If no `sort_by` parameter is specified, results are sorted by `_text_match:desc,default_sorting_field:desc` #[serde(rename = "sort_by", skip_serializing_if = "Option::is_none")] - pub sort_by: Option, + pub sort_by: Option>, /// A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. #[serde(rename = "facet_by", skip_serializing_if = "Option::is_none")] - pub facet_by: Option, + pub facet_by: Option>, /// Maximum number of facet values to be returned. #[serde(rename = "max_facet_values", skip_serializing_if = "Option::is_none")] pub max_facet_values: Option, /// Facet values that are returned can now be filtered via this parameter. The matching facet text is also highlighted. For example, when faceting by `category`, you can set `facet_query=category:shoe` to return only facet values that contain the prefix \"shoe\". #[serde(rename = "facet_query", skip_serializing_if = "Option::is_none")] - pub facet_query: Option, + pub facet_query: Option>, /// The number of typographical errors (1 or 2) that would be tolerated. Default: 2 #[serde(rename = "num_typos", skip_serializing_if = "Option::is_none")] - pub num_typos: Option, + pub num_typos: Option>, /// Results from this specific page number would be fetched. #[serde(rename = "page", skip_serializing_if = "Option::is_none")] pub page: Option, @@ -83,7 +85,7 @@ pub struct SearchParameters { pub offset: Option, /// You can aggregate search results into groups or buckets by specify one or more `group_by` fields. Separate multiple fields with a comma. To group on a particular field, it must be a faceted field. #[serde(rename = "group_by", skip_serializing_if = "Option::is_none")] - pub group_by: Option, + pub group_by: Option>, /// Maximum number of hits to be returned for every group. If the `group_limit` is set as `K` then only the top K hits in each group are returned in the response. Default: 3 #[serde(rename = "group_limit", skip_serializing_if = "Option::is_none")] pub group_limit: Option, @@ -95,16 +97,16 @@ pub struct SearchParameters { pub group_missing_values: Option, /// List of fields from the document to include in the search result #[serde(rename = "include_fields", skip_serializing_if = "Option::is_none")] - pub include_fields: Option, + pub include_fields: Option>, /// List of fields from the document to exclude in the search result #[serde(rename = "exclude_fields", skip_serializing_if = "Option::is_none")] - pub exclude_fields: Option, + pub exclude_fields: Option>, /// List of fields which should be highlighted fully without snippeting #[serde( rename = "highlight_full_fields", skip_serializing_if = "Option::is_none" )] - pub highlight_full_fields: Option, + pub highlight_full_fields: Option>, /// The number of tokens that should surround the highlighted text on each side. Default: 4 #[serde( rename = "highlight_affix_num_tokens", @@ -116,10 +118,10 @@ pub struct SearchParameters { rename = "highlight_start_tag", skip_serializing_if = "Option::is_none" )] - pub highlight_start_tag: Option, + pub highlight_start_tag: Option>, /// The end tag used for the highlighted snippets. Default: `` #[serde(rename = "highlight_end_tag", skip_serializing_if = "Option::is_none")] - pub highlight_end_tag: Option, + pub highlight_end_tag: Option>, /// Flag for enabling/disabling the deprecated, old highlight structure in the response. Default: true #[serde( rename = "enable_highlight_v1", @@ -134,7 +136,7 @@ pub struct SearchParameters { pub snippet_threshold: Option, /// List of synonym set names to associate with this search query #[serde(rename = "synonym_sets", skip_serializing_if = "Option::is_none")] - pub synonym_sets: Option, + pub synonym_sets: Option>, /// If the number of results found for a specific query is less than this number, Typesense will attempt to drop the tokens in the query until enough results are found. Tokens that have the least individual hits are dropped first. Set to 0 to disable. Default: 10 #[serde( rename = "drop_tokens_threshold", @@ -172,19 +174,19 @@ pub struct SearchParameters { pub synonym_num_typos: Option, /// A list of records to unconditionally include in the search results at specific positions. An example use case would be to feature or promote certain items on the top of search results. A list of `record_id:hit_position`. Eg: to include a record with ID 123 at Position 1 and another record with ID 456 at Position 5, you'd specify `123:1,456:5`. You could also use the Overrides feature to override search results based on rules. Overrides are applied first, followed by `pinned_hits` and finally `hidden_hits`. #[serde(rename = "pinned_hits", skip_serializing_if = "Option::is_none")] - pub pinned_hits: Option, + pub pinned_hits: Option>, /// A list of records to unconditionally hide from search results. A list of `record_id`s to hide. Eg: to hide records with IDs 123 and 456, you'd specify `123,456`. You could also use the Overrides feature to override search results based on rules. Overrides are applied first, followed by `pinned_hits` and finally `hidden_hits`. #[serde(rename = "hidden_hits", skip_serializing_if = "Option::is_none")] - pub hidden_hits: Option, + pub hidden_hits: Option>, /// Comma separated list of tags to trigger the curations rules that match the tags. #[serde(rename = "override_tags", skip_serializing_if = "Option::is_none")] - pub override_tags: Option, + pub override_tags: Option>, /// A list of custom fields that must be highlighted even if you don't query for them #[serde(rename = "highlight_fields", skip_serializing_if = "Option::is_none")] - pub highlight_fields: Option, + pub highlight_fields: Option>, /// Treat space as typo: search for q=basket ball if q=basketball is not found or vice-versa. Splitting/joining of tokens will only be attempted if the original query produces no results. To always trigger this behavior, set value to `always``. To disable, set value to `off`. Default is `fallback`. #[serde(rename = "split_join_tokens", skip_serializing_if = "Option::is_none")] - pub split_join_tokens: Option, + pub split_join_tokens: Option>, /// You can index content from any logographic language into Typesense if you are able to segment / split the text into space-separated words yourself before indexing and querying. Set this parameter to true to do the same #[serde( rename = "pre_segmented_query", @@ -193,7 +195,7 @@ pub struct SearchParameters { pub pre_segmented_query: Option, /// Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. #[serde(rename = "preset", skip_serializing_if = "Option::is_none")] - pub preset: Option, + pub preset: Option>, /// If you have some overrides defined but want to disable all of them during query time, you can do that by setting this parameter to false #[serde(rename = "enable_overrides", skip_serializing_if = "Option::is_none")] pub enable_overrides: Option, @@ -244,7 +246,7 @@ pub struct SearchParameters { pub min_len_2typo: Option, /// Vector query expression for fetching documents \"closest\" to a given query/document vector. #[serde(rename = "vector_query", skip_serializing_if = "Option::is_none")] - pub vector_query: Option, + pub vector_query: Option>, /// Timeout (in milliseconds) for fetching remote embeddings. #[serde( rename = "remote_embedding_timeout_ms", @@ -259,19 +261,19 @@ pub struct SearchParameters { pub remote_embedding_num_tries: Option, /// Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). #[serde(rename = "facet_strategy", skip_serializing_if = "Option::is_none")] - pub facet_strategy: Option, + pub facet_strategy: Option>, /// Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query. #[serde(rename = "stopwords", skip_serializing_if = "Option::is_none")] - pub stopwords: Option, + pub stopwords: Option>, /// Comma separated string of nested facet fields whose parent object should be returned in facet response. #[serde( rename = "facet_return_parent", skip_serializing_if = "Option::is_none" )] - pub facet_return_parent: Option, + pub facet_return_parent: Option>, /// The base64 encoded audio file in 16 khz 16-bit WAV format. #[serde(rename = "voice_query", skip_serializing_if = "Option::is_none")] - pub voice_query: Option, + pub voice_query: Option>, /// Enable conversational search. #[serde(rename = "conversation", skip_serializing_if = "Option::is_none")] pub conversation: Option, @@ -280,15 +282,18 @@ pub struct SearchParameters { rename = "conversation_model_id", skip_serializing_if = "Option::is_none" )] - pub conversation_model_id: Option, + pub conversation_model_id: Option>, /// The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. #[serde(rename = "conversation_id", skip_serializing_if = "Option::is_none")] - pub conversation_id: Option, + pub conversation_id: Option>, + #[serde(skip)] + #[builder(default)] + pub _phantom: PhantomData<&'a ()>, } -impl SearchParameters { - pub fn new() -> SearchParameters { - SearchParameters { +impl<'a> SearchParameters<'a> { + pub fn new() -> Self { + Self { q: None, query_by: None, nl_query: None, @@ -360,6 +365,7 @@ impl SearchParameters { conversation: None, conversation_model_id: None, conversation_id: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_request_params.rs b/typesense_codegen/src/models/search_request_params.rs index 7e67048b..333935d6 100644 --- a/typesense_codegen/src/models/search_request_params.rs +++ b/typesense_codegen/src/models/search_request_params.rs @@ -9,27 +9,31 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchRequestParams { +pub struct SearchRequestParams<'a> { #[serde(rename = "collection_name")] - pub collection_name: String, + pub collection_name: Cow<'a, str>, #[serde(rename = "q")] - pub q: String, + pub q: Cow<'a, str>, #[serde(rename = "per_page")] pub per_page: i32, #[serde(rename = "voice_query", skip_serializing_if = "Option::is_none")] - pub voice_query: Option>, + pub voice_query: Option>>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SearchRequestParams { - pub fn new(collection_name: String, q: String, per_page: i32) -> SearchRequestParams { - SearchRequestParams { +impl<'a> SearchRequestParams<'a> { + pub fn new(collection_name: Cow<'a, str>, q: Cow<'a, str>, per_page: i32) -> Self { + Self { collection_name, q, per_page, voice_query: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_request_params_voice_query.rs b/typesense_codegen/src/models/search_request_params_voice_query.rs index 97e78ef4..ea18775d 100644 --- a/typesense_codegen/src/models/search_request_params_voice_query.rs +++ b/typesense_codegen/src/models/search_request_params_voice_query.rs @@ -9,18 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchRequestParamsVoiceQuery { +pub struct SearchRequestParamsVoiceQuery<'a> { #[serde(rename = "transcribed_query", skip_serializing_if = "Option::is_none")] - pub transcribed_query: Option, + pub transcribed_query: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SearchRequestParamsVoiceQuery { - pub fn new() -> SearchRequestParamsVoiceQuery { - SearchRequestParamsVoiceQuery { +impl<'a> SearchRequestParamsVoiceQuery<'a> { + pub fn new() -> Self { + Self { transcribed_query: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_result.rs b/typesense_codegen/src/models/search_result.rs index 1805210c..a03c1428 100644 --- a/typesense_codegen/src/models/search_result.rs +++ b/typesense_codegen/src/models/search_result.rs @@ -9,12 +9,13 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchResult { +pub struct SearchResult<'a, D> { #[serde(rename = "facet_counts", skip_serializing_if = "Option::is_none")] - pub facet_counts: Option>, + pub facet_counts: Option>>, /// The number of documents found #[serde(rename = "found", skip_serializing_if = "Option::is_none")] pub found: Option, @@ -33,28 +34,30 @@ pub struct SearchResult { #[serde(rename = "page", skip_serializing_if = "Option::is_none")] pub page: Option, #[serde(rename = "grouped_hits", skip_serializing_if = "Option::is_none")] - pub grouped_hits: Option>>, + pub grouped_hits: Option>>, /// The documents that matched the search query #[serde(rename = "hits", skip_serializing_if = "Option::is_none")] - pub hits: Option>>, + pub hits: Option>>, #[serde(rename = "request_params", skip_serializing_if = "Option::is_none")] - pub request_params: Option>, + pub request_params: Option>>, #[serde(rename = "conversation", skip_serializing_if = "Option::is_none")] - pub conversation: Option>, + pub conversation: Option>>, /// Returned only for union query response. #[serde( rename = "union_request_params", skip_serializing_if = "Option::is_none" )] - pub union_request_params: Option>, + pub union_request_params: Option>>, /// Custom JSON object that can be returned in the search response #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] pub metadata: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SearchResult { - pub fn new() -> SearchResult { - SearchResult { +impl<'a, D> SearchResult<'a, D> { + pub fn new() -> Self { + Self { facet_counts: None, found: None, found_docs: None, @@ -68,6 +71,7 @@ impl SearchResult { conversation: None, union_request_params: None, metadata: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_result_conversation.rs b/typesense_codegen/src/models/search_result_conversation.rs index 380be441..58cee0e0 100644 --- a/typesense_codegen/src/models/search_result_conversation.rs +++ b/typesense_codegen/src/models/search_result_conversation.rs @@ -9,32 +9,36 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchResultConversation { +pub struct SearchResultConversation<'a> { #[serde(rename = "answer")] - pub answer: String, + pub answer: Cow<'a, str>, #[serde(rename = "conversation_history")] pub conversation_history: Vec, #[serde(rename = "conversation_id")] - pub conversation_id: String, + pub conversation_id: Cow<'a, str>, #[serde(rename = "query")] - pub query: String, + pub query: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SearchResultConversation { +impl<'a> SearchResultConversation<'a> { pub fn new( - answer: String, + answer: Cow<'a, str>, conversation_history: Vec, - conversation_id: String, - query: String, - ) -> SearchResultConversation { - SearchResultConversation { + conversation_id: Cow<'a, str>, + query: Cow<'a, str>, + ) -> Self { + Self { answer, conversation_history, conversation_id, query, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_result_hit.rs b/typesense_codegen/src/models/search_result_hit.rs index abe92e43..30a84a17 100644 --- a/typesense_codegen/src/models/search_result_hit.rs +++ b/typesense_codegen/src/models/search_result_hit.rs @@ -9,13 +9,14 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchResultHit { +pub struct SearchResultHit<'a, D> { /// (Deprecated) Contains highlighted portions of the search fields #[serde(rename = "highlights", skip_serializing_if = "Option::is_none")] - pub highlights: Option>, + pub highlights: Option>>, /// Highlighted version of the matching document #[serde(rename = "highlight", skip_serializing_if = "Option::is_none")] pub highlight: Option>, @@ -25,7 +26,7 @@ pub struct SearchResultHit { #[serde(rename = "text_match", skip_serializing_if = "Option::is_none")] pub text_match: Option, #[serde(rename = "text_match_info", skip_serializing_if = "Option::is_none")] - pub text_match_info: Option>, + pub text_match_info: Option>>, /// Can be any key-value pair #[serde( rename = "geo_distance_meters", @@ -36,15 +37,17 @@ pub struct SearchResultHit { #[serde(rename = "vector_distance", skip_serializing_if = "Option::is_none")] pub vector_distance: Option, #[serde(rename = "hybrid_search_info", skip_serializing_if = "Option::is_none")] - pub hybrid_search_info: Option>, + pub hybrid_search_info: Option>>, /// Returned only for union query response. Indicates the index of the query which this document matched to. #[serde(rename = "search_index", skip_serializing_if = "Option::is_none")] pub search_index: Option, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SearchResultHit { - pub fn new() -> SearchResultHit { - SearchResultHit { +impl<'a, D> SearchResultHit<'a, D> { + pub fn new() -> Self { + Self { highlights: None, highlight: None, document: None, @@ -54,6 +57,7 @@ impl SearchResultHit { vector_distance: None, hybrid_search_info: None, search_index: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_result_hit_hybrid_search_info.rs b/typesense_codegen/src/models/search_result_hit_hybrid_search_info.rs index ed0bea0a..ee83a376 100644 --- a/typesense_codegen/src/models/search_result_hit_hybrid_search_info.rs +++ b/typesense_codegen/src/models/search_result_hit_hybrid_search_info.rs @@ -9,21 +9,25 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; /// SearchResultHitHybridSearchInfo : Information about hybrid search scoring #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchResultHitHybridSearchInfo { +pub struct SearchResultHitHybridSearchInfo<'a> { /// Combined score from rank fusion of text and vector search #[serde(rename = "rank_fusion_score", skip_serializing_if = "Option::is_none")] pub rank_fusion_score: Option, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SearchResultHitHybridSearchInfo { +impl<'a> SearchResultHitHybridSearchInfo<'a> { /// Information about hybrid search scoring - pub fn new() -> SearchResultHitHybridSearchInfo { - SearchResultHitHybridSearchInfo { + pub fn new() -> Self { + Self { rank_fusion_score: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_result_hit_text_match_info.rs b/typesense_codegen/src/models/search_result_hit_text_match_info.rs index e77c40fc..bbb27f14 100644 --- a/typesense_codegen/src/models/search_result_hit_text_match_info.rs +++ b/typesense_codegen/src/models/search_result_hit_text_match_info.rs @@ -9,12 +9,13 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchResultHitTextMatchInfo { +pub struct SearchResultHitTextMatchInfo<'a> { #[serde(rename = "best_field_score", skip_serializing_if = "Option::is_none")] - pub best_field_score: Option, + pub best_field_score: Option>, #[serde(rename = "best_field_weight", skip_serializing_if = "Option::is_none")] pub best_field_weight: Option, #[serde(rename = "fields_matched", skip_serializing_if = "Option::is_none")] @@ -22,16 +23,18 @@ pub struct SearchResultHitTextMatchInfo { #[serde(rename = "num_tokens_dropped", skip_serializing_if = "Option::is_none")] pub num_tokens_dropped: Option, #[serde(rename = "score", skip_serializing_if = "Option::is_none")] - pub score: Option, + pub score: Option>, #[serde(rename = "tokens_matched", skip_serializing_if = "Option::is_none")] pub tokens_matched: Option, #[serde(rename = "typo_prefix_score", skip_serializing_if = "Option::is_none")] pub typo_prefix_score: Option, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SearchResultHitTextMatchInfo { - pub fn new() -> SearchResultHitTextMatchInfo { - SearchResultHitTextMatchInfo { +impl<'a> SearchResultHitTextMatchInfo<'a> { + pub fn new() -> Self { + Self { best_field_score: None, best_field_weight: None, fields_matched: None, @@ -39,6 +42,7 @@ impl SearchResultHitTextMatchInfo { score: None, tokens_matched: None, typo_prefix_score: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_synonym.rs b/typesense_codegen/src/models/search_synonym.rs index 3d81eb7b..0100d250 100644 --- a/typesense_codegen/src/models/search_synonym.rs +++ b/typesense_codegen/src/models/search_synonym.rs @@ -9,34 +9,38 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchSynonym { +pub struct SearchSynonym<'a> { /// For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. #[serde(rename = "root", skip_serializing_if = "Option::is_none")] - pub root: Option, + pub root: Option>, /// Array of words that should be considered as synonyms. #[serde(rename = "synonyms")] pub synonyms: Vec, /// Locale for the synonym, leave blank to use the standard tokenizer. #[serde(rename = "locale", skip_serializing_if = "Option::is_none")] - pub locale: Option, + pub locale: Option>, /// By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is. #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] pub symbols_to_index: Option>, #[serde(rename = "id")] - pub id: String, + pub id: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SearchSynonym { - pub fn new(synonyms: Vec, id: String) -> SearchSynonym { - SearchSynonym { +impl<'a> SearchSynonym<'a> { + pub fn new(synonyms: Vec, id: Cow<'a, str>) -> Self { + Self { root: None, synonyms, locale: None, symbols_to_index: None, id, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_synonym_delete_response.rs b/typesense_codegen/src/models/search_synonym_delete_response.rs index c69e47bd..988df8de 100644 --- a/typesense_codegen/src/models/search_synonym_delete_response.rs +++ b/typesense_codegen/src/models/search_synonym_delete_response.rs @@ -9,17 +9,23 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchSynonymDeleteResponse { +pub struct SearchSynonymDeleteResponse<'a> { /// The id of the synonym that was deleted #[serde(rename = "id")] - pub id: String, + pub id: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SearchSynonymDeleteResponse { - pub fn new(id: String) -> SearchSynonymDeleteResponse { - SearchSynonymDeleteResponse { id } +impl<'a> SearchSynonymDeleteResponse<'a> { + pub fn new(id: Cow<'a, str>) -> Self { + Self { + id, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/search_synonym_schema.rs b/typesense_codegen/src/models/search_synonym_schema.rs index 192829fb..c560d46d 100644 --- a/typesense_codegen/src/models/search_synonym_schema.rs +++ b/typesense_codegen/src/models/search_synonym_schema.rs @@ -9,31 +9,35 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchSynonymSchema { +pub struct SearchSynonymSchema<'a> { /// For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. #[serde(rename = "root", skip_serializing_if = "Option::is_none")] - pub root: Option, + pub root: Option>, /// Array of words that should be considered as synonyms. #[serde(rename = "synonyms")] pub synonyms: Vec, /// Locale for the synonym, leave blank to use the standard tokenizer. #[serde(rename = "locale", skip_serializing_if = "Option::is_none")] - pub locale: Option, + pub locale: Option>, /// By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is. #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] pub symbols_to_index: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SearchSynonymSchema { - pub fn new(synonyms: Vec) -> SearchSynonymSchema { - SearchSynonymSchema { +impl<'a> SearchSynonymSchema<'a> { + pub fn new(synonyms: Vec) -> Self { + Self { root: None, synonyms, locale: None, symbols_to_index: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_synonyms_response.rs b/typesense_codegen/src/models/search_synonyms_response.rs index 40434caf..ba1bc426 100644 --- a/typesense_codegen/src/models/search_synonyms_response.rs +++ b/typesense_codegen/src/models/search_synonyms_response.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchSynonymsResponse { +pub struct SearchSynonymsResponse<'a> { #[serde(rename = "synonyms")] - pub synonyms: Vec, + pub synonyms: Vec>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SearchSynonymsResponse { - pub fn new(synonyms: Vec) -> SearchSynonymsResponse { - SearchSynonymsResponse { synonyms } +impl<'a> SearchSynonymsResponse<'a> { + pub fn new(synonyms: Vec>) -> Self { + Self { + synonyms, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/stemming_dictionary.rs b/typesense_codegen/src/models/stemming_dictionary.rs index e90942cb..0f51b24a 100644 --- a/typesense_codegen/src/models/stemming_dictionary.rs +++ b/typesense_codegen/src/models/stemming_dictionary.rs @@ -9,20 +9,27 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct StemmingDictionary { +pub struct StemmingDictionary<'a> { /// Unique identifier for the dictionary #[serde(rename = "id")] - pub id: String, + pub id: Cow<'a, str>, /// List of word mappings in the dictionary #[serde(rename = "words")] - pub words: Vec, + pub words: Vec>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl StemmingDictionary { - pub fn new(id: String, words: Vec) -> StemmingDictionary { - StemmingDictionary { id, words } +impl<'a> StemmingDictionary<'a> { + pub fn new(id: Cow<'a, str>, words: Vec>) -> Self { + Self { + id, + words, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/stemming_dictionary_words_inner.rs b/typesense_codegen/src/models/stemming_dictionary_words_inner.rs index 30cbd401..7f82248e 100644 --- a/typesense_codegen/src/models/stemming_dictionary_words_inner.rs +++ b/typesense_codegen/src/models/stemming_dictionary_words_inner.rs @@ -9,20 +9,27 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct StemmingDictionaryWordsInner { +pub struct StemmingDictionaryWordsInner<'a> { /// The word form to be stemmed #[serde(rename = "word")] - pub word: String, + pub word: Cow<'a, str>, /// The root form of the word #[serde(rename = "root")] - pub root: String, + pub root: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl StemmingDictionaryWordsInner { - pub fn new(word: String, root: String) -> StemmingDictionaryWordsInner { - StemmingDictionaryWordsInner { word, root } +impl<'a> StemmingDictionaryWordsInner<'a> { + pub fn new(word: Cow<'a, str>, root: Cow<'a, str>) -> Self { + Self { + word, + root, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/stopwords_set_retrieve_schema.rs b/typesense_codegen/src/models/stopwords_set_retrieve_schema.rs index b1b6913b..2fabdbe8 100644 --- a/typesense_codegen/src/models/stopwords_set_retrieve_schema.rs +++ b/typesense_codegen/src/models/stopwords_set_retrieve_schema.rs @@ -9,18 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct StopwordsSetRetrieveSchema { +pub struct StopwordsSetRetrieveSchema<'a> { #[serde(rename = "stopwords")] - pub stopwords: Box, + pub stopwords: Box>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl StopwordsSetRetrieveSchema { - pub fn new(stopwords: models::StopwordsSetSchema) -> StopwordsSetRetrieveSchema { - StopwordsSetRetrieveSchema { +impl<'a> StopwordsSetRetrieveSchema<'a> { + pub fn new(stopwords: models::StopwordsSetSchema<'a>) -> Self { + Self { stopwords: Box::new(stopwords), + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/stopwords_set_schema.rs b/typesense_codegen/src/models/stopwords_set_schema.rs index 8f13deef..a7e7d876 100644 --- a/typesense_codegen/src/models/stopwords_set_schema.rs +++ b/typesense_codegen/src/models/stopwords_set_schema.rs @@ -9,24 +9,28 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct StopwordsSetSchema { +pub struct StopwordsSetSchema<'a> { #[serde(rename = "id")] - pub id: String, + pub id: Cow<'a, str>, #[serde(rename = "stopwords")] pub stopwords: Vec, #[serde(rename = "locale", skip_serializing_if = "Option::is_none")] - pub locale: Option, + pub locale: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl StopwordsSetSchema { - pub fn new(id: String, stopwords: Vec) -> StopwordsSetSchema { - StopwordsSetSchema { +impl<'a> StopwordsSetSchema<'a> { + pub fn new(id: Cow<'a, str>, stopwords: Vec) -> Self { + Self { id, stopwords, locale: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/stopwords_set_upsert_schema.rs b/typesense_codegen/src/models/stopwords_set_upsert_schema.rs index 1facab52..0d0a1d83 100644 --- a/typesense_codegen/src/models/stopwords_set_upsert_schema.rs +++ b/typesense_codegen/src/models/stopwords_set_upsert_schema.rs @@ -9,21 +9,25 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct StopwordsSetUpsertSchema { +pub struct StopwordsSetUpsertSchema<'a> { #[serde(rename = "stopwords")] pub stopwords: Vec, #[serde(rename = "locale", skip_serializing_if = "Option::is_none")] - pub locale: Option, + pub locale: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl StopwordsSetUpsertSchema { - pub fn new(stopwords: Vec) -> StopwordsSetUpsertSchema { - StopwordsSetUpsertSchema { +impl<'a> StopwordsSetUpsertSchema<'a> { + pub fn new(stopwords: Vec) -> Self { + Self { stopwords, locale: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/stopwords_sets_retrieve_all_schema.rs b/typesense_codegen/src/models/stopwords_sets_retrieve_all_schema.rs index 84703ac1..368d338c 100644 --- a/typesense_codegen/src/models/stopwords_sets_retrieve_all_schema.rs +++ b/typesense_codegen/src/models/stopwords_sets_retrieve_all_schema.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct StopwordsSetsRetrieveAllSchema { +pub struct StopwordsSetsRetrieveAllSchema<'a> { #[serde(rename = "stopwords")] - pub stopwords: Vec, + pub stopwords: Vec>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl StopwordsSetsRetrieveAllSchema { - pub fn new(stopwords: Vec) -> StopwordsSetsRetrieveAllSchema { - StopwordsSetsRetrieveAllSchema { stopwords } +impl<'a> StopwordsSetsRetrieveAllSchema<'a> { + pub fn new(stopwords: Vec>) -> Self { + Self { + stopwords, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/success_status.rs b/typesense_codegen/src/models/success_status.rs index c88ecb9c..dc41d00a 100644 --- a/typesense_codegen/src/models/success_status.rs +++ b/typesense_codegen/src/models/success_status.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SuccessStatus { +pub struct SuccessStatus<'a> { #[serde(rename = "success")] pub success: bool, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SuccessStatus { - pub fn new(success: bool) -> SuccessStatus { - SuccessStatus { success } +impl<'a> SuccessStatus<'a> { + pub fn new(success: bool) -> Self { + Self { + success, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/synonym_item_delete_schema.rs b/typesense_codegen/src/models/synonym_item_delete_schema.rs index 91c3e1df..c5da7c87 100644 --- a/typesense_codegen/src/models/synonym_item_delete_schema.rs +++ b/typesense_codegen/src/models/synonym_item_delete_schema.rs @@ -9,17 +9,23 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SynonymItemDeleteSchema { +pub struct SynonymItemDeleteSchema<'a> { /// ID of the deleted synonym item #[serde(rename = "id")] - pub id: String, + pub id: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SynonymItemDeleteSchema { - pub fn new(id: String) -> SynonymItemDeleteSchema { - SynonymItemDeleteSchema { id } +impl<'a> SynonymItemDeleteSchema<'a> { + pub fn new(id: Cow<'a, str>) -> Self { + Self { + id, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/synonym_item_schema.rs b/typesense_codegen/src/models/synonym_item_schema.rs index bb03da34..03693113 100644 --- a/typesense_codegen/src/models/synonym_item_schema.rs +++ b/typesense_codegen/src/models/synonym_item_schema.rs @@ -9,35 +9,39 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SynonymItemSchema { +pub struct SynonymItemSchema<'a> { /// Unique identifier for the synonym item #[serde(rename = "id")] - pub id: String, + pub id: Cow<'a, str>, /// Array of words that should be considered as synonyms #[serde(rename = "synonyms")] pub synonyms: Vec, /// For 1-way synonyms, indicates the root word that words in the synonyms parameter map to #[serde(rename = "root", skip_serializing_if = "Option::is_none")] - pub root: Option, + pub root: Option>, /// Locale for the synonym, leave blank to use the standard tokenizer #[serde(rename = "locale", skip_serializing_if = "Option::is_none")] - pub locale: Option, + pub locale: Option>, /// By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] pub symbols_to_index: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SynonymItemSchema { - pub fn new(id: String, synonyms: Vec) -> SynonymItemSchema { - SynonymItemSchema { +impl<'a> SynonymItemSchema<'a> { + pub fn new(id: Cow<'a, str>, synonyms: Vec) -> Self { + Self { id, synonyms, root: None, locale: None, symbols_to_index: None, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/synonym_set_create_schema.rs b/typesense_codegen/src/models/synonym_set_create_schema.rs index 818ae98f..16539737 100644 --- a/typesense_codegen/src/models/synonym_set_create_schema.rs +++ b/typesense_codegen/src/models/synonym_set_create_schema.rs @@ -9,17 +9,23 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SynonymSetCreateSchema { +pub struct SynonymSetCreateSchema<'a> { /// Array of synonym items #[serde(rename = "items")] - pub items: Vec, + pub items: Vec>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SynonymSetCreateSchema { - pub fn new(items: Vec) -> SynonymSetCreateSchema { - SynonymSetCreateSchema { items } +impl<'a> SynonymSetCreateSchema<'a> { + pub fn new(items: Vec>) -> Self { + Self { + items, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/synonym_set_delete_schema.rs b/typesense_codegen/src/models/synonym_set_delete_schema.rs index e127040b..537b181d 100644 --- a/typesense_codegen/src/models/synonym_set_delete_schema.rs +++ b/typesense_codegen/src/models/synonym_set_delete_schema.rs @@ -9,17 +9,23 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SynonymSetDeleteSchema { +pub struct SynonymSetDeleteSchema<'a> { /// Name of the deleted synonym set #[serde(rename = "name")] - pub name: String, + pub name: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SynonymSetDeleteSchema { - pub fn new(name: String) -> SynonymSetDeleteSchema { - SynonymSetDeleteSchema { name } +impl<'a> SynonymSetDeleteSchema<'a> { + pub fn new(name: Cow<'a, str>) -> Self { + Self { + name, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/synonym_set_schema.rs b/typesense_codegen/src/models/synonym_set_schema.rs index f9e171c6..7e3774e1 100644 --- a/typesense_codegen/src/models/synonym_set_schema.rs +++ b/typesense_codegen/src/models/synonym_set_schema.rs @@ -9,20 +9,27 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SynonymSetSchema { +pub struct SynonymSetSchema<'a> { /// Array of synonym items #[serde(rename = "items")] - pub items: Vec, + pub items: Vec>, /// Name of the synonym set #[serde(rename = "name")] - pub name: String, + pub name: Cow<'a, str>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SynonymSetSchema { - pub fn new(items: Vec, name: String) -> SynonymSetSchema { - SynonymSetSchema { items, name } +impl<'a> SynonymSetSchema<'a> { + pub fn new(items: Vec>, name: Cow<'a, str>) -> Self { + Self { + items, + name, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/synonym_sets_retrieve_schema.rs b/typesense_codegen/src/models/synonym_sets_retrieve_schema.rs index 612c1a5e..ea9fd3c9 100644 --- a/typesense_codegen/src/models/synonym_sets_retrieve_schema.rs +++ b/typesense_codegen/src/models/synonym_sets_retrieve_schema.rs @@ -9,17 +9,23 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SynonymSetsRetrieveSchema { +pub struct SynonymSetsRetrieveSchema<'a> { /// Array of synonym sets #[serde(rename = "synonym_sets")] - pub synonym_sets: Vec, + pub synonym_sets: Vec>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl SynonymSetsRetrieveSchema { - pub fn new(synonym_sets: Vec) -> SynonymSetsRetrieveSchema { - SynonymSetsRetrieveSchema { synonym_sets } +impl<'a> SynonymSetsRetrieveSchema<'a> { + pub fn new(synonym_sets: Vec>) -> Self { + Self { + synonym_sets, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/toggle_slow_request_log_request.rs b/typesense_codegen/src/models/toggle_slow_request_log_request.rs index 29572980..a6fb4956 100644 --- a/typesense_codegen/src/models/toggle_slow_request_log_request.rs +++ b/typesense_codegen/src/models/toggle_slow_request_log_request.rs @@ -9,18 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ToggleSlowRequestLogRequest { +pub struct ToggleSlowRequestLogRequest<'a> { #[serde(rename = "log-slow-requests-time-ms")] pub log_slow_requests_time_ms: i32, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl ToggleSlowRequestLogRequest { - pub fn new(log_slow_requests_time_ms: i32) -> ToggleSlowRequestLogRequest { - ToggleSlowRequestLogRequest { +impl<'a> ToggleSlowRequestLogRequest<'a> { + pub fn new(log_slow_requests_time_ms: i32) -> Self { + Self { log_slow_requests_time_ms, + _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/update_documents_200_response.rs b/typesense_codegen/src/models/update_documents_200_response.rs index 88cc7b45..e948033b 100644 --- a/typesense_codegen/src/models/update_documents_200_response.rs +++ b/typesense_codegen/src/models/update_documents_200_response.rs @@ -9,17 +9,23 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct UpdateDocuments200Response { +pub struct UpdateDocuments200Response<'a> { /// The number of documents that have been updated #[serde(rename = "num_updated")] pub num_updated: i32, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl UpdateDocuments200Response { - pub fn new(num_updated: i32) -> UpdateDocuments200Response { - UpdateDocuments200Response { num_updated } +impl<'a> UpdateDocuments200Response<'a> { + pub fn new(num_updated: i32) -> Self { + Self { + num_updated, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/update_documents_parameters.rs b/typesense_codegen/src/models/update_documents_parameters.rs index cf49cbb6..106aa0d6 100644 --- a/typesense_codegen/src/models/update_documents_parameters.rs +++ b/typesense_codegen/src/models/update_documents_parameters.rs @@ -9,16 +9,22 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct UpdateDocumentsParameters { +pub struct UpdateDocumentsParameters<'a> { #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] - pub filter_by: Option, + pub filter_by: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl UpdateDocumentsParameters { - pub fn new() -> UpdateDocumentsParameters { - UpdateDocumentsParameters { filter_by: None } +impl<'a> UpdateDocumentsParameters<'a> { + pub fn new() -> Self { + Self { + filter_by: None, + _phantom: PhantomData, + } } } diff --git a/typesense_codegen/src/models/voice_query_model_collection_config.rs b/typesense_codegen/src/models/voice_query_model_collection_config.rs index 38044c93..658d3828 100644 --- a/typesense_codegen/src/models/voice_query_model_collection_config.rs +++ b/typesense_codegen/src/models/voice_query_model_collection_config.rs @@ -9,18 +9,24 @@ */ use crate::models; +use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; /// VoiceQueryModelCollectionConfig : Configuration for the voice query model #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct VoiceQueryModelCollectionConfig { +pub struct VoiceQueryModelCollectionConfig<'a> { #[serde(rename = "model_name", skip_serializing_if = "Option::is_none")] - pub model_name: Option, + pub model_name: Option>, + #[serde(skip)] + pub _phantom: PhantomData<&'a ()>, } -impl VoiceQueryModelCollectionConfig { +impl<'a> VoiceQueryModelCollectionConfig<'a> { /// Configuration for the voice query model - pub fn new() -> VoiceQueryModelCollectionConfig { - VoiceQueryModelCollectionConfig { model_name: None } + pub fn new() -> Self { + Self { + model_name: None, + _phantom: PhantomData, + } } } diff --git a/typesense_derive/src/lib.rs b/typesense_derive/src/lib.rs index b7ec117b..fafaea5f 100644 --- a/typesense_derive/src/lib.rs +++ b/typesense_derive/src/lib.rs @@ -6,8 +6,8 @@ use helpers::*; use proc_macro::TokenStream; use proc_macro2::{Ident, TokenTree}; -use quote::{quote, ToTokens}; -use syn::{spanned::Spanned, Attribute, ItemStruct}; +use quote::{ToTokens, quote}; +use syn::{Attribute, ItemStruct, spanned::Spanned}; #[proc_macro_derive(Typesense, attributes(typesense))] pub fn typesense_collection_derive(input: TokenStream) -> TokenStream { @@ -76,18 +76,17 @@ fn impl_typesense_collection(item: ItemStruct) -> syn::Result { } } - let (regular_fields, flattened_fields) = fields - .iter() - .map(process_field) - .collect::,Vec<_>)>>()?; - let regular_fields = regular_fields - .into_iter() - .filter_map(|v| v) - .collect::>(); - let flattened_fields = flattened_fields - .into_iter() - .filter_map(|v| v) - .collect::>(); + let mut regular_fields = Vec::new(); + let mut flattened_fields = Vec::new(); + for field in &fields { + let (regular, flattened) = process_field(field)?; + if let Some(f) = regular { + regular_fields.push(f); + } + if let Some(f) = flattened { + flattened_fields.push(f); + } + } let default_sorting_field = if let Some(v) = default_sorting_field { quote! { @@ -150,7 +149,7 @@ fn impl_typesense_collection(item: ItemStruct) -> syn::Result { type Partial = #name_partial; - fn collection_schema() -> ::typesense::models::CollectionSchema { + fn collection_schema() -> ::typesense::models::CollectionSchema<'static> { let fields = [#(#regular_fields,)*].into_iter() #(.chain(#flattened_fields))* .collect::>(); diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index a37b55b3..8aaae8ab 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -10,5 +10,9 @@ clap = { workspace = true } reqwest = { version = "0.12", features = ["blocking"] } # "blocking" is simpler for scripts serde = { workspace = true } serde_yaml = { workspace = true } -typesense = { path = "../typesense"} +typesense = { path = "../typesense", optional = true} tokio = { workspace = true} + +[features] +default = [] +typesense = ["dep:typesense"] diff --git a/xtask/src/add_vendor_attributes.rs b/xtask/src/add_vendor_attributes.rs index 8fe1fe1e..18e481e7 100644 --- a/xtask/src/add_vendor_attributes.rs +++ b/xtask/src/add_vendor_attributes.rs @@ -15,35 +15,38 @@ pub fn add_vendor_attributes(doc_root: &mut Mapping) -> Result<(), String> { ])?; attrs.schema_generic_parameter([ - ("SearchResult", ""), - ("SearchGroupedHit", ""), - ("SearchResultHit", ""), - ("MultiSearchResult", ""), - ("MultiSearchResultItem", ""), + ("SearchResult", "D"), + ("SearchGroupedHit", "D"), + ("SearchResultHit", "D"), + ("MultiSearchResult", "D"), + ("MultiSearchResultItem", "D"), ])?; attrs.schema_field_type_overrides( "SearchResult", [ - ("hits", "Option>>"), - ("grouped_hits", "Option>>"), + ("hits", "Option>>"), + ( + "grouped_hits", + "Option>>", + ), ], )?; attrs.schema_field_type_overrides( "SearchGroupedHit", - [("hits", "Vec>")], + [("hits", "Vec>")], )?; attrs.schema_field_type_overrides("SearchResultHit", [("document", "Option")])?; attrs.schema_field_type_overrides( "MultiSearchResult", - [("results", "Vec>")], + [("results", "Vec>")], )?; // Operations attrs .operation("/collections/{collectionName}/documents/search", "get") - .generic_parameter(" serde::Deserialize<'de> + Serialize>") - .return_type("models::SearchResult") + .generic_parameter("D: for<'de> serde::Deserialize<'de> + Serialize") + .return_type("models::SearchResult<'static, D>") .done()?; attrs @@ -54,7 +57,7 @@ pub fn add_vendor_attributes(doc_root: &mut Mapping) -> Result<(), String> { // The endpoint return `null` if no schema changes are in progress attrs .operation("/operations/schema_changes", "get") - .return_type("Option>") + .return_type("Option>>") .done()?; // The documents /import endpoint expects a text/plain body and response @@ -78,8 +81,8 @@ pub fn add_vendor_attributes(doc_root: &mut Mapping) -> Result<(), String> { attrs .operation("/collections/{collectionName}/documents", "patch") - .generic_parameter("") - .params_generic_parameter("") + .generic_parameter("B: Serialize") + .params_generic_parameter("B") .request_type("B") .done()?; @@ -88,8 +91,8 @@ pub fn add_vendor_attributes(doc_root: &mut Mapping) -> Result<(), String> { "/collections/{collectionName}/documents/{documentId}", "patch", ) - .generic_parameter("") - .params_generic_parameter("") + .generic_parameter("B: Serialize") + .params_generic_parameter("B") .request_type("B") .done()?; diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 29f84c9d..bb60432c 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -3,10 +3,12 @@ use clap::{Parser, ValueEnum}; use std::{env, fs, process::Command}; mod add_vendor_attributes; mod preprocess_openapi; +#[cfg(feature = "typesense")] mod test_clean; mod vendor_attributes; use preprocess_openapi::preprocess_openapi_file; +#[cfg(feature = "typesense")] use test_clean::test_clean; const SPEC_URL: &str = @@ -50,12 +52,14 @@ enum Task { /// Preprocesses fetched OpenAPI spec file into a new one Preprocess, /// Clean up test artifacts, e.g., collections + #[cfg(feature = "typesense")] TestClean, } fn main() -> Result<()> { let cli = Cli::parse(); + #[cfg(feature = "typesense")] let rt = tokio::runtime::Runtime::new().unwrap(); for task in cli.tasks { @@ -65,6 +69,7 @@ fn main() -> Result<()> { Task::Fetch => task_fetch_api_spec()?, Task::Preprocess => preprocess_openapi_file(INPUT_SPEC_FILE, OUTPUT_PREPROCESSED_FILE) .expect("Preprocess failed, aborting!"), + #[cfg(feature = "typesense")] Task::TestClean => { let test_args = cli.test_args.clone(); let is_wasm = cli.wasm; From 45418656e68c6b62c7e2703b7b4c69d87237df23 Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Sun, 9 Nov 2025 14:55:30 +0000 Subject: [PATCH 03/17] Revert ToTypesenseField --- typesense/src/traits/field_type.rs | 102 +++++++++++++---------- typesense_derive/src/field_attributes.rs | 2 +- typesense_derive/src/lib.rs | 4 +- 3 files changed, 60 insertions(+), 48 deletions(-) diff --git a/typesense/src/traits/field_type.rs b/typesense/src/traits/field_type.rs index cf96142a..e994e8d9 100644 --- a/typesense/src/traits/field_type.rs +++ b/typesense/src/traits/field_type.rs @@ -5,65 +5,77 @@ pub type FieldType = String; /// Trait that should implement each type of a document, in order to properly serialize the /// Collection Schema according to the Typesense reference. -pub trait TypesenseField { - /// the type of the typesense document. - const TYPESENSE_TYPE: &'static str; +pub trait ToTypesenseField { + /// Static function that should implement the types of the typesense documents. + fn to_typesense_type() -> &'static str; } /// Generic implementation for any type that is also a Typesense document. -impl TypesenseField for T { - const TYPESENSE_TYPE: &'static str = "object"; +impl ToTypesenseField for T { + #[inline(always)] + fn to_typesense_type() -> &'static str { + "object" + } } /// Generic implementation for a Vec of any type that is also a Typesense document. -impl TypesenseField for Vec { - const TYPESENSE_TYPE: &'static str = "object[]"; +impl ToTypesenseField for Vec { + #[inline(always)] + fn to_typesense_type() -> &'static str { + "object[]" + } } -/// macro used internally to add implementations of TypesenseField for several rust types. +/// macro used internally to add implementations of ToTypesenseField for several rust types. #[macro_export] -macro_rules! impl_typesense_field ( +macro_rules! impl_to_typesense_field ( ($for:ty, $typesense_variant:expr) => { - impl $crate::prelude::TypesenseField for $for { - const TYPESENSE_TYPE: &'static str = $typesense_variant; + impl $crate::prelude::ToTypesenseField for $for { + #[inline(always)] + fn to_typesense_type() -> &'static str { + $typesense_variant + } } }; ($for:ty, $typesense_variant:expr, $any:ident) => { - impl<$any> $crate::prelude::TypesenseField for $for { - const TYPESENSE_TYPE: &'static str = $typesense_variant; + impl<$any> $crate::prelude::ToTypesenseField for $for { + #[inline(always)] + fn to_typesense_type() -> &'static str { + $typesense_variant + } } }; ); -impl_typesense_field!(String, "string"); -impl_typesense_field!(i8, "int32"); -impl_typesense_field!(u8, "int32"); -impl_typesense_field!(i16, "int32"); -impl_typesense_field!(u16, "int32"); -impl_typesense_field!(i32, "int32"); -impl_typesense_field!(u32, "int64"); -impl_typesense_field!(i64, "int64"); -impl_typesense_field!(u64, "int64"); -impl_typesense_field!(isize, "int64"); -impl_typesense_field!(usize, "int64"); -impl_typesense_field!(f32, "float"); -impl_typesense_field!(f64, "float"); -impl_typesense_field!(bool, "bool"); -impl_typesense_field!(HashMap, "object", T); -impl_typesense_field!(BTreeMap, "object", T); +impl_to_typesense_field!(String, "string"); +impl_to_typesense_field!(i8, "int32"); +impl_to_typesense_field!(u8, "int32"); +impl_to_typesense_field!(i16, "int32"); +impl_to_typesense_field!(u16, "int32"); +impl_to_typesense_field!(i32, "int32"); +impl_to_typesense_field!(u32, "int64"); +impl_to_typesense_field!(i64, "int64"); +impl_to_typesense_field!(u64, "int64"); +impl_to_typesense_field!(isize, "int64"); +impl_to_typesense_field!(usize, "int64"); +impl_to_typesense_field!(f32, "float"); +impl_to_typesense_field!(f64, "float"); +impl_to_typesense_field!(bool, "bool"); +impl_to_typesense_field!(HashMap, "object", T); +impl_to_typesense_field!(BTreeMap, "object", T); -impl_typesense_field!(Vec, "string[]"); -impl_typesense_field!(Vec, "int32[]"); -impl_typesense_field!(Vec, "int32[]"); -impl_typesense_field!(Vec, "int32[]"); -impl_typesense_field!(Vec, "int32[]"); -impl_typesense_field!(Vec, "int32[]"); -impl_typesense_field!(Vec, "int64[]"); -impl_typesense_field!(Vec, "int64[]"); -impl_typesense_field!(Vec, "int64[]"); -impl_typesense_field!(Vec, "int64[]"); -impl_typesense_field!(Vec, "int64[]"); -impl_typesense_field!(Vec, "float[]"); -impl_typesense_field!(Vec, "float[]"); -impl_typesense_field!(Vec, "bool[]"); -impl_typesense_field!(Vec>, "object[]", T); -impl_typesense_field!(Vec>, "object[]", T); +impl_to_typesense_field!(Vec, "string[]"); +impl_to_typesense_field!(Vec, "int32[]"); +impl_to_typesense_field!(Vec, "int32[]"); +impl_to_typesense_field!(Vec, "int32[]"); +impl_to_typesense_field!(Vec, "int32[]"); +impl_to_typesense_field!(Vec, "int32[]"); +impl_to_typesense_field!(Vec, "int64[]"); +impl_to_typesense_field!(Vec, "int64[]"); +impl_to_typesense_field!(Vec, "int64[]"); +impl_to_typesense_field!(Vec, "int64[]"); +impl_to_typesense_field!(Vec, "int64[]"); +impl_to_typesense_field!(Vec, "float[]"); +impl_to_typesense_field!(Vec, "float[]"); +impl_to_typesense_field!(Vec, "bool[]"); +impl_to_typesense_field!(Vec>, "object[]", T); +impl_to_typesense_field!(Vec>, "object[]", T); diff --git a/typesense_derive/src/field_attributes.rs b/typesense_derive/src/field_attributes.rs index 905b7ddf..99f2e535 100644 --- a/typesense_derive/src/field_attributes.rs +++ b/typesense_derive/src/field_attributes.rs @@ -267,7 +267,7 @@ fn build_regular_field(field: &Field, field_attrs: &FieldAttributes) -> proc_mac let typesense_field_type = if let Some(override_str) = &field_attrs.type_override { quote! { #override_str } } else { - quote! { <#ty as ::typesense::prelude::TypesenseField>::TYPESENSE_TYPE } + quote! { <#ty as ::typesense::prelude::ToTypesenseField>::to_typesense_type() } }; let optional = field_attrs diff --git a/typesense_derive/src/lib.rs b/typesense_derive/src/lib.rs index fafaea5f..0e1b658c 100644 --- a/typesense_derive/src/lib.rs +++ b/typesense_derive/src/lib.rs @@ -168,13 +168,13 @@ fn impl_typesense_collection(item: ItemStruct) -> syn::Result { Ok(generated_code.into()) } -// Add a bound `T: TypesenseField` to every type parameter T. +// Add a bound `T: ToTypesenseField` to every type parameter T. fn add_trait_bounds(mut generics: syn::Generics) -> syn::Generics { for param in &mut generics.params { if let syn::GenericParam::Type(ref mut type_param) = *param { type_param .bounds - .push(syn::parse_quote!(::typesense::field::TypesenseField)); + .push(syn::parse_quote!(::typesense::field::ToTypesenseField)); } } generics From ad0c49633a6b9c1e6ee013e4191e6656b99de476 Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Sun, 9 Nov 2025 15:05:40 +0000 Subject: [PATCH 04/17] Clippy --- typesense/src/client/keys.rs | 2 +- typesense/src/client/mod.rs | 4 ++-- typesense/src/traits/multi_search_ext.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/typesense/src/client/keys.rs b/typesense/src/client/keys.rs index ceadb7ea..674d5404 100644 --- a/typesense/src/client/keys.rs +++ b/typesense/src/client/keys.rs @@ -58,7 +58,7 @@ impl<'c> Keys<'c> { pub fn generate_scoped_search_key( &self, key: impl AsRef, - params: &ScopedKeyParameters, + params: &ScopedKeyParameters<'_>, ) -> anyhow::Result { let params = serde_json::to_string(params)?; diff --git a/typesense/src/client/mod.rs b/typesense/src/client/mod.rs index 7afd10ea..cc8227fe 100644 --- a/typesense/src/client/mod.rs +++ b/typesense/src/client/mod.rs @@ -91,8 +91,8 @@ //! //! // Search for a document //! let search_params = models::SearchParameters { -//! q: Some("phone".to_owned()), -//! query_by: Some("name".to_owned()), +//! q: Some("phone".into()), +//! query_by: Some("name".into()), //! ..Default::default() //! }; //! diff --git a/typesense/src/traits/multi_search_ext.rs b/typesense/src/traits/multi_search_ext.rs index c7c78ef8..b6fc7d77 100644 --- a/typesense/src/traits/multi_search_ext.rs +++ b/typesense/src/traits/multi_search_ext.rs @@ -47,7 +47,7 @@ fn convert_hit_ref<'a, D: DeserializeOwned>( } fn convert_group_ref<'a, D: DeserializeOwned>( - raw_group: &'a SearchGroupedHit, + raw_group: &'a SearchGroupedHit<'_, Value>, ) -> Result, serde_json::Error> { let hits = raw_group .hits @@ -65,7 +65,7 @@ fn convert_group_ref<'a, D: DeserializeOwned>( /// Convert a single `MultiSearchResultItem` into a strongly-typed `SearchResult`. fn multi_search_item_to_search_result<'a, D: DeserializeOwned>( - item: &'a MultiSearchResultItem, + item: &'a MultiSearchResultItem<'_, Value>, ) -> Result, serde_json::Error> { let typed_hits = match &item.hits { Some(raw_hits) => Some( From e324ed3753f3932803289d157f1cdf043f857ba4 Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Mon, 10 Nov 2025 13:10:43 +0000 Subject: [PATCH 05/17] Refactor --- typesense_derive/src/field_attributes.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typesense_derive/src/field_attributes.rs b/typesense_derive/src/field_attributes.rs index 99f2e535..a62b0519 100644 --- a/typesense_derive/src/field_attributes.rs +++ b/typesense_derive/src/field_attributes.rs @@ -286,7 +286,7 @@ fn build_regular_field(field: &Field, field_attrs: &FieldAttributes) -> proc_mac let num_dim = field_attrs.num_dim.map(|v| quote!(.num_dim(#v))); quote! { - typesense::models::Field::builder().name(#field_name).r#type(#typesense_field_type) + ::typesense::models::Field::builder().name(#field_name).r#type(#typesense_field_type) #optional #facet #index #store #sort #infix #stem #range_index #locale #vec_dist #num_dim .build() } From 9764ebbb066734dcf79f6040bffb38c62e602e6f Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Mon, 10 Nov 2025 13:44:31 +0000 Subject: [PATCH 06/17] Fix UnknownValue --- .../reqwest/api.mustache | 12 +--- .../reqwest/api_mod.mustache | 10 +++- typesense_codegen/src/apis/analytics_api.rs | 54 +++-------------- typesense_codegen/src/apis/collections_api.rs | 54 +++-------------- .../src/apis/conversations_api.rs | 30 ++-------- .../src/apis/curation_sets_api.rs | 48 +++------------ typesense_codegen/src/apis/debug_api.rs | 6 +- typesense_codegen/src/apis/documents_api.rs | 60 ++++--------------- typesense_codegen/src/apis/health_api.rs | 6 +- typesense_codegen/src/apis/keys_api.rs | 24 ++------ typesense_codegen/src/apis/mod.rs | 10 +++- .../src/apis/nl_search_models_api.rs | 30 ++-------- typesense_codegen/src/apis/operations_api.rs | 48 +++------------ typesense_codegen/src/apis/presets_api.rs | 24 ++------ typesense_codegen/src/apis/stemming_api.rs | 18 +----- typesense_codegen/src/apis/stopwords_api.rs | 24 ++------ typesense_codegen/src/apis/synonyms_api.rs | 48 +++------------ 17 files changed, 99 insertions(+), 407 deletions(-) diff --git a/openapi-generator-template/reqwest/api.mustache b/openapi-generator-template/reqwest/api.mustache index 90dd3162..a819c242 100644 --- a/openapi-generator-template/reqwest/api.mustache +++ b/openapi-generator-template/reqwest/api.mustache @@ -70,11 +70,7 @@ pub enum {{{operationIdCamelCase}}}Success<'a> { Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'a>{{/isEnum}}), {{/is3xx}} {{/responses}} - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } {{/operation}} @@ -97,11 +93,7 @@ pub enum {{{operationIdCamelCase}}}Error<'a> { DefaultResponse({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'a>{{/isEnum}}), {{/isDefault}} {{/responses}} - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } {{/operation}} diff --git a/openapi-generator-template/reqwest/api_mod.mustache b/openapi-generator-template/reqwest/api_mod.mustache index 6a78390e..d74f558c 100644 --- a/openapi-generator-template/reqwest/api_mod.mustache +++ b/openapi-generator-template/reqwest/api_mod.mustache @@ -1,4 +1,12 @@ -use std::{error, fmt}; +use ::std::{error, fmt}; + +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] +#[serde(transparent)] +pub struct Unknown<'a> { + pub value: serde_json::Value, + #[serde(skip)] + pub _phantom: core::marker::PhantomData<&'a ()>, +} {{#withAWSV4Signature}} use aws_sigv4; diff --git a/typesense_codegen/src/apis/analytics_api.rs b/typesense_codegen/src/apis/analytics_api.rs index 9bd7474a..fe288b24 100644 --- a/typesense_codegen/src/apis/analytics_api.rs +++ b/typesense_codegen/src/apis/analytics_api.rs @@ -80,11 +80,7 @@ pub struct UpsertAnalyticsRuleParams<'p> { #[serde(untagged)] pub enum CreateAnalyticsEventError<'a> { Status400(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`create_analytics_rule`] @@ -92,11 +88,7 @@ pub enum CreateAnalyticsEventError<'a> { #[serde(untagged)] pub enum CreateAnalyticsRuleError<'a> { Status400(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`delete_analytics_rule`] @@ -104,22 +96,14 @@ pub enum CreateAnalyticsRuleError<'a> { #[serde(untagged)] pub enum DeleteAnalyticsRuleError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`flush_analytics`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum FlushAnalyticsError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`get_analytics_events`] @@ -127,22 +111,14 @@ pub enum FlushAnalyticsError<'a> { #[serde(untagged)] pub enum GetAnalyticsEventsError<'a> { Status400(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`get_analytics_status`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetAnalyticsStatusError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_analytics_rule`] @@ -150,22 +126,14 @@ pub enum GetAnalyticsStatusError<'a> { #[serde(untagged)] pub enum RetrieveAnalyticsRuleError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_analytics_rules`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveAnalyticsRulesError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`upsert_analytics_rule`] @@ -173,11 +141,7 @@ pub enum RetrieveAnalyticsRulesError<'a> { #[serde(untagged)] pub enum UpsertAnalyticsRuleError<'a> { Status400(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// Submit a single analytics event. The event must correspond to an existing analytics rule by name. diff --git a/typesense_codegen/src/apis/collections_api.rs b/typesense_codegen/src/apis/collections_api.rs index 70b8367d..53f96766 100644 --- a/typesense_codegen/src/apis/collections_api.rs +++ b/typesense_codegen/src/apis/collections_api.rs @@ -89,11 +89,7 @@ pub struct UpsertAliasParams<'p> { pub enum CreateCollectionError<'a> { Status400(models::ApiResponse<'a>), Status409(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`delete_alias`] @@ -101,11 +97,7 @@ pub enum CreateCollectionError<'a> { #[serde(untagged)] pub enum DeleteAliasError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`delete_collection`] @@ -113,11 +105,7 @@ pub enum DeleteAliasError<'a> { #[serde(untagged)] pub enum DeleteCollectionError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`get_alias`] @@ -125,22 +113,14 @@ pub enum DeleteCollectionError<'a> { #[serde(untagged)] pub enum GetAliasError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`get_aliases`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetAliasesError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`get_collection`] @@ -148,22 +128,14 @@ pub enum GetAliasesError<'a> { #[serde(untagged)] pub enum GetCollectionError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`get_collections`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetCollectionsError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`update_collection`] @@ -172,11 +144,7 @@ pub enum GetCollectionsError<'a> { pub enum UpdateCollectionError<'a> { Status400(models::ApiResponse<'a>), Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`upsert_alias`] @@ -185,11 +153,7 @@ pub enum UpdateCollectionError<'a> { pub enum UpsertAliasError<'a> { Status400(models::ApiResponse<'a>), Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// When a collection is created, we give it a name and describe the fields that will be indexed from the documents added to the collection. diff --git a/typesense_codegen/src/apis/conversations_api.rs b/typesense_codegen/src/apis/conversations_api.rs index 64c58c47..44c338e5 100644 --- a/typesense_codegen/src/apis/conversations_api.rs +++ b/typesense_codegen/src/apis/conversations_api.rs @@ -51,55 +51,35 @@ pub struct UpdateConversationModelParams<'p> { #[serde(untagged)] pub enum CreateConversationModelError<'a> { Status400(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`delete_conversation_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteConversationModelError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_all_conversation_models`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveAllConversationModelsError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_conversation_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveConversationModelError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`update_conversation_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum UpdateConversationModelError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// Create a Conversation Model diff --git a/typesense_codegen/src/apis/curation_sets_api.rs b/typesense_codegen/src/apis/curation_sets_api.rs index eef5faf2..e638cd4b 100644 --- a/typesense_codegen/src/apis/curation_sets_api.rs +++ b/typesense_codegen/src/apis/curation_sets_api.rs @@ -85,11 +85,7 @@ pub struct UpsertCurationSetItemParams<'p> { #[serde(untagged)] pub enum DeleteCurationSetError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`delete_curation_set_item`] @@ -97,11 +93,7 @@ pub enum DeleteCurationSetError<'a> { #[serde(untagged)] pub enum DeleteCurationSetItemError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_curation_set`] @@ -109,11 +101,7 @@ pub enum DeleteCurationSetItemError<'a> { #[serde(untagged)] pub enum RetrieveCurationSetError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_curation_set_item`] @@ -121,11 +109,7 @@ pub enum RetrieveCurationSetError<'a> { #[serde(untagged)] pub enum RetrieveCurationSetItemError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_curation_set_items`] @@ -133,22 +117,14 @@ pub enum RetrieveCurationSetItemError<'a> { #[serde(untagged)] pub enum RetrieveCurationSetItemsError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_curation_sets`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveCurationSetsError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`upsert_curation_set`] @@ -156,11 +132,7 @@ pub enum RetrieveCurationSetsError<'a> { #[serde(untagged)] pub enum UpsertCurationSetError<'a> { Status400(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`upsert_curation_set_item`] @@ -168,11 +140,7 @@ pub enum UpsertCurationSetError<'a> { #[serde(untagged)] pub enum UpsertCurationSetItemError<'a> { Status400(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// Delete a specific curation set by its name diff --git a/typesense_codegen/src/apis/debug_api.rs b/typesense_codegen/src/apis/debug_api.rs index 074d81dc..09ab46ad 100644 --- a/typesense_codegen/src/apis/debug_api.rs +++ b/typesense_codegen/src/apis/debug_api.rs @@ -18,11 +18,7 @@ use serde::{Deserialize, Serialize, de::Error as _}; #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DebugError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// Print debugging information diff --git a/typesense_codegen/src/apis/documents_api.rs b/typesense_codegen/src/apis/documents_api.rs index 02591a75..803dc311 100644 --- a/typesense_codegen/src/apis/documents_api.rs +++ b/typesense_codegen/src/apis/documents_api.rs @@ -267,11 +267,7 @@ pub struct UpdateDocumentsParams<'p, B> { #[serde(untagged)] pub enum DeleteDocumentError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`delete_documents`] @@ -279,11 +275,7 @@ pub enum DeleteDocumentError<'a> { #[serde(untagged)] pub enum DeleteDocumentsError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`export_documents`] @@ -291,11 +283,7 @@ pub enum DeleteDocumentsError<'a> { #[serde(untagged)] pub enum ExportDocumentsError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`get_document`] @@ -303,11 +291,7 @@ pub enum ExportDocumentsError<'a> { #[serde(untagged)] pub enum GetDocumentError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`import_documents`] @@ -316,11 +300,7 @@ pub enum GetDocumentError<'a> { pub enum ImportDocumentsError<'a> { Status400(models::ApiResponse<'a>), Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`index_document`] @@ -328,11 +308,7 @@ pub enum ImportDocumentsError<'a> { #[serde(untagged)] pub enum IndexDocumentError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`multi_search`] @@ -340,11 +316,7 @@ pub enum IndexDocumentError<'a> { #[serde(untagged)] pub enum MultiSearchError<'a> { Status400(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`search_collection`] @@ -353,11 +325,7 @@ pub enum MultiSearchError<'a> { pub enum SearchCollectionError<'a> { Status400(models::ApiResponse<'a>), Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`update_document`] @@ -365,11 +333,7 @@ pub enum SearchCollectionError<'a> { #[serde(untagged)] pub enum UpdateDocumentError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`update_documents`] @@ -378,11 +342,7 @@ pub enum UpdateDocumentError<'a> { pub enum UpdateDocumentsError<'a> { Status400(models::ApiResponse<'a>), Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// Delete an individual document from a collection by using its ID. diff --git a/typesense_codegen/src/apis/health_api.rs b/typesense_codegen/src/apis/health_api.rs index e0fb7879..ed580bbf 100644 --- a/typesense_codegen/src/apis/health_api.rs +++ b/typesense_codegen/src/apis/health_api.rs @@ -18,11 +18,7 @@ use serde::{Deserialize, Serialize, de::Error as _}; #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum HealthError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// Checks if Typesense server is ready to accept requests. diff --git a/typesense_codegen/src/apis/keys_api.rs b/typesense_codegen/src/apis/keys_api.rs index ceb6af3e..174e1238 100644 --- a/typesense_codegen/src/apis/keys_api.rs +++ b/typesense_codegen/src/apis/keys_api.rs @@ -44,11 +44,7 @@ pub struct GetKeyParams<'p> { pub enum CreateKeyError<'a> { Status400(models::ApiResponse<'a>), Status409(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`delete_key`] @@ -57,11 +53,7 @@ pub enum CreateKeyError<'a> { pub enum DeleteKeyError<'a> { Status400(models::ApiResponse<'a>), Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`get_key`] @@ -69,22 +61,14 @@ pub enum DeleteKeyError<'a> { #[serde(untagged)] pub enum GetKeyError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`get_keys`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetKeysError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// Create an API Key with fine-grain access control. You can restrict access on both a per-collection and per-action level. The generated key is returned only during creation. You want to store this key carefully in a secure place. diff --git a/typesense_codegen/src/apis/mod.rs b/typesense_codegen/src/apis/mod.rs index b66b0b36..ed868efd 100644 --- a/typesense_codegen/src/apis/mod.rs +++ b/typesense_codegen/src/apis/mod.rs @@ -1,4 +1,12 @@ -use std::{error, fmt}; +use ::std::{error, fmt}; + +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] +#[serde(transparent)] +pub struct Unknown<'a> { + pub value: serde_json::Value, + #[serde(skip)] + pub _phantom: core::marker::PhantomData<&'a ()>, +} #[derive(Debug, Clone)] pub struct ResponseContent { diff --git a/typesense_codegen/src/apis/nl_search_models_api.rs b/typesense_codegen/src/apis/nl_search_models_api.rs index fb7ef1ff..c84e9f5b 100644 --- a/typesense_codegen/src/apis/nl_search_models_api.rs +++ b/typesense_codegen/src/apis/nl_search_models_api.rs @@ -53,11 +53,7 @@ pub struct UpdateNlSearchModelParams<'p> { #[serde(untagged)] pub enum CreateNlSearchModelError<'a> { Status400(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`delete_nl_search_model`] @@ -65,22 +61,14 @@ pub enum CreateNlSearchModelError<'a> { #[serde(untagged)] pub enum DeleteNlSearchModelError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_all_nl_search_models`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveAllNlSearchModelsError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_nl_search_model`] @@ -88,11 +76,7 @@ pub enum RetrieveAllNlSearchModelsError<'a> { #[serde(untagged)] pub enum RetrieveNlSearchModelError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`update_nl_search_model`] @@ -101,11 +85,7 @@ pub enum RetrieveNlSearchModelError<'a> { pub enum UpdateNlSearchModelError<'a> { Status400(models::ApiResponse<'a>), Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// Create a new NL search model. diff --git a/typesense_codegen/src/apis/operations_api.rs b/typesense_codegen/src/apis/operations_api.rs index b7b0e86b..d8ad1f51 100644 --- a/typesense_codegen/src/apis/operations_api.rs +++ b/typesense_codegen/src/apis/operations_api.rs @@ -33,88 +33,56 @@ pub struct ToggleSlowRequestLogParams<'p> { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ClearCacheError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`compact_db`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum CompactDbError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`get_schema_changes`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetSchemaChangesError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_api_stats`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveApiStatsError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_metrics`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveMetricsError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`take_snapshot`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TakeSnapshotError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`toggle_slow_request_log`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ToggleSlowRequestLogError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`vote`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum VoteError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// Clear the cached responses of search requests that are sent with `use_cache` parameter in the LRU cache. diff --git a/typesense_codegen/src/apis/presets_api.rs b/typesense_codegen/src/apis/presets_api.rs index b9e4de48..5d11d6ff 100644 --- a/typesense_codegen/src/apis/presets_api.rs +++ b/typesense_codegen/src/apis/presets_api.rs @@ -45,22 +45,14 @@ pub struct UpsertPresetParams<'p> { #[serde(untagged)] pub enum DeletePresetError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_all_presets`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveAllPresetsError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_preset`] @@ -68,11 +60,7 @@ pub enum RetrieveAllPresetsError<'a> { #[serde(untagged)] pub enum RetrievePresetError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`upsert_preset`] @@ -80,11 +68,7 @@ pub enum RetrievePresetError<'a> { #[serde(untagged)] pub enum UpsertPresetError<'a> { Status400(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// Permanently deletes a preset, given it's name. diff --git a/typesense_codegen/src/apis/stemming_api.rs b/typesense_codegen/src/apis/stemming_api.rs index f5363838..f83fb9ab 100644 --- a/typesense_codegen/src/apis/stemming_api.rs +++ b/typesense_codegen/src/apis/stemming_api.rs @@ -37,11 +37,7 @@ pub struct ImportStemmingDictionaryParams<'p> { #[serde(untagged)] pub enum GetStemmingDictionaryError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`import_stemming_dictionary`] @@ -49,22 +45,14 @@ pub enum GetStemmingDictionaryError<'a> { #[serde(untagged)] pub enum ImportStemmingDictionaryError<'a> { Status400(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`list_stemming_dictionaries`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ListStemmingDictionariesError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// Fetch details of a specific stemming dictionary. diff --git a/typesense_codegen/src/apis/stopwords_api.rs b/typesense_codegen/src/apis/stopwords_api.rs index a0c67331..080805f5 100644 --- a/typesense_codegen/src/apis/stopwords_api.rs +++ b/typesense_codegen/src/apis/stopwords_api.rs @@ -45,11 +45,7 @@ pub struct UpsertStopwordsSetParams<'p> { #[serde(untagged)] pub enum DeleteStopwordsSetError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_stopwords_set`] @@ -57,22 +53,14 @@ pub enum DeleteStopwordsSetError<'a> { #[serde(untagged)] pub enum RetrieveStopwordsSetError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_stopwords_sets`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveStopwordsSetsError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`upsert_stopwords_set`] @@ -80,11 +68,7 @@ pub enum RetrieveStopwordsSetsError<'a> { #[serde(untagged)] pub enum UpsertStopwordsSetError<'a> { Status400(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// Permanently deletes a stopwords set, given it's name. diff --git a/typesense_codegen/src/apis/synonyms_api.rs b/typesense_codegen/src/apis/synonyms_api.rs index 10ee3981..fb402121 100644 --- a/typesense_codegen/src/apis/synonyms_api.rs +++ b/typesense_codegen/src/apis/synonyms_api.rs @@ -85,11 +85,7 @@ pub struct UpsertSynonymSetItemParams<'p> { #[serde(untagged)] pub enum DeleteSynonymSetError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`delete_synonym_set_item`] @@ -97,11 +93,7 @@ pub enum DeleteSynonymSetError<'a> { #[serde(untagged)] pub enum DeleteSynonymSetItemError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_synonym_set`] @@ -109,11 +101,7 @@ pub enum DeleteSynonymSetItemError<'a> { #[serde(untagged)] pub enum RetrieveSynonymSetError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_synonym_set_item`] @@ -121,11 +109,7 @@ pub enum RetrieveSynonymSetError<'a> { #[serde(untagged)] pub enum RetrieveSynonymSetItemError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_synonym_set_items`] @@ -133,22 +117,14 @@ pub enum RetrieveSynonymSetItemError<'a> { #[serde(untagged)] pub enum RetrieveSynonymSetItemsError<'a> { Status404(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`retrieve_synonym_sets`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveSynonymSetsError<'a> { - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`upsert_synonym_set`] @@ -156,11 +132,7 @@ pub enum RetrieveSynonymSetsError<'a> { #[serde(untagged)] pub enum UpsertSynonymSetError<'a> { Status400(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// struct for typed errors of method [`upsert_synonym_set_item`] @@ -168,11 +140,7 @@ pub enum UpsertSynonymSetError<'a> { #[serde(untagged)] pub enum UpsertSynonymSetItemError<'a> { Status400(models::ApiResponse<'a>), - UnknownValue { - value: serde_json::Value, - #[serde(skip)] - _phantom: PhantomData<&'a ()>, - }, + UnknownValue(super::Unknown<'a>), } /// Delete a specific synonym set by its name From df48edb15e25cfdc28f8a9e5d5aa8b438b54d915 Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Tue, 11 Nov 2025 00:19:26 +0000 Subject: [PATCH 07/17] Optimize collection API --- typesense/src/client/collection/document.rs | 27 +++++++++++------- typesense/src/client/collection/documents.rs | 15 +++++----- typesense/src/client/collection/mod.rs | 30 +++++++++++--------- typesense/src/client/mod.rs | 20 +++++++------ xtask/src/test_clean.rs | 2 +- 5 files changed, 54 insertions(+), 40 deletions(-) diff --git a/typesense/src/client/collection/document.rs b/typesense/src/client/collection/document.rs index 0956e418..b6c97201 100644 --- a/typesense/src/client/collection/document.rs +++ b/typesense/src/client/collection/document.rs @@ -5,6 +5,7 @@ //! `client.collection::().document("123")` use crate::{Client, Error, execute_wrapper, traits}; +use ::std::borrow::Cow; use serde::{Serialize, de::DeserializeOwned}; use typesense_codegen::apis::documents_api; @@ -14,27 +15,31 @@ use typesense_codegen::apis::documents_api; /// or `client.collection::().document("document_id")`. /// The generic `D` represents the shape of the document and must implement `Serialize` and `DeserializeOwned`. /// If `D` is not specified, it defaults to `serde_json::Value` for schemaless interactions. -pub struct Document<'c, 'n, D = serde_json::Value> +pub struct Document<'d, D = serde_json::Value> where D: DeserializeOwned + Serialize, { - client: &'c Client, - collection_name: &'n str, - document_id: String, + client: &'d Client, + collection_name: &'d str, + document_id: Cow<'d, str>, _phantom: core::marker::PhantomData, } -impl<'c, 'n, D> Document<'c, 'n, D> +impl<'d, D> Document<'d, D> where D: DeserializeOwned + Serialize, { /// Creates a new `Document` instance for a specific document ID. #[inline] - pub(super) fn new(client: &'c Client, collection_name: &'n str, document_id: String) -> Self { + pub(super) fn new( + client: &'d Client, + collection_name: &'d str, + document_id: impl Into>, + ) -> Self { Self { client, collection_name, - document_id, + document_id: document_id.into(), _phantom: core::marker::PhantomData, } } @@ -46,7 +51,7 @@ where pub async fn retrieve(&self) -> Result>> { let params = documents_api::GetDocumentParams { collection_name: self.collection_name.into(), - document_id: self.document_id.as_str().into(), + document_id: self.document_id.as_ref().into(), _phantom: core::marker::PhantomData, }; @@ -64,7 +69,7 @@ where pub async fn delete(&self) -> Result>> { let params = documents_api::DeleteDocumentParams { collection_name: self.collection_name.into(), - document_id: self.document_id.as_str().into(), + document_id: self.document_id.as_ref().into(), _phantom: core::marker::PhantomData, }; @@ -75,7 +80,7 @@ where } } -impl<'c, 'n, D> Document<'c, 'n, D> +impl<'d, D> Document<'d, D> where D: traits::Document, { @@ -128,7 +133,7 @@ where ) -> Result>> { let params = documents_api::UpdateDocumentParams { collection_name: self.collection_name.into(), - document_id: self.document_id.as_str().into(), + document_id: self.document_id.as_ref().into(), body: partial_document, dirty_values: params.and_then(|d| d.dirty_values), _phantom: core::marker::PhantomData, diff --git a/typesense/src/client/collection/documents.rs b/typesense/src/client/collection/documents.rs index d3d8621b..861bc973 100644 --- a/typesense/src/client/collection/documents.rs +++ b/typesense/src/client/collection/documents.rs @@ -9,6 +9,7 @@ use crate::{ models::{DocumentIndexParameters, SearchResult}, traits, }; +use ::std::borrow::Cow; use serde::{Serialize, de::DeserializeOwned}; use typesense_codegen::{ apis::documents_api, @@ -22,22 +23,22 @@ use typesense_codegen::{ /// This struct is generic over the document type `D`. If created via `client.collection_schemaless(...)`, /// `D` defaults to `serde_json::Value`. If created via `client.collection_named::(...)`, /// `D` will be `MyType`. -pub struct Documents<'c, 'n, D = serde_json::Value> +pub struct Documents<'d, D = serde_json::Value> where D: DeserializeOwned + Serialize, { - client: &'c Client, - collection_name: &'n str, + client: &'d Client, + collection_name: &'d str, _phantom: core::marker::PhantomData, } -impl<'c, 'n, D> Documents<'c, 'n, D> +impl<'d, D> Documents<'d, D> where D: DeserializeOwned + Serialize, { /// Creates a new `Documents` instance. #[inline] - pub(super) fn new(client: &'c Client, collection_name: &'n str) -> Self { + pub(super) fn new(client: &'d Client, collection_name: &'d str) -> Self { Self { client, collection_name, @@ -76,7 +77,7 @@ where /// * `params` - An `ImportDocumentsParameters` struct containing options like `action` and `batch_size`. pub async fn import_jsonl( &self, - documents_jsonl: String, + documents_jsonl: impl Into>, params: ImportDocumentsParameters<'_>, ) -> Result>> { let params = documents_api::ImportDocumentsParams { @@ -225,7 +226,7 @@ where } } -impl<'c, 'n, D> Documents<'c, 'n, D> +impl<'d, D> Documents<'d, D> where D: traits::Document, { diff --git a/typesense/src/client/collection/mod.rs b/typesense/src/client/collection/mod.rs index 75069961..a11ce461 100644 --- a/typesense/src/client/collection/mod.rs +++ b/typesense/src/client/collection/mod.rs @@ -4,47 +4,51 @@ mod document; mod documents; -use crate::{Client, Error, execute_wrapper}; +use crate::{Client, Error, execute_wrapper}; +use ::std::borrow::Cow; use serde::{Serialize, de::DeserializeOwned}; use typesense_codegen::{apis::collections_api, models}; /// Provides methods for interacting with a Typesense collection. /// /// This struct is created by calling `client.collection()`. -pub struct Collection<'c, 'n, D = serde_json::Value> +pub struct Collection<'c, D = serde_json::Value> where D: DeserializeOwned + Serialize, { client: &'c Client, - collection_name: &'n str, + collection_name: Cow<'c, str>, _phantom: core::marker::PhantomData, } -impl<'c, 'n, D> Collection<'c, 'n, D> +impl<'c, D> Collection<'c, D> where D: DeserializeOwned + Serialize, { /// Creates a new `Collection` instance. #[inline] - pub(super) fn new(client: &'c Client, collection_name: &'n str) -> Self { + pub(super) fn new(client: &'c Client, collection_name: impl Into>) -> Self { Self { client, - collection_name, + collection_name: collection_name.into(), _phantom: core::marker::PhantomData, } } /// Provides access to the document-related API endpoints for a specific collection. #[inline] - pub fn documents(&self) -> documents::Documents<'c, 'n, D> { - documents::Documents::new(self.client, self.collection_name) + pub fn documents<'d>(&'d self) -> documents::Documents<'d, D> { + documents::Documents::new(self.client, &self.collection_name) } /// Provides access to the API endpoints for a single document within a Typesense collection. #[inline] - pub fn document(&self, document_id: impl Into) -> document::Document<'c, 'n, D> { - document::Document::new(self.client, self.collection_name, document_id.into()) + pub fn document<'d>( + &'d self, + document_id: impl Into>, + ) -> document::Document<'d, D> { + document::Document::new(self.client, &self.collection_name, document_id) } /// Retrieves the details of a collection, given its name. @@ -56,7 +60,7 @@ where Error>, > { let params = collections_api::GetCollectionParams { - collection_name: self.collection_name.into(), + collection_name: self.collection_name.as_ref().into(), _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::get_collection, params) @@ -71,7 +75,7 @@ where Error>, > { let params = collections_api::DeleteCollectionParams { - collection_name: self.collection_name.into(), + collection_name: self.collection_name.as_ref().into(), _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::delete_collection, params) @@ -90,7 +94,7 @@ where Error>, > { let params = collections_api::UpdateCollectionParams { - collection_name: self.collection_name.into(), + collection_name: self.collection_name.as_ref().into(), collection_update_schema: update_schema, _phantom: core::marker::PhantomData, }; diff --git a/typesense/src/client/mod.rs b/typesense/src/client/mod.rs index cc8227fe..773abd81 100644 --- a/typesense/src/client/mod.rs +++ b/typesense/src/client/mod.rs @@ -142,15 +142,16 @@ use reqwest_middleware::ClientBuilder as ReqwestMiddlewareClientBuilder; use reqwest_retry::RetryTransientMiddleware; pub use reqwest_retry::policies::ExponentialBackoff; -use debug_unsafe::{option::OptionUnwrapper, slice::SliceGetter}; -use serde::{Serialize, de::DeserializeOwned}; -use std::{ +use ::std::{ + borrow::Cow, future::Future, sync::{ RwLock, atomic::{AtomicBool, AtomicUsize, Ordering}, }, }; +use debug_unsafe::{option::OptionUnwrapper, slice::SliceGetter}; +use serde::{Serialize, de::DeserializeOwned}; use typesense_codegen::apis::{self, configuration}; use web_time::{Duration, Instant}; @@ -480,7 +481,10 @@ impl Client { /// # } /// ``` #[inline] - pub fn collection_named<'c, 'n, D>(&'c self, collection_name: &'n str) -> Collection<'c, 'n, D> + pub fn collection_named<'c, D>( + &'c self, + collection_name: impl Into>, + ) -> Collection<'c, D> where D: DeserializeOwned + Serialize, { @@ -525,7 +529,7 @@ impl Client { /// # } /// ``` #[inline] - pub fn collection<'c, 'n, D>(&'c self) -> Collection<'c, 'n, D> + pub fn collection<'c, D>(&'c self) -> Collection<'c, D> where D: Document, { @@ -561,10 +565,10 @@ impl Client { /// # } /// ``` #[inline] - pub fn collection_schemaless<'c, 'n>( + pub fn collection_schemaless<'c>( &'c self, - collection_name: &'n str, - ) -> Collection<'c, 'n, serde_json::Value> { + collection_name: impl Into>, + ) -> Collection<'c, serde_json::Value> { Collection::new(self, collection_name) } diff --git a/xtask/src/test_clean.rs b/xtask/src/test_clean.rs index 9acabf11..80209a66 100644 --- a/xtask/src/test_clean.rs +++ b/xtask/src/test_clean.rs @@ -27,7 +27,7 @@ async fn clean_test_artifacts() { } if let Err(err) = client - .collection_schemaless(&collection.name) + .collection_schemaless(collection.name.as_ref()) .delete() .await { From e2369053fc1b4c9b4b6097b842376d091abc533d Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Wed, 12 Nov 2025 15:18:07 +0000 Subject: [PATCH 08/17] Owned data in API response models --- openapi-generator-template/model.mustache | 10 +++--- preprocessed_openapi.yml | 31 ++++++++++++++++ typesense/src/traits/multi_search_ext.rs | 2 +- typesense_codegen/src/models/api_response.rs | 4 +-- .../src/models/collection_response.rs | 6 ++-- .../src/models/multi_search_result_item.rs | 2 +- .../src/models/schema_change_status.rs | 2 +- .../src/models/search_highlight.rs | 6 ++-- .../src/models/search_request_params.rs | 6 ++-- .../search_request_params_voice_query.rs | 2 +- .../src/models/search_result_conversation.rs | 12 +++---- .../search_result_hit_text_match_info.rs | 4 +-- .../models/search_synonym_delete_response.rs | 4 +-- xtask/src/add_vendor_attributes.rs | 2 ++ xtask/src/test_clean.rs | 2 +- xtask/src/vendor_attributes.rs | 35 ++++++++++++++++++- 16 files changed, 98 insertions(+), 32 deletions(-) diff --git a/openapi-generator-template/model.mustache b/openapi-generator-template/model.mustache index 574791e7..e4668cbf 100644 --- a/openapi-generator-template/model.mustache +++ b/openapi-generator-template/model.mustache @@ -127,9 +127,9 @@ impl Default for {{classname}} { #[derive(bon::Builder)] #[builder(on(Cow<'_, str>, into))] #[builder(on(String, into))] -{{/vendorExtensions.x-rust-builder}} -{{#vendorExtensions.x-rust-has-byte-array}}#[serde_as] -{{/vendorExtensions.x-rust-has-byte-array}}{{#oneOf.isEmpty}}#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +{{/vendorExtensions.x-rust-builder}}{{! +}}{{#vendorExtensions.x-rust-has-byte-array}}#[serde_as]{{/vendorExtensions.x-rust-has-byte-array}}{{! +}}{{#oneOf.isEmpty}}#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct {{{classname}}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}> { {{#vars}} {{#description}} @@ -153,7 +153,7 @@ pub struct {{{classname}}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{ ### ByteArray }}{{^isModel}}{{#isByteArray}}Vec{{/isByteArray}}{{! ### String - }}{{^isByteArray}}{{#isString}}Cow<'a, str>{{/isString}}{{! + }}{{^isByteArray}}{{#isString}}{{#model}}{{#vendorExtensions.x-rust-is-owned-data}}String{{/vendorExtensions.x-rust-is-owned-data}}{{^vendorExtensions.x-rust-is-owned-data}}Cow<'a, str>{{/vendorExtensions.x-rust-is-owned-data}}{{/model}}{{/isString}}{{! ### Arrays }}{{^isString}}{{#isArray}}Vec<{{#items}}{{! ### Array Models @@ -186,7 +186,7 @@ impl<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtension }}{{^vendorExtensions.x-rust-type}}{{#isNullable}}Option<{{/isNullable}}{{! }}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{! }}{{^isEnum}}{{#isByteArray}}Vec{{/isByteArray}}{{! - }}{{^isByteArray}}{{#isString}}Cow<'a, str>{{/isString}}{{! + }}{{^isByteArray}}{{#isString}}{{#model}}{{#vendorExtensions.x-rust-is-owned-data}}String{{/vendorExtensions.x-rust-is-owned-data}}{{^vendorExtensions.x-rust-is-owned-data}}Cow<'a, str>{{/vendorExtensions.x-rust-is-owned-data}}{{/model}}{{/isString}}{{! }}{{^isString}}{{#isArray}}Vec<{{#items}}{{! }}{{#isModel}}{{{dataType}}}<'a>{{/isModel}}{{! }}{{^isModel}}{{{dataType}}}{{/isModel}}{{/items}}>{{/isArray}}{{! diff --git a/preprocessed_openapi.yml b/preprocessed_openapi.yml index 69290aeb..896f5a37 100644 --- a/preprocessed_openapi.yml +++ b/preprocessed_openapi.yml @@ -3226,6 +3226,7 @@ components: description: Timestamp of when the collection was created (Unix epoch in seconds) format: int64 readOnly: true + x-rust-is-owned-data: true Field: required: - name @@ -3381,6 +3382,7 @@ components: x-go-type: '[]*CollectionAlias' items: $ref: '#/components/schemas/CollectionAlias' + x-rust-is-owned-data: true SearchResult: type: object properties: @@ -3429,7 +3431,9 @@ components: type: object description: Custom JSON object that can be returned in the search response additionalProperties: true + x-rust-is-owned-data: true x-rust-generic-parameter: D + x-rust-is-owned-data: true SearchRequestParams: type: object required: @@ -3448,6 +3452,8 @@ components: properties: transcribed_query: type: string + x-rust-is-owned-data: true + x-rust-is-owned-data: true SearchResultConversation: type: object required: @@ -3466,6 +3472,7 @@ components: type: string query: type: string + x-rust-is-owned-data: true SearchGroupedHit: type: object required: @@ -3484,6 +3491,7 @@ components: $ref: '#/components/schemas/SearchResultHit' x-rust-type: Vec> x-rust-generic-parameter: D + x-rust-is-owned-data: true SearchResultHit: type: object properties: @@ -3496,12 +3504,14 @@ components: type: object description: Highlighted version of the matching document additionalProperties: true + x-rust-is-owned-data: true document: type: object description: Can be any key-value pair additionalProperties: type: object x-rust-type: Option + x-rust-is-owned-data: true text_match: type: integer format: int64 @@ -3524,11 +3534,13 @@ components: type: integer typo_prefix_score: type: integer + x-rust-is-owned-data: true geo_distance_meters: type: object description: Can be any key-value pair additionalProperties: type: integer + x-rust-is-owned-data: true vector_distance: type: number format: float @@ -3541,6 +3553,7 @@ components: type: number format: float description: Combined score from rank fusion of text and vector search + x-rust-is-owned-data: true search_index: type: integer description: Returned only for union query response. Indicates the index of the query which this document matched to. @@ -3556,6 +3569,7 @@ components: country: USA text_match: 1234556 x-rust-generic-parameter: D + x-rust-is-owned-data: true SearchHighlight: type: object properties: @@ -3597,6 +3611,7 @@ components: items: type: object x-go-type: interface{} + x-rust-is-owned-data: true SearchSynonymSchema: type: object required: @@ -3636,6 +3651,7 @@ components: id: type: string description: The id of the synonym that was deleted + x-rust-is-owned-data: true SearchSynonymsResponse: type: object required: @@ -3646,6 +3662,7 @@ components: x-go-type: '[]*SearchSynonym' items: $ref: '#/components/schemas/SearchSynonym' + x-rust-is-owned-data: true HealthStatus: type: object required: @@ -3653,6 +3670,7 @@ components: properties: ok: type: boolean + x-rust-is-owned-data: true SchemaChangeStatus: type: object properties: @@ -3665,6 +3683,7 @@ components: altered_docs: type: integer description: Number of documents that have been altered + x-rust-is-owned-data: true SuccessStatus: type: object required: @@ -3672,6 +3691,7 @@ components: properties: success: type: boolean + x-rust-is-owned-data: true ApiResponse: type: object required: @@ -3679,6 +3699,7 @@ components: properties: message: type: string + x-rust-is-owned-data: true ApiKeySchema: type: object required: @@ -3722,6 +3743,7 @@ components: type: integer format: int64 description: The id of the API key that was deleted + x-rust-is-owned-data: true ApiKeysResponse: type: object required: @@ -3732,6 +3754,7 @@ components: x-go-type: '[]*ApiKey' items: $ref: '#/components/schemas/ApiKey' + x-rust-is-owned-data: true MultiSearchResult: type: object required: @@ -3745,6 +3768,7 @@ components: conversation: $ref: '#/components/schemas/SearchResultConversation' x-rust-generic-parameter: D + x-rust-is-owned-data: true MultiSearchResultItem: allOf: - $ref: '#/components/schemas/SearchResult' @@ -3758,6 +3782,7 @@ components: type: string description: Error description x-rust-generic-parameter: D + x-rust-is-owned-data: true SearchParameters: type: object properties: @@ -4355,6 +4380,7 @@ components: properties: ok: type: boolean + x-rust-is-owned-data: true AnalyticsEvent: type: object required: @@ -4413,6 +4439,7 @@ components: type: string query: type: string + x-rust-is-owned-data: true AnalyticsRuleCreate: type: object required: @@ -4503,6 +4530,7 @@ components: type: integer doc_counter_events: type: integer + x-rust-is-owned-data: true APIStatsResponse: type: object properties: @@ -4521,6 +4549,7 @@ components: latency_ms: type: object x-go-type: map[string]float64 + x-rust-is-owned-data: true overloaded_requests_per_second: type: number format: double @@ -4530,6 +4559,7 @@ components: requests_per_second: type: object x-go-type: map[string]float64 + x-rust-is-owned-data: true search_latency_ms: type: number format: double @@ -4545,6 +4575,7 @@ components: write_requests_per_second: type: number format: double + x-rust-is-owned-data: true StopwordsSetUpsertSchema: type: object properties: diff --git a/typesense/src/traits/multi_search_ext.rs b/typesense/src/traits/multi_search_ext.rs index b6fc7d77..8bb233f2 100644 --- a/typesense/src/traits/multi_search_ext.rs +++ b/typesense/src/traits/multi_search_ext.rs @@ -119,7 +119,7 @@ impl<'a> MultiSearchResultExt<'a> for MultiSearchResult<'a, Value> { if let Some(error_msg) = &raw_item.error { return Err(MultiSearchParseError::ApiError { index, - message: error_msg.clone().into_owned(), + message: error_msg.clone(), }); } diff --git a/typesense_codegen/src/models/api_response.rs b/typesense_codegen/src/models/api_response.rs index eb5910b8..8f474400 100644 --- a/typesense_codegen/src/models/api_response.rs +++ b/typesense_codegen/src/models/api_response.rs @@ -15,13 +15,13 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ApiResponse<'a> { #[serde(rename = "message")] - pub message: Cow<'a, str>, + pub message: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> ApiResponse<'a> { - pub fn new(message: Cow<'a, str>) -> Self { + pub fn new(message: String) -> Self { Self { message, _phantom: PhantomData, diff --git a/typesense_codegen/src/models/collection_response.rs b/typesense_codegen/src/models/collection_response.rs index 4bd20f9b..3a42c1b5 100644 --- a/typesense_codegen/src/models/collection_response.rs +++ b/typesense_codegen/src/models/collection_response.rs @@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize}; pub struct CollectionResponse<'a> { /// Name of the collection #[serde(rename = "name")] - pub name: Cow<'a, str>, + pub name: String, /// A list of fields for querying, filtering and faceting #[serde(rename = "fields")] pub fields: Vec>, @@ -25,7 +25,7 @@ pub struct CollectionResponse<'a> { rename = "default_sorting_field", skip_serializing_if = "Option::is_none" )] - pub default_sorting_field: Option>, + pub default_sorting_field: Option, /// List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters. #[serde(rename = "token_separators", skip_serializing_if = "Option::is_none")] pub token_separators: Option>, @@ -58,7 +58,7 @@ pub struct CollectionResponse<'a> { impl<'a> CollectionResponse<'a> { pub fn new( - name: Cow<'a, str>, + name: String, fields: Vec>, num_documents: i64, created_at: i64, diff --git a/typesense_codegen/src/models/multi_search_result_item.rs b/typesense_codegen/src/models/multi_search_result_item.rs index cde46996..9f294cde 100644 --- a/typesense_codegen/src/models/multi_search_result_item.rs +++ b/typesense_codegen/src/models/multi_search_result_item.rs @@ -56,7 +56,7 @@ pub struct MultiSearchResultItem<'a, D> { pub code: Option, /// Error description #[serde(rename = "error", skip_serializing_if = "Option::is_none")] - pub error: Option>, + pub error: Option, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } diff --git a/typesense_codegen/src/models/schema_change_status.rs b/typesense_codegen/src/models/schema_change_status.rs index 726d8132..db49514b 100644 --- a/typesense_codegen/src/models/schema_change_status.rs +++ b/typesense_codegen/src/models/schema_change_status.rs @@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize}; pub struct SchemaChangeStatus<'a> { /// Name of the collection being modified #[serde(rename = "collection", skip_serializing_if = "Option::is_none")] - pub collection: Option>, + pub collection: Option, /// Number of documents that have been validated #[serde(rename = "validated_docs", skip_serializing_if = "Option::is_none")] pub validated_docs: Option, diff --git a/typesense_codegen/src/models/search_highlight.rs b/typesense_codegen/src/models/search_highlight.rs index ae05e107..5e9922b6 100644 --- a/typesense_codegen/src/models/search_highlight.rs +++ b/typesense_codegen/src/models/search_highlight.rs @@ -15,16 +15,16 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct SearchHighlight<'a> { #[serde(rename = "field", skip_serializing_if = "Option::is_none")] - pub field: Option>, + pub field: Option, /// Present only for (non-array) string fields #[serde(rename = "snippet", skip_serializing_if = "Option::is_none")] - pub snippet: Option>, + pub snippet: Option, /// Present only for (array) string[] fields #[serde(rename = "snippets", skip_serializing_if = "Option::is_none")] pub snippets: Option>, /// Full field value with highlighting, present only for (non-array) string fields #[serde(rename = "value", skip_serializing_if = "Option::is_none")] - pub value: Option>, + pub value: Option, /// Full field value with highlighting, present only for (array) string[] fields #[serde(rename = "values", skip_serializing_if = "Option::is_none")] pub values: Option>, diff --git a/typesense_codegen/src/models/search_request_params.rs b/typesense_codegen/src/models/search_request_params.rs index 333935d6..bf2bbb2b 100644 --- a/typesense_codegen/src/models/search_request_params.rs +++ b/typesense_codegen/src/models/search_request_params.rs @@ -15,9 +15,9 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct SearchRequestParams<'a> { #[serde(rename = "collection_name")] - pub collection_name: Cow<'a, str>, + pub collection_name: String, #[serde(rename = "q")] - pub q: Cow<'a, str>, + pub q: String, #[serde(rename = "per_page")] pub per_page: i32, #[serde(rename = "voice_query", skip_serializing_if = "Option::is_none")] @@ -27,7 +27,7 @@ pub struct SearchRequestParams<'a> { } impl<'a> SearchRequestParams<'a> { - pub fn new(collection_name: Cow<'a, str>, q: Cow<'a, str>, per_page: i32) -> Self { + pub fn new(collection_name: String, q: String, per_page: i32) -> Self { Self { collection_name, q, diff --git a/typesense_codegen/src/models/search_request_params_voice_query.rs b/typesense_codegen/src/models/search_request_params_voice_query.rs index ea18775d..adb01b45 100644 --- a/typesense_codegen/src/models/search_request_params_voice_query.rs +++ b/typesense_codegen/src/models/search_request_params_voice_query.rs @@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct SearchRequestParamsVoiceQuery<'a> { #[serde(rename = "transcribed_query", skip_serializing_if = "Option::is_none")] - pub transcribed_query: Option>, + pub transcribed_query: Option, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } diff --git a/typesense_codegen/src/models/search_result_conversation.rs b/typesense_codegen/src/models/search_result_conversation.rs index 58cee0e0..aaa045d9 100644 --- a/typesense_codegen/src/models/search_result_conversation.rs +++ b/typesense_codegen/src/models/search_result_conversation.rs @@ -15,23 +15,23 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct SearchResultConversation<'a> { #[serde(rename = "answer")] - pub answer: Cow<'a, str>, + pub answer: String, #[serde(rename = "conversation_history")] pub conversation_history: Vec, #[serde(rename = "conversation_id")] - pub conversation_id: Cow<'a, str>, + pub conversation_id: String, #[serde(rename = "query")] - pub query: Cow<'a, str>, + pub query: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> SearchResultConversation<'a> { pub fn new( - answer: Cow<'a, str>, + answer: String, conversation_history: Vec, - conversation_id: Cow<'a, str>, - query: Cow<'a, str>, + conversation_id: String, + query: String, ) -> Self { Self { answer, diff --git a/typesense_codegen/src/models/search_result_hit_text_match_info.rs b/typesense_codegen/src/models/search_result_hit_text_match_info.rs index bbb27f14..9b3976ec 100644 --- a/typesense_codegen/src/models/search_result_hit_text_match_info.rs +++ b/typesense_codegen/src/models/search_result_hit_text_match_info.rs @@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct SearchResultHitTextMatchInfo<'a> { #[serde(rename = "best_field_score", skip_serializing_if = "Option::is_none")] - pub best_field_score: Option>, + pub best_field_score: Option, #[serde(rename = "best_field_weight", skip_serializing_if = "Option::is_none")] pub best_field_weight: Option, #[serde(rename = "fields_matched", skip_serializing_if = "Option::is_none")] @@ -23,7 +23,7 @@ pub struct SearchResultHitTextMatchInfo<'a> { #[serde(rename = "num_tokens_dropped", skip_serializing_if = "Option::is_none")] pub num_tokens_dropped: Option, #[serde(rename = "score", skip_serializing_if = "Option::is_none")] - pub score: Option>, + pub score: Option, #[serde(rename = "tokens_matched", skip_serializing_if = "Option::is_none")] pub tokens_matched: Option, #[serde(rename = "typo_prefix_score", skip_serializing_if = "Option::is_none")] diff --git a/typesense_codegen/src/models/search_synonym_delete_response.rs b/typesense_codegen/src/models/search_synonym_delete_response.rs index 988df8de..6e4e3d9c 100644 --- a/typesense_codegen/src/models/search_synonym_delete_response.rs +++ b/typesense_codegen/src/models/search_synonym_delete_response.rs @@ -16,13 +16,13 @@ use serde::{Deserialize, Serialize}; pub struct SearchSynonymDeleteResponse<'a> { /// The id of the synonym that was deleted #[serde(rename = "id")] - pub id: Cow<'a, str>, + pub id: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> SearchSynonymDeleteResponse<'a> { - pub fn new(id: Cow<'a, str>) -> Self { + pub fn new(id: String) -> Self { Self { id, _phantom: PhantomData, diff --git a/xtask/src/add_vendor_attributes.rs b/xtask/src/add_vendor_attributes.rs index 18e481e7..ae98c251 100644 --- a/xtask/src/add_vendor_attributes.rs +++ b/xtask/src/add_vendor_attributes.rs @@ -96,5 +96,7 @@ pub fn add_vendor_attributes(doc_root: &mut Mapping) -> Result<(), String> { .request_type("B") .done()?; + attrs.schemas_mark_owned_data()?; + Ok(()) } diff --git a/xtask/src/test_clean.rs b/xtask/src/test_clean.rs index 80209a66..a527b92b 100644 --- a/xtask/src/test_clean.rs +++ b/xtask/src/test_clean.rs @@ -27,7 +27,7 @@ async fn clean_test_artifacts() { } if let Err(err) = client - .collection_schemaless(collection.name.as_ref()) + .collection_schemaless(collection.name.as_str()) .delete() .await { diff --git a/xtask/src/vendor_attributes.rs b/xtask/src/vendor_attributes.rs index 39baceb0..a625f2bf 100644 --- a/xtask/src/vendor_attributes.rs +++ b/xtask/src/vendor_attributes.rs @@ -49,7 +49,7 @@ impl<'a> VendorAttributes<'a> { #[inline] fn insert_into_map(map: &mut Mapping, attr: &str, val: Value) { - map.insert(Value::String(attr.to_string()), val); + map.insert(Value::String(attr.to_owned()), val); } fn set_attr( @@ -113,6 +113,39 @@ impl<'a> VendorAttributes<'a> { } } + pub fn schemas_mark_owned_data(&mut self) -> Result<&mut Self, String> { + let map = self.get_map_mut(&["components", "schemas"])?; + for (schema_n, schema_m) in map { + let (Value::String(schema_name), Value::Mapping(schema_map)) = (schema_n, schema_m) + else { + continue; + }; + if schema_name.ends_with("Response") + || schema_name.contains("Result") + || schema_name.ends_with("Status") + || schema_name.ends_with("Hit") + || ["SearchRequestParams", "SearchHighlight"].contains(&schema_name.as_str()) + { + Self::insert_into_map(schema_map, "x-rust-is-owned-data", Value::Bool(true)); + if let Some(Value::Mapping(props)) = schema_map.get_mut("properties") { + for (_, prop_m) in props { + let Value::Mapping(prop_map) = prop_m else { + continue; + }; + let Some(Value::String(typ)) = prop_map.get("type") else { + continue; + }; + if typ != "object" { + continue; + } + Self::insert_into_map(prop_map, "x-rust-is-owned-data", Value::Bool(true)); + } + } + } + } + Ok(self) + } + pub fn schema_generic_parameter( &mut self, items: [(&str, &str); N], From c93dfc2454a1a98b94c6044ee503293cbf711805 Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Wed, 12 Nov 2025 21:13:06 +0000 Subject: [PATCH 09/17] Rm unused api --- typesense_codegen/src/apis/curation_api.rs | 250 ------------------ typesense_codegen/src/apis/override_api.rs | 92 ------- .../src/models/search_override.rs | 79 ------ .../models/search_override_delete_response.rs | 25 -- .../src/models/search_override_exclude.rs | 25 -- .../src/models/search_override_include.rs | 28 -- .../src/models/search_override_rule.rs | 53 ---- .../src/models/search_override_schema.rs | 76 ------ .../src/models/search_overrides_response.rs | 24 -- 9 files changed, 652 deletions(-) delete mode 100644 typesense_codegen/src/apis/curation_api.rs delete mode 100644 typesense_codegen/src/apis/override_api.rs delete mode 100644 typesense_codegen/src/models/search_override.rs delete mode 100644 typesense_codegen/src/models/search_override_delete_response.rs delete mode 100644 typesense_codegen/src/models/search_override_exclude.rs delete mode 100644 typesense_codegen/src/models/search_override_include.rs delete mode 100644 typesense_codegen/src/models/search_override_rule.rs delete mode 100644 typesense_codegen/src/models/search_override_schema.rs delete mode 100644 typesense_codegen/src/models/search_overrides_response.rs diff --git a/typesense_codegen/src/apis/curation_api.rs b/typesense_codegen/src/apis/curation_api.rs deleted file mode 100644 index 4d3c9c64..00000000 --- a/typesense_codegen/src/apis/curation_api.rs +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Typesense API - * - * An open source search engine for building delightful search experiences. - * - * The version of the OpenAPI document: 30.0 - * - * Generated by: https://openapi-generator.tech - */ - -use super::{ContentType, Error, configuration}; -use crate::{apis::ResponseContent, models}; -use reqwest; -use serde::{Deserialize, Serialize, de::Error as _}; - -/// struct for passing parameters to the method [`delete_search_override`] -#[derive(Clone, Debug)] -pub struct DeleteSearchOverrideParams { - /// The name of the collection - pub collection_name: String, - /// The ID of the search override to delete - pub override_id: String, -} - -/// struct for passing parameters to the method [`get_search_overrides`] -#[derive(Clone, Debug)] -pub struct GetSearchOverridesParams { - /// The name of the collection - pub collection_name: String, -} - -/// struct for passing parameters to the method [`upsert_search_override`] -#[derive(Clone, Debug)] -pub struct UpsertSearchOverrideParams { - /// The name of the collection - pub collection_name: String, - /// The ID of the search override to create/update - pub override_id: String, - /// The search override object to be created/updated - pub search_override_schema: models::SearchOverrideSchema, -} - -/// struct for typed errors of method [`delete_search_override`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum DeleteSearchOverrideError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`get_search_overrides`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetSearchOverridesError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`upsert_search_override`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum UpsertSearchOverrideError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), -} - -pub async fn delete_search_override( - configuration: &configuration::Configuration, - params: &DeleteSearchOverrideParams, -) -> Result> { - let uri_str = format!( - "{}/collections/{collectionName}/overrides/{overrideId}", - configuration.base_path, - collectionName = crate::apis::urlencode(¶ms.collection_name), - overrideId = crate::apis::urlencode(¶ms.override_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref apikey) = configuration.api_key { - let key = &apikey.key; - let value = match apikey.prefix { - Some(ref prefix) => &format!("{prefix} {key}"), - None => key, - }; - req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => { - return Err(Error::from(serde_json::Error::custom( - "Received `text/plain` content type response that cannot be converted to `models::SearchOverrideDeleteResponse`", - ))); - } - ContentType::Unsupported(unknown_type) => { - return Err(Error::from(serde_json::Error::custom(format!( - "Received `{unknown_type}` content type response that cannot be converted to `models::SearchOverrideDeleteResponse`" - )))); - } - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn get_search_overrides( - configuration: &configuration::Configuration, - params: &GetSearchOverridesParams, -) -> Result> { - let uri_str = format!( - "{}/collections/{collectionName}/overrides", - configuration.base_path, - collectionName = crate::apis::urlencode(¶ms.collection_name) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref apikey) = configuration.api_key { - let key = &apikey.key; - let value = match apikey.prefix { - Some(ref prefix) => &format!("{prefix} {key}"), - None => key, - }; - req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => { - return Err(Error::from(serde_json::Error::custom( - "Received `text/plain` content type response that cannot be converted to `models::SearchOverridesResponse`", - ))); - } - ContentType::Unsupported(unknown_type) => { - return Err(Error::from(serde_json::Error::custom(format!( - "Received `{unknown_type}` content type response that cannot be converted to `models::SearchOverridesResponse`" - )))); - } - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -/// Create or update an override to promote certain documents over others. Using overrides, you can include or exclude specific documents for a given query. -pub async fn upsert_search_override( - configuration: &configuration::Configuration, - params: &UpsertSearchOverrideParams, -) -> Result> { - let uri_str = format!( - "{}/collections/{collectionName}/overrides/{overrideId}", - configuration.base_path, - collectionName = crate::apis::urlencode(¶ms.collection_name), - overrideId = crate::apis::urlencode(¶ms.override_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref apikey) = configuration.api_key { - let key = &apikey.key; - let value = match apikey.prefix { - Some(ref prefix) => &format!("{prefix} {key}"), - None => key, - }; - req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); - }; - req_builder = req_builder.json(¶ms.search_override_schema); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => { - return Err(Error::from(serde_json::Error::custom( - "Received `text/plain` content type response that cannot be converted to `models::SearchOverride`", - ))); - } - ContentType::Unsupported(unknown_type) => { - return Err(Error::from(serde_json::Error::custom(format!( - "Received `{unknown_type}` content type response that cannot be converted to `models::SearchOverride`" - )))); - } - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/typesense_codegen/src/apis/override_api.rs b/typesense_codegen/src/apis/override_api.rs deleted file mode 100644 index 9eadf5ad..00000000 --- a/typesense_codegen/src/apis/override_api.rs +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Typesense API - * - * An open source search engine for building delightful search experiences. - * - * The version of the OpenAPI document: 30.0 - * - * Generated by: https://openapi-generator.tech - */ - -use super::{ContentType, Error, configuration}; -use crate::{apis::ResponseContent, models}; -use reqwest; -use serde::{Deserialize, Serialize, de::Error as _}; - -/// struct for passing parameters to the method [`get_search_override`] -#[derive(Clone, Debug)] -pub struct GetSearchOverrideParams { - /// The name of the collection - pub collection_name: String, - /// The id of the search override - pub override_id: String, -} - -/// struct for typed errors of method [`get_search_override`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetSearchOverrideError { - UnknownValue(serde_json::Value), -} - -/// Retrieve the details of a search override, given its id. -pub async fn get_search_override( - configuration: &configuration::Configuration, - params: &GetSearchOverrideParams, -) -> Result> { - let uri_str = format!( - "{}/collections/{collectionName}/overrides/{overrideId}", - configuration.base_path, - collectionName = crate::apis::urlencode(¶ms.collection_name), - overrideId = crate::apis::urlencode(¶ms.override_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref apikey) = configuration.api_key { - let key = &apikey.key; - let value = match apikey.prefix { - Some(ref prefix) => &format!("{prefix} {key}"), - None => key, - }; - req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => { - return Err(Error::from(serde_json::Error::custom( - "Received `text/plain` content type response that cannot be converted to `models::SearchOverride`", - ))); - } - ContentType::Unsupported(unknown_type) => { - return Err(Error::from(serde_json::Error::custom(format!( - "Received `{unknown_type}` content type response that cannot be converted to `models::SearchOverride`" - )))); - } - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/typesense_codegen/src/models/search_override.rs b/typesense_codegen/src/models/search_override.rs deleted file mode 100644 index b1f8353f..00000000 --- a/typesense_codegen/src/models/search_override.rs +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Typesense API - * - * An open source search engine for building delightful search experiences. - * - * The version of the OpenAPI document: 30.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchOverride { - #[serde(rename = "rule")] - pub rule: Box, - /// List of document `id`s that should be included in the search results with their corresponding `position`s. - #[serde(rename = "includes", skip_serializing_if = "Option::is_none")] - pub includes: Option>, - /// List of document `id`s that should be excluded from the search results. - #[serde(rename = "excludes", skip_serializing_if = "Option::is_none")] - pub excludes: Option>, - /// A filter by clause that is applied to any search query that matches the override rule. - #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] - pub filter_by: Option, - /// Indicates whether search query tokens that exist in the override's rule should be removed from the search query. - #[serde( - rename = "remove_matched_tokens", - skip_serializing_if = "Option::is_none" - )] - pub remove_matched_tokens: Option, - /// Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered. - #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] - pub metadata: Option, - /// A sort by clause that is applied to any search query that matches the override rule. - #[serde(rename = "sort_by", skip_serializing_if = "Option::is_none")] - pub sort_by: Option, - /// Replaces the current search query with this value, when the search query matches the override rule. - #[serde(rename = "replace_query", skip_serializing_if = "Option::is_none")] - pub replace_query: Option, - /// When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. - #[serde( - rename = "filter_curated_hits", - skip_serializing_if = "Option::is_none" - )] - pub filter_curated_hits: Option, - /// A Unix timestamp that indicates the date/time from which the override will be active. You can use this to create override rules that start applying from a future point in time. - #[serde(rename = "effective_from_ts", skip_serializing_if = "Option::is_none")] - pub effective_from_ts: Option, - /// A Unix timestamp that indicates the date/time until which the override will be active. You can use this to create override rules that stop applying after a period of time. - #[serde(rename = "effective_to_ts", skip_serializing_if = "Option::is_none")] - pub effective_to_ts: Option, - /// When set to true, override processing will stop at the first matching rule. When set to false override processing will continue and multiple override actions will be triggered in sequence. Overrides are processed in the lexical sort order of their id field. Default: true. - #[serde(rename = "stop_processing", skip_serializing_if = "Option::is_none")] - pub stop_processing: Option, - #[serde(rename = "id")] - pub id: String, -} - -impl SearchOverride { - pub fn new(rule: models::SearchOverrideRule, id: String) -> SearchOverride { - SearchOverride { - rule: Box::new(rule), - includes: None, - excludes: None, - filter_by: None, - remove_matched_tokens: None, - metadata: None, - sort_by: None, - replace_query: None, - filter_curated_hits: None, - effective_from_ts: None, - effective_to_ts: None, - stop_processing: None, - id, - } - } -} diff --git a/typesense_codegen/src/models/search_override_delete_response.rs b/typesense_codegen/src/models/search_override_delete_response.rs deleted file mode 100644 index 39493200..00000000 --- a/typesense_codegen/src/models/search_override_delete_response.rs +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Typesense API - * - * An open source search engine for building delightful search experiences. - * - * The version of the OpenAPI document: 30.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchOverrideDeleteResponse { - /// The id of the override that was deleted - #[serde(rename = "id")] - pub id: String, -} - -impl SearchOverrideDeleteResponse { - pub fn new(id: String) -> SearchOverrideDeleteResponse { - SearchOverrideDeleteResponse { id } - } -} diff --git a/typesense_codegen/src/models/search_override_exclude.rs b/typesense_codegen/src/models/search_override_exclude.rs deleted file mode 100644 index 58b01b99..00000000 --- a/typesense_codegen/src/models/search_override_exclude.rs +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Typesense API - * - * An open source search engine for building delightful search experiences. - * - * The version of the OpenAPI document: 30.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchOverrideExclude { - /// document id that should be excluded from the search results. - #[serde(rename = "id")] - pub id: String, -} - -impl SearchOverrideExclude { - pub fn new(id: String) -> SearchOverrideExclude { - SearchOverrideExclude { id } - } -} diff --git a/typesense_codegen/src/models/search_override_include.rs b/typesense_codegen/src/models/search_override_include.rs deleted file mode 100644 index 7756358e..00000000 --- a/typesense_codegen/src/models/search_override_include.rs +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Typesense API - * - * An open source search engine for building delightful search experiences. - * - * The version of the OpenAPI document: 30.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchOverrideInclude { - /// document id that should be included - #[serde(rename = "id")] - pub id: String, - /// position number where document should be included in the search results - #[serde(rename = "position")] - pub position: i32, -} - -impl SearchOverrideInclude { - pub fn new(id: String, position: i32) -> SearchOverrideInclude { - SearchOverrideInclude { id, position } - } -} diff --git a/typesense_codegen/src/models/search_override_rule.rs b/typesense_codegen/src/models/search_override_rule.rs deleted file mode 100644 index de9ebf50..00000000 --- a/typesense_codegen/src/models/search_override_rule.rs +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Typesense API - * - * An open source search engine for building delightful search experiences. - * - * The version of the OpenAPI document: 30.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchOverrideRule { - /// List of tag values to associate with this override rule. - #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] - pub tags: Option>, - /// Indicates what search queries should be overridden - #[serde(rename = "query", skip_serializing_if = "Option::is_none")] - pub query: Option, - /// Indicates whether the match on the query term should be `exact` or `contains`. If we want to match all queries that contained the word `apple`, we will use the `contains` match instead. - #[serde(rename = "match", skip_serializing_if = "Option::is_none")] - pub r#match: Option, - /// Indicates that the override should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc). - #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] - pub filter_by: Option, -} - -impl SearchOverrideRule { - pub fn new() -> SearchOverrideRule { - SearchOverrideRule { - tags: None, - query: None, - r#match: None, - filter_by: None, - } - } -} -/// Indicates whether the match on the query term should be `exact` or `contains`. If we want to match all queries that contained the word `apple`, we will use the `contains` match instead. -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] -pub enum Match { - #[serde(rename = "exact")] - Exact, - #[serde(rename = "contains")] - Contains, -} - -impl Default for Match { - fn default() -> Match { - Self::Exact - } -} diff --git a/typesense_codegen/src/models/search_override_schema.rs b/typesense_codegen/src/models/search_override_schema.rs deleted file mode 100644 index 1b0eede1..00000000 --- a/typesense_codegen/src/models/search_override_schema.rs +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Typesense API - * - * An open source search engine for building delightful search experiences. - * - * The version of the OpenAPI document: 30.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchOverrideSchema { - #[serde(rename = "rule")] - pub rule: Box, - /// List of document `id`s that should be included in the search results with their corresponding `position`s. - #[serde(rename = "includes", skip_serializing_if = "Option::is_none")] - pub includes: Option>, - /// List of document `id`s that should be excluded from the search results. - #[serde(rename = "excludes", skip_serializing_if = "Option::is_none")] - pub excludes: Option>, - /// A filter by clause that is applied to any search query that matches the override rule. - #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] - pub filter_by: Option, - /// Indicates whether search query tokens that exist in the override's rule should be removed from the search query. - #[serde( - rename = "remove_matched_tokens", - skip_serializing_if = "Option::is_none" - )] - pub remove_matched_tokens: Option, - /// Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered. - #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] - pub metadata: Option, - /// A sort by clause that is applied to any search query that matches the override rule. - #[serde(rename = "sort_by", skip_serializing_if = "Option::is_none")] - pub sort_by: Option, - /// Replaces the current search query with this value, when the search query matches the override rule. - #[serde(rename = "replace_query", skip_serializing_if = "Option::is_none")] - pub replace_query: Option, - /// When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. - #[serde( - rename = "filter_curated_hits", - skip_serializing_if = "Option::is_none" - )] - pub filter_curated_hits: Option, - /// A Unix timestamp that indicates the date/time from which the override will be active. You can use this to create override rules that start applying from a future point in time. - #[serde(rename = "effective_from_ts", skip_serializing_if = "Option::is_none")] - pub effective_from_ts: Option, - /// A Unix timestamp that indicates the date/time until which the override will be active. You can use this to create override rules that stop applying after a period of time. - #[serde(rename = "effective_to_ts", skip_serializing_if = "Option::is_none")] - pub effective_to_ts: Option, - /// When set to true, override processing will stop at the first matching rule. When set to false override processing will continue and multiple override actions will be triggered in sequence. Overrides are processed in the lexical sort order of their id field. Default: true. - #[serde(rename = "stop_processing", skip_serializing_if = "Option::is_none")] - pub stop_processing: Option, -} - -impl SearchOverrideSchema { - pub fn new(rule: models::SearchOverrideRule) -> SearchOverrideSchema { - SearchOverrideSchema { - rule: Box::new(rule), - includes: None, - excludes: None, - filter_by: None, - remove_matched_tokens: None, - metadata: None, - sort_by: None, - replace_query: None, - filter_curated_hits: None, - effective_from_ts: None, - effective_to_ts: None, - stop_processing: None, - } - } -} diff --git a/typesense_codegen/src/models/search_overrides_response.rs b/typesense_codegen/src/models/search_overrides_response.rs deleted file mode 100644 index fd8aba3f..00000000 --- a/typesense_codegen/src/models/search_overrides_response.rs +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Typesense API - * - * An open source search engine for building delightful search experiences. - * - * The version of the OpenAPI document: 30.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchOverridesResponse { - #[serde(rename = "overrides")] - pub overrides: Vec, -} - -impl SearchOverridesResponse { - pub fn new(overrides: Vec) -> SearchOverridesResponse { - SearchOverridesResponse { overrides } - } -} From c1958608faa5733e354f59d6a1e06430625afb58 Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Wed, 12 Nov 2025 20:28:41 +0000 Subject: [PATCH 10/17] XTask schemas_mark_owned_data --- Cargo.toml | 1 + preprocessed_openapi.yml | 595 ++++++++++-------- .../analytics_events_response_events_inner.rs | 12 +- .../src/models/analytics_rule.rs | 15 +- typesense_codegen/src/models/api_key.rs | 8 +- .../src/models/collection_alias.rs | 6 +- .../src/models/conversation_model_schema.rs | 21 +- .../src/models/curation_exclude.rs | 4 +- .../src/models/curation_include.rs | 4 +- .../src/models/curation_item_delete_schema.rs | 4 +- .../src/models/curation_item_schema.rs | 10 +- typesense_codegen/src/models/curation_rule.rs | 4 +- .../src/models/curation_set_delete_schema.rs | 4 +- .../src/models/curation_set_schema.rs | 6 +- typesense_codegen/src/models/facet_counts.rs | 2 +- .../src/models/facet_counts_counts_inner.rs | 4 +- typesense_codegen/src/models/field.rs | 14 +- .../src/models/nl_search_model_base.rs | 24 +- .../models/nl_search_model_delete_schema.rs | 4 +- .../src/models/nl_search_model_schema.rs | 28 +- .../src/models/preset_delete_schema.rs | 4 +- typesense_codegen/src/models/preset_schema.rs | 4 +- .../src/models/search_synonym.rs | 8 +- .../src/models/search_synonym_schema.rs | 4 +- .../src/models/stemming_dictionary.rs | 4 +- .../models/stemming_dictionary_words_inner.rs | 6 +- .../src/models/stopwords_set_schema.rs | 6 +- .../src/models/synonym_item_delete_schema.rs | 4 +- .../src/models/synonym_set_delete_schema.rs | 4 +- .../src/models/synonym_set_schema.rs | 4 +- .../voice_query_model_collection_config.rs | 2 +- typesense_derive/src/field_attributes.rs | 4 +- xtask/Cargo.toml | 3 +- xtask/src/add_vendor_attributes.rs | 47 +- xtask/src/preprocess_openapi.rs | 375 ++++++++--- xtask/src/vendor_attributes.rs | 309 +++------ 36 files changed, 841 insertions(+), 717 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 626ce20f..fd092420 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ bon = "3" clap = { version = "4", features = ["derive"] } debug_unsafe = "0.1" hmac = "0.12" +indexmap = { version = "2", features = ["serde"] } reqwest-retry = "0.7" serde = { version = "1", features = ["derive"] } serde_json = "1.0" diff --git a/preprocessed_openapi.yml b/preprocessed_openapi.yml index 896f5a37..9ed67b27 100644 --- a/preprocessed_openapi.yml +++ b/preprocessed_openapi.yml @@ -116,9 +116,9 @@ paths: application/json: schema: type: array - x-go-type: '[]*CollectionResponse' items: $ref: '#/components/schemas/CollectionResponse' + x-go-type: '[]*CollectionResponse' post: tags: - collections @@ -127,11 +127,11 @@ paths: operationId: createCollection requestBody: description: The collection object to be created + required: true content: application/json: schema: $ref: '#/components/schemas/CollectionSchema' - required: true responses: '201': description: Collection successfully created @@ -193,11 +193,11 @@ paths: type: string requestBody: description: The document object with fields to be updated + required: true content: application/json: schema: $ref: '#/components/schemas/CollectionUpdateSchema' - required: true responses: '200': description: The updated partial collection schema @@ -271,21 +271,21 @@ paths: $ref: '#/components/schemas/DirtyValues' requestBody: description: The document object to be indexed + required: true content: application/json: schema: - type: object description: Can be any key-value pair + type: object x-go-type: interface{} - required: true responses: '201': description: Document successfully created/indexed content: application/json: schema: - type: object description: Can be any key-value pair + type: object '404': description: Collection not found content: @@ -310,6 +310,17 @@ paths: schema: type: string example: 'num_employees:>100 && country: [USA, UK]' + requestBody: + description: The document fields to be updated + required: true + content: + application/json: + schema: + description: Can be any key-value pair + type: object + x-go-type: interface{} + x-rust-params-generic-parameter: B + x-rust-type: B responses: '200': description: The response contains a single field, `num_updated`, indicating the number of documents affected. @@ -321,8 +332,8 @@ paths: - num_updated properties: num_updated: - type: integer description: The number of documents that have been updated + type: integer example: 1 '400': description: Bad request, see error message for details @@ -336,17 +347,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiResponse' - requestBody: - description: The document fields to be updated - content: - application/json: - schema: - type: object - description: Can be any key-value pair - x-go-type: interface{} - required: true - x-rust-params-generic-parameter: B - x-rust-type: B x-rust-generic-parameter: 'B: Serialize' delete: tags: @@ -594,8 +594,8 @@ paths: - name: synonym_sets in: query schema: - type: string description: List of synonym set names to associate with this search query + type: string example: synonym_set_1,synonym_set_2 - name: drop_tokens_threshold in: query @@ -616,33 +616,33 @@ paths: - name: enable_typos_for_alpha_numerical_tokens in: query schema: - type: boolean description: | Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. + type: boolean - name: filter_curated_hits in: query schema: - type: boolean description: | Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false + type: boolean - name: enable_synonyms in: query schema: - type: boolean description: | If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true + type: boolean - name: synonym_prefix in: query schema: - type: boolean description: | Allow synonym resolution on word prefixes in the query. Default: false + type: boolean - name: synonym_num_typos in: query schema: - type: integer description: | Allow synonym resolution on typo-corrected words in the query. Default: 0 + type: integer - name: pinned_hits in: query schema: @@ -903,11 +903,11 @@ paths: type: string requestBody: description: The synonym set to be created/updated + required: true content: application/json: schema: $ref: '#/components/schemas/SynonymSetCreateSchema' - required: true responses: '200': description: Synonym set successfully created/updated @@ -1030,11 +1030,11 @@ paths: type: string requestBody: description: The synonym item to be created/updated + required: true content: application/json: schema: $ref: '#/components/schemas/SynonymItemSchema' - required: true responses: '200': description: Synonym item successfully created/updated @@ -1138,11 +1138,11 @@ paths: type: string requestBody: description: The curation set to be created/updated + required: true content: application/json: schema: $ref: '#/components/schemas/CurationSetCreateSchema' - required: true responses: '200': description: Curation set successfully created/updated @@ -1265,11 +1265,11 @@ paths: type: string requestBody: description: The curation item to be created/updated + required: true content: application/json: schema: $ref: '#/components/schemas/CurationItemCreateSchema' - required: true responses: '200': description: Curation item successfully created/updated @@ -1383,8 +1383,8 @@ paths: - name: return_id in: query schema: - type: boolean description: Returning the id of the imported documents. If you want the import response to return the ingested document's id in the response, you can use the return_id parameter. + type: boolean - name: remote_embedding_batch_size in: query schema: @@ -1403,12 +1403,12 @@ paths: $ref: '#/components/schemas/DirtyValues' requestBody: description: The json array of documents or the JSONL file to import + required: true content: application/octet-stream: schema: - type: string description: The JSONL file to import - required: true + type: string responses: '200': description: Result of the import operation. Each line of the response indicates the result of each document present in the request body (in the same order). If the import of a single document fails, it does not affect the other documents. If there is a failure, the response line will include a corresponding error message and as well as the actual document content. @@ -1459,8 +1459,8 @@ paths: content: application/json: schema: - type: object description: Can be any key-value pair + type: object '404': description: The document or collection was not found content: @@ -1493,13 +1493,13 @@ paths: $ref: '#/components/schemas/DirtyValues' requestBody: description: The document object with fields to be updated + required: true content: application/json: schema: - type: object description: Can be any key-value pair + type: object x-go-type: interface{} - required: true x-rust-params-generic-parameter: B x-rust-type: B responses: @@ -1508,8 +1508,8 @@ paths: content: application/json: schema: - type: object description: Can be any key-value pair + type: object '404': description: The document or collection was not found content: @@ -1542,8 +1542,8 @@ paths: content: application/json: schema: - type: object description: Can be any key-value pair + type: object '404': description: The document or collection was not found content: @@ -1552,48 +1552,51 @@ paths: $ref: '#/components/schemas/ApiResponse' /conversations/models: get: + tags: + - conversations + summary: List all conversation models description: Retrieve all conversation models operationId: retrieveAllConversationModels responses: '200': + description: List of all conversation models content: application/json: schema: + type: array items: $ref: '#/components/schemas/ConversationModelSchema' - type: array x-go-type: '[]*ConversationModelSchema' - description: List of all conversation models - summary: List all conversation models + post: tags: - conversations - post: summary: Create a conversation model description: Create a Conversation Model operationId: createConversationModel requestBody: + required: true content: application/json: schema: $ref: '#/components/schemas/ConversationModelCreateSchema' - required: true responses: '201': + description: Created Conversation Model content: application/json: schema: $ref: '#/components/schemas/ConversationModelSchema' - description: Created Conversation Model '400': + description: Bad request, see error message for details content: application/json: schema: $ref: '#/components/schemas/ApiResponse' - description: Bad request, see error message for details - tags: - - conversations /conversations/models/{modelId}: get: + tags: + - conversations + summary: Retrieve a conversation model description: Retrieve a conversation model operationId: retrieveConversationModel parameters: @@ -1605,23 +1608,17 @@ paths: type: string responses: '200': + description: A conversation model content: application/json: schema: $ref: '#/components/schemas/ConversationModelSchema' - description: A conversation model - summary: Retrieve a conversation model + put: tags: - conversations - put: + summary: Update a conversation model description: Update a conversation model operationId: updateConversationModel - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ConversationModelUpdateSchema' - required: true parameters: - name: modelId in: path @@ -1629,17 +1626,23 @@ paths: required: true schema: type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ConversationModelUpdateSchema' responses: '200': + description: The conversation model was successfully updated content: application/json: schema: $ref: '#/components/schemas/ConversationModelSchema' - description: The conversation model was successfully updated - summary: Update a conversation model + delete: tags: - conversations - delete: + summary: Delete a conversation model description: Delete a conversation model operationId: deleteConversationModel parameters: @@ -1651,14 +1654,11 @@ paths: type: string responses: '200': + description: The conversation model was successfully deleted content: application/json: schema: $ref: '#/components/schemas/ConversationModelSchema' - description: The conversation model was successfully deleted - summary: Delete a conversation model - tags: - - conversations /keys: get: tags: @@ -1990,13 +1990,13 @@ paths: application/json: schema: type: object - properties: - log-slow-requests-time-ms: - type: integer required: - log-slow-requests-time-ms example: | {"log-slow-requests-time-ms": 2000} + properties: + log-slow-requests-time-ms: + type: integer responses: '200': description: Compacting the on-disk database succeeded. @@ -2006,11 +2006,11 @@ paths: $ref: '#/components/schemas/SuccessStatus' /multi_search: post: - operationId: multiSearch tags: - documents summary: send multiple search requests in a single HTTP request description: This is especially useful to avoid round-trip network latencies incurred otherwise if each of these requests are sent in separate HTTP requests. You can also use this feature to do a federated search across multiple collections in a single HTTP request. + operationId: multiSearch parameters: - name: q in: query @@ -2180,21 +2180,21 @@ paths: - name: enable_typos_for_alpha_numerical_tokens in: query schema: - type: boolean description: | Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. + type: boolean - name: filter_curated_hits in: query schema: - type: boolean description: | Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false + type: boolean - name: enable_synonyms in: query schema: - type: boolean description: | If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true + type: boolean - name: enable_analytics in: query schema: @@ -2205,15 +2205,15 @@ paths: - name: synonym_prefix in: query schema: - type: boolean description: | Allow synonym resolution on word prefixes in the query. Default: false + type: boolean - name: synonym_num_typos in: query schema: - type: integer description: | Allow synonym resolution on typo-corrected words in the query. Default: 0 + type: integer - name: pinned_hits in: query schema: @@ -2412,11 +2412,11 @@ paths: operationId: createAnalyticsEvent requestBody: description: The analytics event to be created + required: true content: application/json: schema: $ref: '#/components/schemas/AnalyticsEvent' - required: true responses: '200': description: Analytics event successfully created @@ -2504,6 +2504,7 @@ paths: operationId: createAnalyticsRule requestBody: description: The analytics rule(s) to be created + required: true content: application/json: schema: @@ -2512,7 +2513,6 @@ paths: - type: array items: $ref: '#/components/schemas/AnalyticsRuleCreate' - required: true responses: '200': description: Analytics rule(s) successfully created @@ -2542,12 +2542,12 @@ paths: description: Retrieve all analytics rules. Use the optional rule_tag filter to narrow down results. operationId: retrieveAnalyticsRules parameters: - - in: query - name: rule_tag + - name: rule_tag + in: query + description: Filter rules by rule_tag + required: false schema: type: string - required: false - description: Filter rules by rule_tag responses: '200': description: Analytics rules fetched @@ -2565,19 +2565,19 @@ paths: description: Upserts an analytics rule with the given name. operationId: upsertAnalyticsRule parameters: - - in: path - name: ruleName + - name: ruleName + in: path description: The name of the analytics rule to upsert + required: true schema: type: string - required: true requestBody: description: The Analytics rule to be upserted + required: true content: application/json: schema: $ref: '#/components/schemas/AnalyticsRuleUpdate' - required: true responses: '200': description: Analytics rule successfully upserted @@ -2598,12 +2598,12 @@ paths: description: Retrieve the details of an analytics rule, given it's name operationId: retrieveAnalyticsRule parameters: - - in: path - name: ruleName + - name: ruleName + in: path description: The name of the analytics rule to retrieve + required: true schema: type: string - required: true responses: '200': description: Analytics rule fetched @@ -2624,12 +2624,12 @@ paths: description: Permanently deletes an analytics rule, given it's name operationId: deleteAnalyticsRule parameters: - - in: path - name: ruleName + - name: ruleName + in: path description: The name of the analytics rule to delete + required: true schema: type: string - required: true responses: '200': description: Analytics rule deleted @@ -2693,20 +2693,20 @@ paths: description: When an analytics rule is created, we give it a name and describe the type, the source collections and the destination collection. operationId: upsertStopwordsSet parameters: - - in: path - name: setId + - name: setId + in: path description: The ID of the stopwords set to upsert. + required: true schema: type: string - required: true example: countries requestBody: description: The stopwords set to upsert. + required: true content: application/json: schema: $ref: '#/components/schemas/StopwordsSetUpsertSchema' - required: true responses: '200': description: Stopwords set successfully upserted. @@ -2727,12 +2727,12 @@ paths: description: Retrieve the details of a stopwords set, given it's name. operationId: retrieveStopwordsSet parameters: - - in: path - name: setId + - name: setId + in: path description: The ID of the stopwords set to retrieve. + required: true schema: type: string - required: true example: countries responses: '200': @@ -2754,12 +2754,12 @@ paths: description: Permanently deletes a stopwords set, given it's name. operationId: deleteStopwordsSet parameters: - - in: path - name: setId + - name: setId + in: path description: The ID of the stopwords set to delete. + required: true schema: type: string - required: true example: countries responses: '200': @@ -2768,13 +2768,13 @@ paths: application/json: schema: type: object - properties: - id: - type: string required: - id example: | {"id": "countries"} + properties: + id: + type: string '404': description: Stopwords set not found. content: @@ -2803,12 +2803,12 @@ paths: description: Retrieve the details of a preset, given it's name. operationId: retrievePreset parameters: - - in: path - name: presetId + - name: presetId + in: path description: The ID of the preset to retrieve. + required: true schema: type: string - required: true example: listing_view responses: '200': @@ -2830,20 +2830,20 @@ paths: description: Create or update an existing preset. operationId: upsertPreset parameters: - - in: path - name: presetId + - name: presetId + in: path description: The name of the preset set to upsert. + required: true schema: type: string - required: true example: listing_view requestBody: description: The stopwords set to upsert. + required: true content: application/json: schema: $ref: '#/components/schemas/PresetUpsertSchema' - required: true responses: '200': description: Preset successfully upserted. @@ -2864,12 +2864,12 @@ paths: description: Permanently deletes a preset, given it's name. operationId: deletePreset parameters: - - in: path - name: presetId + - name: presetId + in: path description: The ID of the preset to delete. + required: true schema: type: string - required: true example: listing_view responses: '200': @@ -2901,11 +2901,11 @@ paths: properties: dictionaries: type: array - items: - type: string example: - irregular-plurals - company-terms + items: + type: string /stemming/dictionaries/{dictionaryId}: get: tags: @@ -3000,11 +3000,11 @@ paths: operationId: createNLSearchModel requestBody: description: The NL search model to be created + required: true content: application/json: schema: $ref: '#/components/schemas/NLSearchModelCreateSchema' - required: true responses: '201': description: NL search model successfully created @@ -3060,11 +3060,11 @@ paths: type: string requestBody: description: The NL search model fields to update + required: true content: application/json: schema: $ref: '#/components/schemas/NLSearchModelUpdateSchema' - required: true responses: '200': description: NL search model successfully updated @@ -3113,18 +3113,18 @@ paths: components: schemas: CollectionSchema: + type: object required: - name - fields - type: object properties: name: - type: string description: Name of the collection + type: string example: companies fields: - type: array description: A list of fields for querying, filtering and faceting + type: array example: - name: num_employees type: int32 @@ -3138,34 +3138,34 @@ components: items: $ref: '#/components/schemas/Field' default_sorting_field: - type: string description: The name of an int32 / float field that determines the order in which the search results are ranked when a sort_by clause is not provided during searching. This field must indicate some kind of popularity. + type: string example: num_employees default: '' token_separators: - type: array description: | List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters. + type: array items: type: string minLength: 1 maxLength: 1 default: [] synonym_sets: - type: array description: List of synonym set names to associate with this collection + type: array items: type: string example: synonym_set_1 enable_nested_fields: - type: boolean description: Enables experimental support at a collection level for nested object or object array fields. This field is only available if the Typesense server is version `0.24.0.rcn34` or later. - default: false + type: boolean example: true + default: false symbols_to_index: - type: array description: | List of symbols or special characters to be indexed. + type: array items: type: string minLength: 1 @@ -3174,18 +3174,18 @@ components: voice_query_model: $ref: '#/components/schemas/VoiceQueryModelCollectionConfig' metadata: - type: object description: | Optional details about the collection, e.g., when it was created, who created it etc. + type: object x-rust-builder: true CollectionUpdateSchema: + type: object required: - fields - type: object properties: fields: - type: array description: A list of fields for querying, filtering and faceting + type: array example: - name: company_name type: string @@ -3199,15 +3199,15 @@ components: items: $ref: '#/components/schemas/Field' synonym_sets: - type: array description: List of synonym set names to associate with this collection + type: array items: type: string example: synonym_set_1 metadata: - type: object description: | Optional details about the collection, e.g., when it was created, who created it etc. + type: object CollectionResponse: allOf: - $ref: '#/components/schemas/CollectionSchema' @@ -3228,10 +3228,10 @@ components: readOnly: true x-rust-is-owned-data: true Field: + type: object required: - name - type - type: object properties: name: type: string @@ -3260,9 +3260,9 @@ components: example: true default: false reference: - type: string description: | Name of a field in another collection that should be linked to this collection so that it can be joined during query. + type: string num_dim: type: integer example: 256 @@ -3270,38 +3270,38 @@ components: type: boolean example: true store: - type: boolean description: | When set to false, the field value will not be stored on disk. Default: true. + type: boolean vec_dist: - type: string description: | The distance metric to be used for vector search. Default: `cosine`. You can also use `ip` for inner product. + type: string range_index: - type: boolean description: | Enables an index optimized for range filtering on numerical fields (e.g. rating:>3.5). Default: false. - stem: type: boolean + stem: description: | Values are stemmed before indexing in-memory. Default: false. + type: boolean stem_dictionary: - type: string description: Name of the stemming dictionary to use for this field + type: string example: irregular-plurals token_separators: - type: array description: | List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters. + type: array items: type: string minLength: 1 maxLength: 1 default: [] symbols_to_index: - type: array description: | List of symbols or special characters to be indexed. + type: array items: type: string minLength: 1 @@ -3342,23 +3342,26 @@ components: type: string query_prefix: type: string + x-rust-is-owned-data: true x-rust-builder: true + x-rust-is-owned-data: true VoiceQueryModelCollectionConfig: - type: object description: | Configuration for the voice query model + type: object properties: model_name: type: string example: ts/whisper/base.en + x-rust-is-owned-data: true CollectionAliasSchema: type: object required: - collection_name properties: collection_name: - type: string description: Name of the collection you wish to map the alias to + type: string CollectionAlias: type: object required: @@ -3366,12 +3369,13 @@ components: - name properties: name: + description: Name of the collection alias type: string readOnly: true - description: Name of the collection alias collection_name: - type: string description: Name of the collection the alias mapped to + type: string + x-rust-is-owned-data: true CollectionAliasesResponse: type: object required: @@ -3379,9 +3383,9 @@ components: properties: aliases: type: array - x-go-type: '[]*CollectionAlias' items: $ref: '#/components/schemas/CollectionAlias' + x-go-type: '[]*CollectionAlias' x-rust-is-owned-data: true SearchResult: type: object @@ -3391,30 +3395,30 @@ components: items: $ref: '#/components/schemas/FacetCounts' found: - type: integer description: The number of documents found + type: integer found_docs: type: integer search_time_ms: - type: integer description: The number of milliseconds the search took - out_of: type: integer + out_of: description: The total number of documents in the collection + type: integer search_cutoff: - type: boolean description: Whether the search was cut off + type: boolean page: - type: integer description: The search result page number + type: integer grouped_hits: type: array items: $ref: '#/components/schemas/SearchGroupedHit' x-rust-type: Option>> hits: - type: array description: The documents that matched the search query + type: array items: $ref: '#/components/schemas/SearchResultHit' x-rust-type: Option>> @@ -3423,13 +3427,13 @@ components: conversation: $ref: '#/components/schemas/SearchResultConversation' union_request_params: - type: array description: Returned only for union query response. + type: array items: $ref: '#/components/schemas/SearchRequestParams' metadata: - type: object description: Custom JSON object that can be returned in the search response + type: object additionalProperties: true x-rust-is-owned-data: true x-rust-generic-parameter: D @@ -3468,6 +3472,7 @@ components: type: array items: type: object + x-rust-is-owned-data: true conversation_id: type: string query: @@ -3485,8 +3490,8 @@ components: type: array items: {} hits: - type: array description: The documents that matched the search query + type: array items: $ref: '#/components/schemas/SearchResultHit' x-rust-type: Vec> @@ -3494,20 +3499,31 @@ components: x-rust-is-owned-data: true SearchResultHit: type: object + example: + highlights: + company_name: + field: company_name + snippet: Stark Industries + document: + id: '124' + company_name: Stark Industries + num_employees: 5215 + country: USA + text_match: 1234556 properties: highlights: - type: array description: (Deprecated) Contains highlighted portions of the search fields + type: array items: $ref: '#/components/schemas/SearchHighlight' highlight: - type: object description: Highlighted version of the matching document + type: object additionalProperties: true x-rust-is-owned-data: true document: - type: object description: Can be any key-value pair + type: object additionalProperties: type: object x-rust-type: Option @@ -3536,38 +3552,27 @@ components: type: integer x-rust-is-owned-data: true geo_distance_meters: - type: object description: Can be any key-value pair + type: object additionalProperties: type: integer x-rust-is-owned-data: true vector_distance: + description: Distance between the query vector and matching document's vector value type: number format: float - description: Distance between the query vector and matching document's vector value hybrid_search_info: - type: object description: Information about hybrid search scoring + type: object properties: rank_fusion_score: + description: Combined score from rank fusion of text and vector search type: number format: float - description: Combined score from rank fusion of text and vector search x-rust-is-owned-data: true search_index: - type: integer description: Returned only for union query response. Indicates the index of the query which this document matched to. - example: - highlights: - company_name: - field: company_name - snippet: Stark Industries - document: - id: '124' - company_name: Stark Industries - num_employees: 5215 - country: USA - text_match: 1234556 + type: integer x-rust-generic-parameter: D x-rust-is-owned-data: true SearchHighlight: @@ -3577,32 +3582,32 @@ components: type: string example: company_name snippet: - type: string description: Present only for (non-array) string fields + type: string example: Stark Industries snippets: - type: array description: Present only for (array) string[] fields + type: array example: - Stark Industries - Stark Corp items: type: string value: - type: string description: Full field value with highlighting, present only for (non-array) string fields + type: string example: Stark Industries is a major supplier of space equipment. values: - type: array description: Full field value with highlighting, present only for (array) string[] fields + type: array example: - Stark Industries - Stark Corp items: type: string indices: - type: array description: The indices property will be present only for string[] fields and will contain the corresponding indices of the snippets in the search field + type: array example: 1 items: type: integer @@ -3611,6 +3616,7 @@ components: items: type: object x-go-type: interface{} + x-rust-is-owned-data: true x-rust-is-owned-data: true SearchSynonymSchema: type: object @@ -3618,21 +3624,22 @@ components: - synonyms properties: root: - type: string description: For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. + type: string synonyms: - type: array description: Array of words that should be considered as synonyms. + type: array items: type: string locale: - type: string description: Locale for the synonym, leave blank to use the standard tokenizer. + type: string symbols_to_index: - type: array description: By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is. + type: array items: type: string + x-rust-is-owned-data: true SearchSynonym: allOf: - $ref: '#/components/schemas/SearchSynonymSchema' @@ -3643,14 +3650,15 @@ components: id: type: string readOnly: true + x-rust-is-owned-data: true SearchSynonymDeleteResponse: type: object required: - id properties: id: - type: string description: The id of the synonym that was deleted + type: string x-rust-is-owned-data: true SearchSynonymsResponse: type: object @@ -3659,9 +3667,9 @@ components: properties: synonyms: type: array - x-go-type: '[]*SearchSynonym' items: $ref: '#/components/schemas/SearchSynonym' + x-go-type: '[]*SearchSynonym' x-rust-is-owned-data: true HealthStatus: type: object @@ -3675,14 +3683,14 @@ components: type: object properties: collection: - type: string description: Name of the collection being modified + type: string validated_docs: - type: integer description: Number of documents that have been validated - altered_docs: type: integer + altered_docs: description: Number of documents that have been altered + type: integer x-rust-is-owned-data: true SuccessStatus: type: object @@ -3734,15 +3742,16 @@ components: value_prefix: type: string readOnly: true + x-rust-is-owned-data: true ApiKeyDeleteResponse: type: object required: - id properties: id: + description: The id of the API key that was deleted type: integer format: int64 - description: The id of the API key that was deleted x-rust-is-owned-data: true ApiKeysResponse: type: object @@ -3751,9 +3760,9 @@ components: properties: keys: type: array - x-go-type: '[]*ApiKey' items: $ref: '#/components/schemas/ApiKey' + x-go-type: '[]*ApiKey' x-rust-is-owned-data: true MultiSearchResult: type: object @@ -3900,8 +3909,8 @@ components: Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 type: integer synonym_sets: - type: string description: List of synonym set names to associate with this search query + type: string example: synonym_set_1,synonym_set_2 drop_tokens_threshold: description: | @@ -3914,25 +3923,25 @@ components: If the number of results found for a specific query is less than this number, Typesense will attempt to look for tokens with more typos until enough results are found. Default: 100 type: integer enable_typos_for_alpha_numerical_tokens: - type: boolean description: | Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. - filter_curated_hits: type: boolean + filter_curated_hits: description: | Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false - enable_synonyms: type: boolean + enable_synonyms: description: | If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true - synonym_prefix: type: boolean + synonym_prefix: description: | Allow synonym resolution on word prefixes in the query. Default: false + type: boolean synonym_num_typos: - type: integer description: | Allow synonym resolution on typo-corrected words in the query. Default: 0 + type: integer pinned_hits: description: | A list of records to unconditionally include in the search results at specific positions. An example use case would be to feature or promote certain items on the top of search results. A list of `record_id:hit_position`. Eg: to include a record with ID 123 at Position 1 and another record with ID 456 at Position 5, you'd specify `123:1,456:5`. @@ -4166,30 +4175,30 @@ components: If the number of results found for a specific query is less than this number, Typesense will attempt to look for tokens with more typos until enough results are found. Default: 100 type: integer enable_typos_for_alpha_numerical_tokens: - type: boolean description: | Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. - filter_curated_hits: type: boolean + filter_curated_hits: description: | Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false - enable_synonyms: type: boolean + enable_synonyms: description: | If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true + type: boolean enable_analytics: description: | Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). type: boolean default: true synonym_prefix: - type: boolean description: | Allow synonym resolution on word prefixes in the query. Default: false + type: boolean synonym_num_typos: - type: integer description: | Allow synonym resolution on typo-corrected words in the query. Default: 0 + type: integer pinned_hits: description: | A list of records to unconditionally include in the search results at specific positions. An example use case would be to feature or promote certain items on the top of search results. A list of `record_id:hit_position`. Eg: to include a record with ID 123 at Position 1 and another record with ID 456 at Position 5, you'd specify `123:1,456:5`. @@ -4313,9 +4322,9 @@ components: - searches properties: union: + description: When true, merges the search results from each search query into a single ordered set of hits. type: boolean default: false - description: When true, merges the search results from each search query into a single ordered set of hits. searches: type: array items: @@ -4354,6 +4363,7 @@ components: type: string parent: type: object + x-rust-is-owned-data: true field_name: type: string stats: @@ -4373,6 +4383,8 @@ components: avg: type: number format: double + x-rust-is-owned-data: true + x-rust-is-owned-data: true AnalyticsEventCreateResponse: type: object required: @@ -4389,14 +4401,14 @@ components: - data properties: name: - type: string description: Name of the analytics rule this event corresponds to - event_type: type: string + event_type: description: Type of event (e.g., click, conversion, query, visit) + type: string data: - type: object description: Event payload + type: object properties: user_id: type: string @@ -4439,6 +4451,7 @@ components: type: string query: type: string + x-rust-is-owned-data: true x-rust-is-owned-data: true AnalyticsRuleCreate: type: object @@ -4483,8 +4496,8 @@ components: weight: type: integer AnalyticsRuleUpdate: - type: object description: Fields allowed to update on an analytics rule + type: object properties: name: type: string @@ -4513,6 +4526,7 @@ components: allOf: - $ref: '#/components/schemas/AnalyticsRuleCreate' - type: object + x-rust-is-owned-data: true AnalyticsStatus: type: object properties: @@ -4578,6 +4592,10 @@ components: x-rust-is-owned-data: true StopwordsSetUpsertSchema: type: object + required: + - stopwords + example: | + {"stopwords": ["Germany", "France", "Italy"], "locale": "en"} properties: stopwords: type: array @@ -4585,12 +4603,13 @@ components: type: string locale: type: string + StopwordsSetSchema: + type: object required: + - id - stopwords example: | - {"stopwords": ["Germany", "France", "Italy"], "locale": "en"} - StopwordsSetSchema: - type: object + {"id": "countries", "stopwords": ["Germany", "France", "Italy"], "locale": "en"} properties: id: type: string @@ -4600,39 +4619,37 @@ components: type: string locale: type: string + x-rust-is-owned-data: true + StopwordsSetRetrieveSchema: + type: object required: - - id - stopwords example: | - {"id": "countries", "stopwords": ["Germany", "France", "Italy"], "locale": "en"} - StopwordsSetRetrieveSchema: - type: object + {"stopwords": {"id": "countries", "stopwords": ["Germany", "France", "Italy"], "locale": "en"}} properties: stopwords: $ref: '#/components/schemas/StopwordsSetSchema' + x-rust-is-owned-data: true + StopwordsSetsRetrieveAllSchema: + type: object required: - stopwords example: | - {"stopwords": {"id": "countries", "stopwords": ["Germany", "France", "Italy"], "locale": "en"}} - StopwordsSetsRetrieveAllSchema: - type: object + {"stopwords": [{"id": "countries", "stopwords": ["Germany", "France", "Italy"], "locale": "en"}]} properties: stopwords: type: array items: $ref: '#/components/schemas/StopwordsSetSchema' - required: - - stopwords - example: | - {"stopwords": [{"id": "countries", "stopwords": ["Germany", "France", "Italy"], "locale": "en"}]} + x-rust-is-owned-data: true PresetUpsertSchema: + required: + - value properties: value: oneOf: - $ref: '#/components/schemas/SearchParameters' - $ref: '#/components/schemas/MultiSearchSearchesParameter' - required: - - value PresetSchema: allOf: - $ref: '#/components/schemas/PresetUpsertSchema' @@ -4642,6 +4659,7 @@ components: properties: name: type: string + x-rust-is-owned-data: true PresetsRetrieveSchema: type: object required: @@ -4652,6 +4670,7 @@ components: items: $ref: '#/components/schemas/PresetSchema' x-go-type: '[]*PresetSchema' + x-rust-is-owned-data: true PresetDeleteSchema: type: object required: @@ -4659,6 +4678,7 @@ components: properties: name: type: string + x-rust-is-owned-data: true DirtyValues: type: string enum: @@ -4674,13 +4694,13 @@ components: - upsert - emplace DropTokensMode: + description: | + Dictates the direction in which the words in the query must be dropped when the original words in the query do not appear in any document. Values: right_to_left (default), left_to_right, both_sides:3 A note on both_sides:3 - for queries up to 3 tokens (words) in length, this mode will drop tokens from both sides and exhaustively rank all matching results. If query length is greater than 3 words, Typesense will just fallback to default behavior of right_to_left type: string enum: - right_to_left - left_to_right - both_sides:3 - description: | - Dictates the direction in which the words in the query must be dropped when the original words in the query do not appear in any document. Values: right_to_left (default), left_to_right, both_sides:3 A note on both_sides:3 - for queries up to 3 tokens (words) in length, this mode will drop tokens from both sides and exhaustively rank all matching results. If query length is greater than 3 words, Typesense will just fallback to default behavior of right_to_left ConversationModelCreateSchema: required: - model_name @@ -4707,8 +4727,8 @@ components: type: object properties: id: - type: string description: An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. + type: string model_name: description: Name of the LLM model offered by OpenAI, Cloudflare or vLLM type: string @@ -4716,8 +4736,8 @@ components: description: The LLM service's API Key type: string history_collection: - type: string description: Typesense collection that stores the historical conversations + type: string account_id: description: LLM service's account ID (only applicable for Cloudflare) type: string @@ -4725,9 +4745,9 @@ components: description: The system prompt that contains special instructions to the LLM type: string ttl: - type: integer description: | Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) + type: integer max_bytes: description: | The maximum number of bytes to send to the LLM in every API call. Consult the LLM's documentation on the number of bytes supported in the context window. @@ -4745,6 +4765,7 @@ components: id: type: string description: An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. + x-rust-is-owned-data: true StemmingDictionary: type: object required: @@ -4752,12 +4773,12 @@ components: - words properties: id: - type: string description: Unique identifier for the dictionary + type: string example: irregular-plurals words: - type: array description: List of word mappings in the dictionary + type: array items: type: object required: @@ -4765,72 +4786,75 @@ components: - root properties: word: - type: string description: The word form to be stemmed + type: string example: people root: - type: string description: The root form of the word + type: string example: person + x-rust-is-owned-data: true + x-rust-is-owned-data: true NLSearchModelBase: type: object properties: model_name: - type: string description: Name of the NL model to use - api_key: type: string + api_key: description: API key for the NL model service - api_url: type: string + api_url: description: Custom API URL for the NL model service + type: string max_bytes: - type: integer description: Maximum number of bytes to process + type: integer temperature: - type: number description: Temperature parameter for the NL model + type: number system_prompt: - type: string description: System prompt for the NL model + type: string top_p: - type: number description: Top-p parameter for the NL model (Google-specific) + type: number top_k: - type: integer description: Top-k parameter for the NL model (Google-specific) + type: integer stop_sequences: + description: Stop sequences for the NL model (Google-specific) type: array items: type: string - description: Stop sequences for the NL model (Google-specific) api_version: - type: string description: API version for the NL model service - project_id: type: string + project_id: description: Project ID for GCP Vertex AI - access_token: type: string + access_token: description: Access token for GCP Vertex AI - refresh_token: type: string + refresh_token: description: Refresh token for GCP Vertex AI - client_id: type: string + client_id: description: Client ID for GCP Vertex AI - client_secret: type: string + client_secret: description: Client secret for GCP Vertex AI - region: type: string + region: description: Region for GCP Vertex AI + type: string max_output_tokens: - type: integer description: Maximum output tokens for GCP Vertex AI + type: integer account_id: - type: string description: Account ID for Cloudflare-specific models + type: string + x-rust-is-owned-data: true NLSearchModelCreateSchema: allOf: - $ref: '#/components/schemas/NLSearchModelBase' @@ -4849,6 +4873,7 @@ components: id: type: string description: ID of the NL search model + x-rust-is-owned-data: true NLSearchModelUpdateSchema: $ref: '#/components/schemas/NLSearchModelCreateSchema' NLSearchModelDeleteSchema: @@ -4857,8 +4882,9 @@ components: - id properties: id: - type: string description: ID of the deleted NL search model + type: string + x-rust-is-owned-data: true SynonymItemSchema: type: object required: @@ -4866,22 +4892,22 @@ components: - synonyms properties: id: - type: string description: Unique identifier for the synonym item + type: string synonyms: - type: array description: Array of words that should be considered as synonyms + type: array items: type: string root: - type: string description: For 1-way synonyms, indicates the root word that words in the synonyms parameter map to - locale: type: string + locale: description: Locale for the synonym, leave blank to use the standard tokenizer + type: string symbols_to_index: - type: array description: By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is + type: array items: type: string SynonymSetCreateSchema: @@ -4890,8 +4916,8 @@ components: - items properties: items: - type: array description: Array of synonym items + type: array items: $ref: '#/components/schemas/SynonymItemSchema' SynonymSetSchema: @@ -4904,34 +4930,39 @@ components: name: type: string description: Name of the synonym set + x-rust-is-owned-data: true SynonymSetsRetrieveSchema: type: object required: - synonym_sets properties: synonym_sets: - type: array description: Array of synonym sets + type: array items: $ref: '#/components/schemas/SynonymSetSchema' + x-rust-is-owned-data: true SynonymSetRetrieveSchema: $ref: '#/components/schemas/SynonymSetCreateSchema' + x-rust-is-owned-data: true SynonymSetDeleteSchema: type: object required: - name properties: name: - type: string description: Name of the deleted synonym set + type: string + x-rust-is-owned-data: true SynonymItemDeleteSchema: type: object required: - id properties: id: - type: string description: ID of the deleted synonym item + type: string + x-rust-is-owned-data: true CurationItemCreateSchema: type: object required: @@ -4940,54 +4971,54 @@ components: rule: $ref: '#/components/schemas/CurationRule' includes: - type: array description: List of document `id`s that should be included in the search results with their corresponding `position`s. + type: array items: $ref: '#/components/schemas/CurationInclude' excludes: - type: array description: List of document `id`s that should be excluded from the search results. + type: array items: $ref: '#/components/schemas/CurationExclude' filter_by: - type: string description: | A filter by clause that is applied to any search query that matches the curation rule. + type: string remove_matched_tokens: - type: boolean description: | Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. + type: boolean metadata: - type: object description: | Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered. + type: object sort_by: - type: string description: | A sort by clause that is applied to any search query that matches the curation rule. - replace_query: type: string + replace_query: description: | Replaces the current search query with this value, when the search query matches the curation rule. + type: string filter_curated_hits: - type: boolean description: | When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. + type: boolean effective_from_ts: - type: integer description: | A Unix timestamp that indicates the date/time from which the curation will be active. You can use this to create rules that start applying from a future point in time. - effective_to_ts: type: integer + effective_to_ts: description: | A Unix timestamp that indicates the date/time until which the curation will be active. You can use this to create rules that stop applying after a period of time. + type: integer stop_processing: - type: boolean description: | When set to true, curation processing will stop at the first matching rule. When set to false curation processing will continue and multiple curation actions will be triggered in sequence. Curations are processed in the lexical sort order of their id field. + type: boolean id: - type: string description: ID of the curation item + type: string CurationItemSchema: allOf: - $ref: '#/components/schemas/CurationItemCreateSchema' @@ -4997,19 +5028,20 @@ components: properties: id: type: string + x-rust-is-owned-data: true CurationSetCreateSchema: type: object required: - items properties: items: - type: array description: Array of curation items + type: array items: $ref: '#/components/schemas/CurationItemCreateSchema' description: - type: string description: Optional description for the curation set + type: string CurationSetSchema: allOf: - $ref: '#/components/schemas/CurationSetCreateSchema' @@ -5019,28 +5051,30 @@ components: properties: name: type: string + x-rust-is-owned-data: true CurationRule: type: object properties: tags: - type: array description: List of tag values to associate with this curation rule. + type: array items: type: string query: - type: string description: Indicates what search queries should be curated - match: type: string + match: description: | Indicates whether the match on the query term should be `exact` or `contains`. If we want to match all queries that contained the word `apple`, we will use the `contains` match instead. + type: string enum: - exact - contains filter_by: - type: string description: | Indicates that the curation should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc). + type: string + x-rust-is-owned-data: true CurationInclude: type: object required: @@ -5048,45 +5082,50 @@ components: - position properties: id: - type: string description: document id that should be included + type: string position: - type: integer description: position number where document should be included in the search results + type: integer + x-rust-is-owned-data: true CurationExclude: type: object required: - id properties: id: - type: string description: document id that should be excluded from the search results. + type: string + x-rust-is-owned-data: true CurationSetRetrieveSchema: $ref: '#/components/schemas/CurationSetCreateSchema' + x-rust-is-owned-data: true CurationSetDeleteSchema: type: object required: - name properties: name: - type: string description: Name of the deleted curation set + type: string + x-rust-is-owned-data: true CurationItemDeleteSchema: type: object required: - id properties: id: - type: string description: ID of the deleted curation item + type: string + x-rust-is-owned-data: true ImportDocumentsParameters: type: object properties: batch_size: type: integer return_id: - type: boolean description: Returning the id of the imported documents. If you want the import response to return the ingested document's id in the response, you can use the return_id parameter. + type: boolean remote_embedding_batch_size: type: integer return_doc: diff --git a/typesense_codegen/src/models/analytics_events_response_events_inner.rs b/typesense_codegen/src/models/analytics_events_response_events_inner.rs index 042edea0..42dd55cf 100644 --- a/typesense_codegen/src/models/analytics_events_response_events_inner.rs +++ b/typesense_codegen/src/models/analytics_events_response_events_inner.rs @@ -15,21 +15,21 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct AnalyticsEventsResponseEventsInner<'a> { #[serde(rename = "name", skip_serializing_if = "Option::is_none")] - pub name: Option>, + pub name: Option, #[serde(rename = "event_type", skip_serializing_if = "Option::is_none")] - pub event_type: Option>, + pub event_type: Option, #[serde(rename = "collection", skip_serializing_if = "Option::is_none")] - pub collection: Option>, + pub collection: Option, #[serde(rename = "timestamp", skip_serializing_if = "Option::is_none")] pub timestamp: Option, #[serde(rename = "user_id", skip_serializing_if = "Option::is_none")] - pub user_id: Option>, + pub user_id: Option, #[serde(rename = "doc_id", skip_serializing_if = "Option::is_none")] - pub doc_id: Option>, + pub doc_id: Option, #[serde(rename = "doc_ids", skip_serializing_if = "Option::is_none")] pub doc_ids: Option>, #[serde(rename = "query", skip_serializing_if = "Option::is_none")] - pub query: Option>, + pub query: Option, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } diff --git a/typesense_codegen/src/models/analytics_rule.rs b/typesense_codegen/src/models/analytics_rule.rs index 809e8fda..dc1bbd82 100644 --- a/typesense_codegen/src/models/analytics_rule.rs +++ b/typesense_codegen/src/models/analytics_rule.rs @@ -15,15 +15,15 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct AnalyticsRule<'a> { #[serde(rename = "name")] - pub name: Cow<'a, str>, + pub name: String, #[serde(rename = "type")] pub r#type: Type, #[serde(rename = "collection")] - pub collection: Cow<'a, str>, + pub collection: String, #[serde(rename = "event_type")] - pub event_type: Cow<'a, str>, + pub event_type: String, #[serde(rename = "rule_tag", skip_serializing_if = "Option::is_none")] - pub rule_tag: Option>, + pub rule_tag: Option, #[serde(rename = "params", skip_serializing_if = "Option::is_none")] pub params: Option>>, #[serde(skip)] @@ -31,12 +31,7 @@ pub struct AnalyticsRule<'a> { } impl<'a> AnalyticsRule<'a> { - pub fn new( - name: Cow<'a, str>, - r#type: Type, - collection: Cow<'a, str>, - event_type: Cow<'a, str>, - ) -> Self { + pub fn new(name: String, r#type: Type, collection: String, event_type: String) -> Self { Self { name, r#type, diff --git a/typesense_codegen/src/models/api_key.rs b/typesense_codegen/src/models/api_key.rs index ffe460bc..6b570c0e 100644 --- a/typesense_codegen/src/models/api_key.rs +++ b/typesense_codegen/src/models/api_key.rs @@ -15,9 +15,9 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ApiKey<'a> { #[serde(rename = "value", skip_serializing_if = "Option::is_none")] - pub value: Option>, + pub value: Option, #[serde(rename = "description")] - pub description: Cow<'a, str>, + pub description: String, #[serde(rename = "actions")] pub actions: Vec, #[serde(rename = "collections")] @@ -27,13 +27,13 @@ pub struct ApiKey<'a> { #[serde(rename = "id", skip_serializing_if = "Option::is_none")] pub id: Option, #[serde(rename = "value_prefix", skip_serializing_if = "Option::is_none")] - pub value_prefix: Option>, + pub value_prefix: Option, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> ApiKey<'a> { - pub fn new(description: Cow<'a, str>, actions: Vec, collections: Vec) -> Self { + pub fn new(description: String, actions: Vec, collections: Vec) -> Self { Self { value: None, description, diff --git a/typesense_codegen/src/models/collection_alias.rs b/typesense_codegen/src/models/collection_alias.rs index 957a6076..b1dab9b9 100644 --- a/typesense_codegen/src/models/collection_alias.rs +++ b/typesense_codegen/src/models/collection_alias.rs @@ -16,16 +16,16 @@ use serde::{Deserialize, Serialize}; pub struct CollectionAlias<'a> { /// Name of the collection alias #[serde(rename = "name")] - pub name: Cow<'a, str>, + pub name: String, /// Name of the collection the alias mapped to #[serde(rename = "collection_name")] - pub collection_name: Cow<'a, str>, + pub collection_name: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> CollectionAlias<'a> { - pub fn new(name: Cow<'a, str>, collection_name: Cow<'a, str>) -> Self { + pub fn new(name: String, collection_name: String) -> Self { Self { name, collection_name, diff --git a/typesense_codegen/src/models/conversation_model_schema.rs b/typesense_codegen/src/models/conversation_model_schema.rs index dd0cd164..b872e67d 100644 --- a/typesense_codegen/src/models/conversation_model_schema.rs +++ b/typesense_codegen/src/models/conversation_model_schema.rs @@ -16,22 +16,22 @@ use serde::{Deserialize, Serialize}; pub struct ConversationModelSchema<'a> { /// An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. #[serde(rename = "id")] - pub id: Cow<'a, str>, + pub id: String, /// Name of the LLM model offered by OpenAI, Cloudflare or vLLM #[serde(rename = "model_name")] - pub model_name: Cow<'a, str>, + pub model_name: String, /// The LLM service's API Key #[serde(rename = "api_key", skip_serializing_if = "Option::is_none")] - pub api_key: Option>, + pub api_key: Option, /// Typesense collection that stores the historical conversations #[serde(rename = "history_collection")] - pub history_collection: Cow<'a, str>, + pub history_collection: String, /// LLM service's account ID (only applicable for Cloudflare) #[serde(rename = "account_id", skip_serializing_if = "Option::is_none")] - pub account_id: Option>, + pub account_id: Option, /// The system prompt that contains special instructions to the LLM #[serde(rename = "system_prompt", skip_serializing_if = "Option::is_none")] - pub system_prompt: Option>, + pub system_prompt: Option, /// Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) #[serde(rename = "ttl", skip_serializing_if = "Option::is_none")] pub ttl: Option, @@ -40,18 +40,13 @@ pub struct ConversationModelSchema<'a> { pub max_bytes: i32, /// URL of vLLM service #[serde(rename = "vllm_url", skip_serializing_if = "Option::is_none")] - pub vllm_url: Option>, + pub vllm_url: Option, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> ConversationModelSchema<'a> { - pub fn new( - id: Cow<'a, str>, - model_name: Cow<'a, str>, - history_collection: Cow<'a, str>, - max_bytes: i32, - ) -> Self { + pub fn new(id: String, model_name: String, history_collection: String, max_bytes: i32) -> Self { Self { id, model_name, diff --git a/typesense_codegen/src/models/curation_exclude.rs b/typesense_codegen/src/models/curation_exclude.rs index 8941518d..fa306ac8 100644 --- a/typesense_codegen/src/models/curation_exclude.rs +++ b/typesense_codegen/src/models/curation_exclude.rs @@ -16,13 +16,13 @@ use serde::{Deserialize, Serialize}; pub struct CurationExclude<'a> { /// document id that should be excluded from the search results. #[serde(rename = "id")] - pub id: Cow<'a, str>, + pub id: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> CurationExclude<'a> { - pub fn new(id: Cow<'a, str>) -> Self { + pub fn new(id: String) -> Self { Self { id, _phantom: PhantomData, diff --git a/typesense_codegen/src/models/curation_include.rs b/typesense_codegen/src/models/curation_include.rs index 8ba943f5..f1970455 100644 --- a/typesense_codegen/src/models/curation_include.rs +++ b/typesense_codegen/src/models/curation_include.rs @@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize}; pub struct CurationInclude<'a> { /// document id that should be included #[serde(rename = "id")] - pub id: Cow<'a, str>, + pub id: String, /// position number where document should be included in the search results #[serde(rename = "position")] pub position: i32, @@ -25,7 +25,7 @@ pub struct CurationInclude<'a> { } impl<'a> CurationInclude<'a> { - pub fn new(id: Cow<'a, str>, position: i32) -> Self { + pub fn new(id: String, position: i32) -> Self { Self { id, position, diff --git a/typesense_codegen/src/models/curation_item_delete_schema.rs b/typesense_codegen/src/models/curation_item_delete_schema.rs index ad1abd08..201c5ebe 100644 --- a/typesense_codegen/src/models/curation_item_delete_schema.rs +++ b/typesense_codegen/src/models/curation_item_delete_schema.rs @@ -16,13 +16,13 @@ use serde::{Deserialize, Serialize}; pub struct CurationItemDeleteSchema<'a> { /// ID of the deleted curation item #[serde(rename = "id")] - pub id: Cow<'a, str>, + pub id: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> CurationItemDeleteSchema<'a> { - pub fn new(id: Cow<'a, str>) -> Self { + pub fn new(id: String) -> Self { Self { id, _phantom: PhantomData, diff --git a/typesense_codegen/src/models/curation_item_schema.rs b/typesense_codegen/src/models/curation_item_schema.rs index 705879fe..598d88f1 100644 --- a/typesense_codegen/src/models/curation_item_schema.rs +++ b/typesense_codegen/src/models/curation_item_schema.rs @@ -24,7 +24,7 @@ pub struct CurationItemSchema<'a> { pub excludes: Option>>, /// A filter by clause that is applied to any search query that matches the curation rule. #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] - pub filter_by: Option>, + pub filter_by: Option, /// Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. #[serde( rename = "remove_matched_tokens", @@ -36,10 +36,10 @@ pub struct CurationItemSchema<'a> { pub metadata: Option, /// A sort by clause that is applied to any search query that matches the curation rule. #[serde(rename = "sort_by", skip_serializing_if = "Option::is_none")] - pub sort_by: Option>, + pub sort_by: Option, /// Replaces the current search query with this value, when the search query matches the curation rule. #[serde(rename = "replace_query", skip_serializing_if = "Option::is_none")] - pub replace_query: Option>, + pub replace_query: Option, /// When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. #[serde( rename = "filter_curated_hits", @@ -56,13 +56,13 @@ pub struct CurationItemSchema<'a> { #[serde(rename = "stop_processing", skip_serializing_if = "Option::is_none")] pub stop_processing: Option, #[serde(rename = "id")] - pub id: Cow<'a, str>, + pub id: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> CurationItemSchema<'a> { - pub fn new(rule: models::CurationRule<'a>, id: Cow<'a, str>) -> Self { + pub fn new(rule: models::CurationRule<'a>, id: String) -> Self { Self { rule: Box::new(rule), includes: None, diff --git a/typesense_codegen/src/models/curation_rule.rs b/typesense_codegen/src/models/curation_rule.rs index 9bff89bd..42268064 100644 --- a/typesense_codegen/src/models/curation_rule.rs +++ b/typesense_codegen/src/models/curation_rule.rs @@ -19,13 +19,13 @@ pub struct CurationRule<'a> { pub tags: Option>, /// Indicates what search queries should be curated #[serde(rename = "query", skip_serializing_if = "Option::is_none")] - pub query: Option>, + pub query: Option, /// Indicates whether the match on the query term should be `exact` or `contains`. If we want to match all queries that contained the word `apple`, we will use the `contains` match instead. #[serde(rename = "match", skip_serializing_if = "Option::is_none")] pub r#match: Option, /// Indicates that the curation should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc). #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] - pub filter_by: Option>, + pub filter_by: Option, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } diff --git a/typesense_codegen/src/models/curation_set_delete_schema.rs b/typesense_codegen/src/models/curation_set_delete_schema.rs index c022df41..6a4ae1dc 100644 --- a/typesense_codegen/src/models/curation_set_delete_schema.rs +++ b/typesense_codegen/src/models/curation_set_delete_schema.rs @@ -16,13 +16,13 @@ use serde::{Deserialize, Serialize}; pub struct CurationSetDeleteSchema<'a> { /// Name of the deleted curation set #[serde(rename = "name")] - pub name: Cow<'a, str>, + pub name: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> CurationSetDeleteSchema<'a> { - pub fn new(name: Cow<'a, str>) -> Self { + pub fn new(name: String) -> Self { Self { name, _phantom: PhantomData, diff --git a/typesense_codegen/src/models/curation_set_schema.rs b/typesense_codegen/src/models/curation_set_schema.rs index 50742584..2e471d00 100644 --- a/typesense_codegen/src/models/curation_set_schema.rs +++ b/typesense_codegen/src/models/curation_set_schema.rs @@ -19,15 +19,15 @@ pub struct CurationSetSchema<'a> { pub items: Vec>, /// Optional description for the curation set #[serde(rename = "description", skip_serializing_if = "Option::is_none")] - pub description: Option>, + pub description: Option, #[serde(rename = "name")] - pub name: Cow<'a, str>, + pub name: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> CurationSetSchema<'a> { - pub fn new(items: Vec>, name: Cow<'a, str>) -> Self { + pub fn new(items: Vec>, name: String) -> Self { Self { items, description: None, diff --git a/typesense_codegen/src/models/facet_counts.rs b/typesense_codegen/src/models/facet_counts.rs index fd17a05b..c340d58e 100644 --- a/typesense_codegen/src/models/facet_counts.rs +++ b/typesense_codegen/src/models/facet_counts.rs @@ -17,7 +17,7 @@ pub struct FacetCounts<'a> { #[serde(rename = "counts", skip_serializing_if = "Option::is_none")] pub counts: Option>>, #[serde(rename = "field_name", skip_serializing_if = "Option::is_none")] - pub field_name: Option>, + pub field_name: Option, #[serde(rename = "stats", skip_serializing_if = "Option::is_none")] pub stats: Option>>, #[serde(skip)] diff --git a/typesense_codegen/src/models/facet_counts_counts_inner.rs b/typesense_codegen/src/models/facet_counts_counts_inner.rs index 1e657025..94375a8b 100644 --- a/typesense_codegen/src/models/facet_counts_counts_inner.rs +++ b/typesense_codegen/src/models/facet_counts_counts_inner.rs @@ -17,9 +17,9 @@ pub struct FacetCountsCountsInner<'a> { #[serde(rename = "count", skip_serializing_if = "Option::is_none")] pub count: Option, #[serde(rename = "highlighted", skip_serializing_if = "Option::is_none")] - pub highlighted: Option>, + pub highlighted: Option, #[serde(rename = "value", skip_serializing_if = "Option::is_none")] - pub value: Option>, + pub value: Option, #[serde(rename = "parent", skip_serializing_if = "Option::is_none")] pub parent: Option, #[serde(skip)] diff --git a/typesense_codegen/src/models/field.rs b/typesense_codegen/src/models/field.rs index e1013819..a8b0fd0e 100644 --- a/typesense_codegen/src/models/field.rs +++ b/typesense_codegen/src/models/field.rs @@ -18,9 +18,9 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Field<'a> { #[serde(rename = "name")] - pub name: Cow<'a, str>, + pub name: String, #[serde(rename = "type")] - pub r#type: Cow<'a, str>, + pub r#type: String, #[serde(rename = "optional", skip_serializing_if = "Option::is_none")] pub optional: Option, #[serde(rename = "facet", skip_serializing_if = "Option::is_none")] @@ -28,14 +28,14 @@ pub struct Field<'a> { #[serde(rename = "index", skip_serializing_if = "Option::is_none")] pub index: Option, #[serde(rename = "locale", skip_serializing_if = "Option::is_none")] - pub locale: Option>, + pub locale: Option, #[serde(rename = "sort", skip_serializing_if = "Option::is_none")] pub sort: Option, #[serde(rename = "infix", skip_serializing_if = "Option::is_none")] pub infix: Option, /// Name of a field in another collection that should be linked to this collection so that it can be joined during query. #[serde(rename = "reference", skip_serializing_if = "Option::is_none")] - pub reference: Option>, + pub reference: Option, #[serde(rename = "num_dim", skip_serializing_if = "Option::is_none")] pub num_dim: Option, #[serde(rename = "drop", skip_serializing_if = "Option::is_none")] @@ -45,7 +45,7 @@ pub struct Field<'a> { pub store: Option, /// The distance metric to be used for vector search. Default: `cosine`. You can also use `ip` for inner product. #[serde(rename = "vec_dist", skip_serializing_if = "Option::is_none")] - pub vec_dist: Option>, + pub vec_dist: Option, /// Enables an index optimized for range filtering on numerical fields (e.g. rating:>3.5). Default: false. #[serde(rename = "range_index", skip_serializing_if = "Option::is_none")] pub range_index: Option, @@ -54,7 +54,7 @@ pub struct Field<'a> { pub stem: Option, /// Name of the stemming dictionary to use for this field #[serde(rename = "stem_dictionary", skip_serializing_if = "Option::is_none")] - pub stem_dictionary: Option>, + pub stem_dictionary: Option, /// List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters. #[serde(rename = "token_separators", skip_serializing_if = "Option::is_none")] pub token_separators: Option>, @@ -69,7 +69,7 @@ pub struct Field<'a> { } impl<'a> Field<'a> { - pub fn new(name: Cow<'a, str>, r#type: Cow<'a, str>) -> Self { + pub fn new(name: String, r#type: String) -> Self { Self { name, r#type, diff --git a/typesense_codegen/src/models/nl_search_model_base.rs b/typesense_codegen/src/models/nl_search_model_base.rs index e899ee04..a806361d 100644 --- a/typesense_codegen/src/models/nl_search_model_base.rs +++ b/typesense_codegen/src/models/nl_search_model_base.rs @@ -16,13 +16,13 @@ use serde::{Deserialize, Serialize}; pub struct NlSearchModelBase<'a> { /// Name of the NL model to use #[serde(rename = "model_name", skip_serializing_if = "Option::is_none")] - pub model_name: Option>, + pub model_name: Option, /// API key for the NL model service #[serde(rename = "api_key", skip_serializing_if = "Option::is_none")] - pub api_key: Option>, + pub api_key: Option, /// Custom API URL for the NL model service #[serde(rename = "api_url", skip_serializing_if = "Option::is_none")] - pub api_url: Option>, + pub api_url: Option, /// Maximum number of bytes to process #[serde(rename = "max_bytes", skip_serializing_if = "Option::is_none")] pub max_bytes: Option, @@ -31,7 +31,7 @@ pub struct NlSearchModelBase<'a> { pub temperature: Option, /// System prompt for the NL model #[serde(rename = "system_prompt", skip_serializing_if = "Option::is_none")] - pub system_prompt: Option>, + pub system_prompt: Option, /// Top-p parameter for the NL model (Google-specific) #[serde(rename = "top_p", skip_serializing_if = "Option::is_none")] pub top_p: Option, @@ -43,31 +43,31 @@ pub struct NlSearchModelBase<'a> { pub stop_sequences: Option>, /// API version for the NL model service #[serde(rename = "api_version", skip_serializing_if = "Option::is_none")] - pub api_version: Option>, + pub api_version: Option, /// Project ID for GCP Vertex AI #[serde(rename = "project_id", skip_serializing_if = "Option::is_none")] - pub project_id: Option>, + pub project_id: Option, /// Access token for GCP Vertex AI #[serde(rename = "access_token", skip_serializing_if = "Option::is_none")] - pub access_token: Option>, + pub access_token: Option, /// Refresh token for GCP Vertex AI #[serde(rename = "refresh_token", skip_serializing_if = "Option::is_none")] - pub refresh_token: Option>, + pub refresh_token: Option, /// Client ID for GCP Vertex AI #[serde(rename = "client_id", skip_serializing_if = "Option::is_none")] - pub client_id: Option>, + pub client_id: Option, /// Client secret for GCP Vertex AI #[serde(rename = "client_secret", skip_serializing_if = "Option::is_none")] - pub client_secret: Option>, + pub client_secret: Option, /// Region for GCP Vertex AI #[serde(rename = "region", skip_serializing_if = "Option::is_none")] - pub region: Option>, + pub region: Option, /// Maximum output tokens for GCP Vertex AI #[serde(rename = "max_output_tokens", skip_serializing_if = "Option::is_none")] pub max_output_tokens: Option, /// Account ID for Cloudflare-specific models #[serde(rename = "account_id", skip_serializing_if = "Option::is_none")] - pub account_id: Option>, + pub account_id: Option, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } diff --git a/typesense_codegen/src/models/nl_search_model_delete_schema.rs b/typesense_codegen/src/models/nl_search_model_delete_schema.rs index fa187d83..9ab0d2ae 100644 --- a/typesense_codegen/src/models/nl_search_model_delete_schema.rs +++ b/typesense_codegen/src/models/nl_search_model_delete_schema.rs @@ -16,13 +16,13 @@ use serde::{Deserialize, Serialize}; pub struct NlSearchModelDeleteSchema<'a> { /// ID of the deleted NL search model #[serde(rename = "id")] - pub id: Cow<'a, str>, + pub id: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> NlSearchModelDeleteSchema<'a> { - pub fn new(id: Cow<'a, str>) -> Self { + pub fn new(id: String) -> Self { Self { id, _phantom: PhantomData, diff --git a/typesense_codegen/src/models/nl_search_model_schema.rs b/typesense_codegen/src/models/nl_search_model_schema.rs index 76a616d3..c64c9a51 100644 --- a/typesense_codegen/src/models/nl_search_model_schema.rs +++ b/typesense_codegen/src/models/nl_search_model_schema.rs @@ -16,13 +16,13 @@ use serde::{Deserialize, Serialize}; pub struct NlSearchModelSchema<'a> { /// Name of the NL model to use #[serde(rename = "model_name", skip_serializing_if = "Option::is_none")] - pub model_name: Option>, + pub model_name: Option, /// API key for the NL model service #[serde(rename = "api_key", skip_serializing_if = "Option::is_none")] - pub api_key: Option>, + pub api_key: Option, /// Custom API URL for the NL model service #[serde(rename = "api_url", skip_serializing_if = "Option::is_none")] - pub api_url: Option>, + pub api_url: Option, /// Maximum number of bytes to process #[serde(rename = "max_bytes", skip_serializing_if = "Option::is_none")] pub max_bytes: Option, @@ -31,7 +31,7 @@ pub struct NlSearchModelSchema<'a> { pub temperature: Option, /// System prompt for the NL model #[serde(rename = "system_prompt", skip_serializing_if = "Option::is_none")] - pub system_prompt: Option>, + pub system_prompt: Option, /// Top-p parameter for the NL model (Google-specific) #[serde(rename = "top_p", skip_serializing_if = "Option::is_none")] pub top_p: Option, @@ -43,40 +43,40 @@ pub struct NlSearchModelSchema<'a> { pub stop_sequences: Option>, /// API version for the NL model service #[serde(rename = "api_version", skip_serializing_if = "Option::is_none")] - pub api_version: Option>, + pub api_version: Option, /// Project ID for GCP Vertex AI #[serde(rename = "project_id", skip_serializing_if = "Option::is_none")] - pub project_id: Option>, + pub project_id: Option, /// Access token for GCP Vertex AI #[serde(rename = "access_token", skip_serializing_if = "Option::is_none")] - pub access_token: Option>, + pub access_token: Option, /// Refresh token for GCP Vertex AI #[serde(rename = "refresh_token", skip_serializing_if = "Option::is_none")] - pub refresh_token: Option>, + pub refresh_token: Option, /// Client ID for GCP Vertex AI #[serde(rename = "client_id", skip_serializing_if = "Option::is_none")] - pub client_id: Option>, + pub client_id: Option, /// Client secret for GCP Vertex AI #[serde(rename = "client_secret", skip_serializing_if = "Option::is_none")] - pub client_secret: Option>, + pub client_secret: Option, /// Region for GCP Vertex AI #[serde(rename = "region", skip_serializing_if = "Option::is_none")] - pub region: Option>, + pub region: Option, /// Maximum output tokens for GCP Vertex AI #[serde(rename = "max_output_tokens", skip_serializing_if = "Option::is_none")] pub max_output_tokens: Option, /// Account ID for Cloudflare-specific models #[serde(rename = "account_id", skip_serializing_if = "Option::is_none")] - pub account_id: Option>, + pub account_id: Option, /// ID of the NL search model #[serde(rename = "id")] - pub id: Cow<'a, str>, + pub id: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> NlSearchModelSchema<'a> { - pub fn new(id: Cow<'a, str>) -> Self { + pub fn new(id: String) -> Self { Self { model_name: None, api_key: None, diff --git a/typesense_codegen/src/models/preset_delete_schema.rs b/typesense_codegen/src/models/preset_delete_schema.rs index a3607b83..bd5a8b4c 100644 --- a/typesense_codegen/src/models/preset_delete_schema.rs +++ b/typesense_codegen/src/models/preset_delete_schema.rs @@ -15,13 +15,13 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct PresetDeleteSchema<'a> { #[serde(rename = "name")] - pub name: Cow<'a, str>, + pub name: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> PresetDeleteSchema<'a> { - pub fn new(name: Cow<'a, str>) -> Self { + pub fn new(name: String) -> Self { Self { name, _phantom: PhantomData, diff --git a/typesense_codegen/src/models/preset_schema.rs b/typesense_codegen/src/models/preset_schema.rs index 5233007b..16dbf506 100644 --- a/typesense_codegen/src/models/preset_schema.rs +++ b/typesense_codegen/src/models/preset_schema.rs @@ -17,13 +17,13 @@ pub struct PresetSchema<'a> { #[serde(rename = "value")] pub value: Box>, #[serde(rename = "name")] - pub name: Cow<'a, str>, + pub name: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> PresetSchema<'a> { - pub fn new(value: models::PresetUpsertSchemaValue<'a>, name: Cow<'a, str>) -> Self { + pub fn new(value: models::PresetUpsertSchemaValue<'a>, name: String) -> Self { Self { value: Box::new(value), name, diff --git a/typesense_codegen/src/models/search_synonym.rs b/typesense_codegen/src/models/search_synonym.rs index 0100d250..7d383205 100644 --- a/typesense_codegen/src/models/search_synonym.rs +++ b/typesense_codegen/src/models/search_synonym.rs @@ -16,24 +16,24 @@ use serde::{Deserialize, Serialize}; pub struct SearchSynonym<'a> { /// For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. #[serde(rename = "root", skip_serializing_if = "Option::is_none")] - pub root: Option>, + pub root: Option, /// Array of words that should be considered as synonyms. #[serde(rename = "synonyms")] pub synonyms: Vec, /// Locale for the synonym, leave blank to use the standard tokenizer. #[serde(rename = "locale", skip_serializing_if = "Option::is_none")] - pub locale: Option>, + pub locale: Option, /// By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is. #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] pub symbols_to_index: Option>, #[serde(rename = "id")] - pub id: Cow<'a, str>, + pub id: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> SearchSynonym<'a> { - pub fn new(synonyms: Vec, id: Cow<'a, str>) -> Self { + pub fn new(synonyms: Vec, id: String) -> Self { Self { root: None, synonyms, diff --git a/typesense_codegen/src/models/search_synonym_schema.rs b/typesense_codegen/src/models/search_synonym_schema.rs index c560d46d..8b640295 100644 --- a/typesense_codegen/src/models/search_synonym_schema.rs +++ b/typesense_codegen/src/models/search_synonym_schema.rs @@ -16,13 +16,13 @@ use serde::{Deserialize, Serialize}; pub struct SearchSynonymSchema<'a> { /// For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. #[serde(rename = "root", skip_serializing_if = "Option::is_none")] - pub root: Option>, + pub root: Option, /// Array of words that should be considered as synonyms. #[serde(rename = "synonyms")] pub synonyms: Vec, /// Locale for the synonym, leave blank to use the standard tokenizer. #[serde(rename = "locale", skip_serializing_if = "Option::is_none")] - pub locale: Option>, + pub locale: Option, /// By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is. #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] pub symbols_to_index: Option>, diff --git a/typesense_codegen/src/models/stemming_dictionary.rs b/typesense_codegen/src/models/stemming_dictionary.rs index 0f51b24a..106149ca 100644 --- a/typesense_codegen/src/models/stemming_dictionary.rs +++ b/typesense_codegen/src/models/stemming_dictionary.rs @@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize}; pub struct StemmingDictionary<'a> { /// Unique identifier for the dictionary #[serde(rename = "id")] - pub id: Cow<'a, str>, + pub id: String, /// List of word mappings in the dictionary #[serde(rename = "words")] pub words: Vec>, @@ -25,7 +25,7 @@ pub struct StemmingDictionary<'a> { } impl<'a> StemmingDictionary<'a> { - pub fn new(id: Cow<'a, str>, words: Vec>) -> Self { + pub fn new(id: String, words: Vec>) -> Self { Self { id, words, diff --git a/typesense_codegen/src/models/stemming_dictionary_words_inner.rs b/typesense_codegen/src/models/stemming_dictionary_words_inner.rs index 7f82248e..1683b5a0 100644 --- a/typesense_codegen/src/models/stemming_dictionary_words_inner.rs +++ b/typesense_codegen/src/models/stemming_dictionary_words_inner.rs @@ -16,16 +16,16 @@ use serde::{Deserialize, Serialize}; pub struct StemmingDictionaryWordsInner<'a> { /// The word form to be stemmed #[serde(rename = "word")] - pub word: Cow<'a, str>, + pub word: String, /// The root form of the word #[serde(rename = "root")] - pub root: Cow<'a, str>, + pub root: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> StemmingDictionaryWordsInner<'a> { - pub fn new(word: Cow<'a, str>, root: Cow<'a, str>) -> Self { + pub fn new(word: String, root: String) -> Self { Self { word, root, diff --git a/typesense_codegen/src/models/stopwords_set_schema.rs b/typesense_codegen/src/models/stopwords_set_schema.rs index a7e7d876..e90a2b82 100644 --- a/typesense_codegen/src/models/stopwords_set_schema.rs +++ b/typesense_codegen/src/models/stopwords_set_schema.rs @@ -15,17 +15,17 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct StopwordsSetSchema<'a> { #[serde(rename = "id")] - pub id: Cow<'a, str>, + pub id: String, #[serde(rename = "stopwords")] pub stopwords: Vec, #[serde(rename = "locale", skip_serializing_if = "Option::is_none")] - pub locale: Option>, + pub locale: Option, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> StopwordsSetSchema<'a> { - pub fn new(id: Cow<'a, str>, stopwords: Vec) -> Self { + pub fn new(id: String, stopwords: Vec) -> Self { Self { id, stopwords, diff --git a/typesense_codegen/src/models/synonym_item_delete_schema.rs b/typesense_codegen/src/models/synonym_item_delete_schema.rs index c5da7c87..215386a8 100644 --- a/typesense_codegen/src/models/synonym_item_delete_schema.rs +++ b/typesense_codegen/src/models/synonym_item_delete_schema.rs @@ -16,13 +16,13 @@ use serde::{Deserialize, Serialize}; pub struct SynonymItemDeleteSchema<'a> { /// ID of the deleted synonym item #[serde(rename = "id")] - pub id: Cow<'a, str>, + pub id: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> SynonymItemDeleteSchema<'a> { - pub fn new(id: Cow<'a, str>) -> Self { + pub fn new(id: String) -> Self { Self { id, _phantom: PhantomData, diff --git a/typesense_codegen/src/models/synonym_set_delete_schema.rs b/typesense_codegen/src/models/synonym_set_delete_schema.rs index 537b181d..f63038b6 100644 --- a/typesense_codegen/src/models/synonym_set_delete_schema.rs +++ b/typesense_codegen/src/models/synonym_set_delete_schema.rs @@ -16,13 +16,13 @@ use serde::{Deserialize, Serialize}; pub struct SynonymSetDeleteSchema<'a> { /// Name of the deleted synonym set #[serde(rename = "name")] - pub name: Cow<'a, str>, + pub name: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> SynonymSetDeleteSchema<'a> { - pub fn new(name: Cow<'a, str>) -> Self { + pub fn new(name: String) -> Self { Self { name, _phantom: PhantomData, diff --git a/typesense_codegen/src/models/synonym_set_schema.rs b/typesense_codegen/src/models/synonym_set_schema.rs index 7e3774e1..ee1d81f0 100644 --- a/typesense_codegen/src/models/synonym_set_schema.rs +++ b/typesense_codegen/src/models/synonym_set_schema.rs @@ -19,13 +19,13 @@ pub struct SynonymSetSchema<'a> { pub items: Vec>, /// Name of the synonym set #[serde(rename = "name")] - pub name: Cow<'a, str>, + pub name: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> SynonymSetSchema<'a> { - pub fn new(items: Vec>, name: Cow<'a, str>) -> Self { + pub fn new(items: Vec>, name: String) -> Self { Self { items, name, diff --git a/typesense_codegen/src/models/voice_query_model_collection_config.rs b/typesense_codegen/src/models/voice_query_model_collection_config.rs index 658d3828..6042a7bc 100644 --- a/typesense_codegen/src/models/voice_query_model_collection_config.rs +++ b/typesense_codegen/src/models/voice_query_model_collection_config.rs @@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct VoiceQueryModelCollectionConfig<'a> { #[serde(rename = "model_name", skip_serializing_if = "Option::is_none")] - pub model_name: Option>, + pub model_name: Option, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } diff --git a/typesense_derive/src/field_attributes.rs b/typesense_derive/src/field_attributes.rs index a62b0519..fe4b7d1b 100644 --- a/typesense_derive/src/field_attributes.rs +++ b/typesense_derive/src/field_attributes.rs @@ -321,9 +321,9 @@ pub(crate) fn process_field( .into_iter() .map(|mut f| { // Use the dynamically determined prefix here - f.name = ::std::borrow::Cow::Owned(format!("{}.{}", #prefix, f.name)); + f.name = format!("{}.{}", #prefix, f.name); if #is_vec && !f.r#type.ends_with("[]") { - f.r#type.to_mut().push_str("[]"); + f.r#type.push_str("[]"); } f }) diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 8aaae8ab..645e3453 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -7,11 +7,12 @@ edition.workspace = true [dependencies] anyhow = { workspace = true } clap = { workspace = true } +indexmap = { workspace = true } reqwest = { version = "0.12", features = ["blocking"] } # "blocking" is simpler for scripts serde = { workspace = true } serde_yaml = { workspace = true } -typesense = { path = "../typesense", optional = true} tokio = { workspace = true} +typesense = { path = "../typesense", optional = true} [features] default = [] diff --git a/xtask/src/add_vendor_attributes.rs b/xtask/src/add_vendor_attributes.rs index ae98c251..9eece4e3 100644 --- a/xtask/src/add_vendor_attributes.rs +++ b/xtask/src/add_vendor_attributes.rs @@ -1,9 +1,8 @@ -use crate::vendor_attributes::VendorAttributes; -use serde_yaml::Mapping; +use crate::{preprocess_openapi::OpenAPI, vendor_attributes::VendorAttributes}; -pub fn add_vendor_attributes(doc_root: &mut Mapping) -> Result<(), String> { +pub fn add_vendor_attributes(doc: &mut OpenAPI) -> Result<(), String> { println!("Adding custom x-* vendor attributes..."); - let mut attrs = VendorAttributes::new(doc_root); + let mut attrs = VendorAttributes::new(doc); // Schemas attrs.schema_builder([ @@ -45,58 +44,50 @@ pub fn add_vendor_attributes(doc_root: &mut Mapping) -> Result<(), String> { // Operations attrs .operation("/collections/{collectionName}/documents/search", "get") - .generic_parameter("D: for<'de> serde::Deserialize<'de> + Serialize") - .return_type("models::SearchResult<'static, D>") - .done()?; + .generic_parameter("D: for<'de> serde::Deserialize<'de> + Serialize")? + .return_type("models::SearchResult<'static, D>")?; attrs .operation("/multi_search", "post") - .return_type("serde_json::Value") - .done()?; + .return_type("serde_json::Value")?; // The endpoint return `null` if no schema changes are in progress attrs .operation("/operations/schema_changes", "get") - .return_type("Option>>") - .done()?; + .return_type("Option>>")?; // The documents /import endpoint expects a text/plain body and response attrs .operation("/collections/{collectionName}/documents/import", "post") - .body_is_raw_text() - .supports_plain_text() - .done()?; + .body_is_raw_text()? + .supports_plain_text()?; // The stemming /import endpoint also expects a text/plain body and response attrs .operation("/stemming/dictionaries/import", "post") - .body_is_raw_text() - .supports_plain_text() - .done()?; + .body_is_raw_text()? + .supports_plain_text()?; attrs .operation("/collections/{collectionName}/documents/export", "get") - .supports_plain_text() - .done()?; + .supports_plain_text()?; attrs .operation("/collections/{collectionName}/documents", "patch") - .generic_parameter("B: Serialize") - .params_generic_parameter("B") - .request_type("B") - .done()?; + .generic_parameter("B: Serialize")? + .params_generic_parameter("B")? + .request_type("B")?; attrs .operation( "/collections/{collectionName}/documents/{documentId}", "patch", ) - .generic_parameter("B: Serialize") - .params_generic_parameter("B") - .request_type("B") - .done()?; + .generic_parameter("B: Serialize")? + .params_generic_parameter("B")? + .request_type("B")?; - attrs.schemas_mark_owned_data()?; + // attrs.schemas_mark_owned_data()?; Ok(()) } diff --git a/xtask/src/preprocess_openapi.rs b/xtask/src/preprocess_openapi.rs index d2a16ba9..0ce2e073 100644 --- a/xtask/src/preprocess_openapi.rs +++ b/xtask/src/preprocess_openapi.rs @@ -1,8 +1,142 @@ -use serde_yaml::{Mapping, Value}; -use std::fs; +use ::std::{collections::HashSet, fs}; +use indexmap::IndexMap; +use serde::{Deserialize, Serialize}; +use serde_yaml::Value; use crate::add_vendor_attributes::add_vendor_attributes; +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct OpenAPI { + #[serde(skip_serializing_if = "Option::is_none")] + openapi: Option, + #[serde(skip_serializing_if = "Option::is_none")] + info: Option, + #[serde(skip_serializing_if = "Option::is_none")] + servers: Option, + #[serde(skip_serializing_if = "Option::is_none")] + external_docs: Option, + #[serde(skip_serializing_if = "Option::is_none")] + security: Option, + #[serde(skip_serializing_if = "Option::is_none")] + tags: Option, + pub(crate) paths: IndexMap, + pub(crate) components: OpenAPIComponents, + + // Everything else not explicitly listed above + #[serde(flatten)] + pub(crate) extra: IndexMap, +} + +// PATHS +pub(crate) type OpenAPIPath = IndexMap; + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct OpenAPIMethod { + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) tags: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) summary: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) description: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) operation_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) parameters: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) request_body: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) responses: Option>, + + // Everything else not explicitly listed above + #[serde(flatten)] + pub(crate) extra: IndexMap, +} + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct OpenAPIBody { + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) description: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) required: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) content: Option>, + + // Everything else not explicitly listed above + #[serde(flatten)] + pub(crate) extra: IndexMap, +} + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct OpenAPIBodyContent { + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) schema: Option, + + // Everything else not explicitly listed above + #[serde(flatten)] + pub(crate) extra: IndexMap, +} + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct OpenAPIParameter { + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) r#in: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) description: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) required: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) schema: Option, + + // Everything else not explicitly listed above + #[serde(flatten)] + pub(crate) extra: IndexMap, +} + +// COMPONENTS +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct OpenAPIComponents { + pub(crate) schemas: IndexMap, + + // Everything else not explicitly listed above + #[serde(flatten)] + pub(crate) extra: IndexMap, +} + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct OpenAPIProperty { + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) description: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) r#type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) required: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) example: Option, + #[serde(rename = "$ref", skip_serializing_if = "Option::is_none")] + pub(crate) r#ref: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) properties: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) items: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) one_of: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) any_of: Option>, + + // Everything else not explicitly listed above + #[serde(flatten)] + pub(crate) extra: IndexMap, +} + // --- Main function to orchestrate the file reading, processing, and writing --- pub fn preprocess_openapi_file( input_path: &str, @@ -13,57 +147,53 @@ pub fn preprocess_openapi_file( println!("Reading OpenAPI spec from {}...", input_path); let input_content = fs::read_to_string(input_path) .map_err(|e| format!("Failed to read {}: {}", input_path, e))?; - let mut doc: Value = serde_yaml::from_str(&input_content)?; - - // Ensure the root is a mutable mapping - let doc_root = doc - .as_mapping_mut() - .ok_or("OpenAPI spec root is not a YAML map")?; + let mut doc: OpenAPI = serde_yaml::from_str(&input_content)?; // --- Step 2: Apply all the required transformations --- println!("Preprocessing the spec..."); println!("Adding custom x-* vendor attributes..."); - add_vendor_attributes(doc_root)?; + add_vendor_attributes(&mut doc)?; println!("Unwrapping parameters..."); - unwrap_search_parameters(doc_root)?; - unwrap_multi_search_parameters(doc_root)?; + unwrap_search_parameters(&mut doc)?; + unwrap_multi_search_parameters(&mut doc)?; unwrap_parameters_by_path( - doc_root, + &mut doc, "/collections/{collectionName}/documents/import", "post", "importDocumentsParameters", Some("ImportDocumentsParameters"), // Copy schema to components )?; unwrap_parameters_by_path( - doc_root, + &mut doc, "/collections/{collectionName}/documents/export", "get", "exportDocumentsParameters", Some("ExportDocumentsParameters"), )?; unwrap_parameters_by_path( - doc_root, + &mut doc, "/collections/{collectionName}/documents", "patch", "updateDocumentsParameters", Some("UpdateDocumentsParameters"), )?; unwrap_parameters_by_path( - doc_root, + &mut doc, "/collections/{collectionName}/documents", "delete", "deleteDocumentsParameters", Some("DeleteDocumentsParameters"), )?; unwrap_parameters_by_path( - doc_root, + &mut doc, "/collections", "get", "getCollectionsParameters", Some("GetCollectionsParameters"), )?; + schemas_mark_owned_data(&mut doc); println!("Preprocessing complete."); // --- Step 3: Serialize the modified spec and write to the output file --- @@ -76,11 +206,107 @@ pub fn preprocess_openapi_file( Ok(()) } +fn collect_property(prop: &OpenAPIProperty) -> Vec { + let mut data = Vec::new(); + if let Some(schema) = &prop.r#ref { + data.push( + schema + .trim_start_matches("#/components/schemas/") + .to_owned(), + ); + } + if let Some(p) = &prop.items { + data.extend(collect_property(p)); + } + if let Some(v) = &prop.any_of { + v.iter().for_each(|p| data.extend(collect_property(p))); + } + if let Some(v) = &prop.one_of { + v.iter().for_each(|p| data.extend(collect_property(p))); + } + data +} + +fn schemas_mark_owned_data(doc: &mut OpenAPI) { + let mut request_schemas = HashSet::new(); + doc.paths.iter().for_each(|(_, pms)| { + pms.iter().for_each(|(_, pm)| { + if let Some(ps) = &pm.parameters { + ps.iter().for_each(|p| { + if let Some(s) = &p.schema { + request_schemas.extend(collect_property(s)); + } + }) + } + if let Some(reqb) = &pm.request_body + && let Some(cs) = &reqb.content + { + cs.iter().for_each(|(_, c)| { + c.schema.as_ref().iter().for_each(|cp| { + request_schemas.extend(collect_property(cp)); + }) + }) + } + }) + }); + + let schemas = doc + .components + .schemas + .iter() + .filter(|(n, _)| !n.ends_with("Parameters") && !request_schemas.contains(n.as_str())) + .map(|(n, _)| n.to_owned()) + .collect::>(); + drop(request_schemas); + + for schema_name in schemas { + let Some(schema) = doc.components.schemas.get_mut(&schema_name) else { + continue; + }; + + schema + .extra + .insert("x-rust-is-owned-data".to_owned(), Value::Bool(true)); + + for (_, prop) in schema.properties.iter_mut().flat_map(|v| v.iter_mut()) { + for inner in prop.one_of.iter_mut().flat_map(|v| v.iter_mut()) { + if inner.r#type.as_deref() != Some("object") { + continue; + } + inner + .extra + .insert("x-rust-is-owned-data".to_owned(), Value::Bool(true)); + } + for inner in prop.any_of.iter_mut().flat_map(|v| v.iter_mut()) { + if inner.r#type.as_deref() != Some("object") { + continue; + } + inner + .extra + .insert("x-rust-is-owned-data".to_owned(), Value::Bool(true)); + } + if let Some(inner) = &mut prop.items + && inner.r#type.as_deref() == Some("object") + { + inner + .extra + .insert("x-rust-is-owned-data".to_owned(), Value::Bool(true)); + } + + if prop.r#type.as_deref() != Some("object") { + continue; + } + prop.extra + .insert("x-rust-is-owned-data".to_owned(), Value::Bool(true)); + } + } +} + /// A generic function to: /// 1. (Optional) Copy an inline parameter schema to `components/schemas`. /// 2. Unwrap that parameter object into individual query parameters within the `paths` definition. fn unwrap_parameters_by_path( - doc: &mut Mapping, + doc: &mut OpenAPI, path: &str, method: &str, param_name_to_unwrap: &str, @@ -95,31 +321,26 @@ fn unwrap_parameters_by_path( // Find the parameter with the inline schema to copy using a read-only borrow let params_for_copy = doc - .get("paths") - .and_then(|p| p.get(path)) + .paths + .get(path) .and_then(|p| p.get(method)) - .and_then(|op| op.get("parameters")) - .and_then(|params| params.as_sequence()) + .and_then(|op| op.parameters.as_ref()) .ok_or_else(|| format!("Could not find parameters for {} {}", method, path))?; let param_to_copy = params_for_copy .iter() - .find(|p| p.get("name").and_then(|n| n.as_str()) == Some(param_name_to_unwrap)) + .find(|p| p.name.as_deref() == Some(param_name_to_unwrap)) .ok_or_else(|| format!("Parameter '{}' not found for copying", param_name_to_unwrap))?; let inline_schema = param_to_copy - .get("schema") - .cloned() // Clone the schema to avoid borrowing issues + .schema + .clone() .ok_or_else(|| format!("No schema found for '{}'", param_name_to_unwrap))?; // Get a mutable borrow to insert the cloned schema into components - let schemas = doc - .get_mut("components") - .and_then(|c| c.get_mut("schemas")) - .and_then(|s| s.as_mapping_mut()) - .ok_or_else(|| "Could not find components/schemas section".to_string())?; - - schemas.insert(component_name.into(), inline_schema); + doc.components + .schemas + .insert(component_name.into(), inline_schema); } // --- Step 2: Unwrap the parameter object into individual parameters --- @@ -130,23 +351,21 @@ fn unwrap_parameters_by_path( // Navigate down to the operation's parameters list (mutable) let params_for_unwrap = doc - .get_mut("paths") - .and_then(|p| p.get_mut(path)) + .paths + .get_mut(path) .and_then(|p| p.get_mut(method)) - .and_then(|op| op.get_mut("parameters")) - .and_then(|params| params.as_sequence_mut()) + .and_then(|op| op.parameters.as_mut()) .ok_or_else(|| format!("Could not find parameters for {} {}", method, path))?; let param_index = params_for_unwrap .iter() - .position(|p| p.get("name").and_then(|n| n.as_str()) == Some(param_name_to_unwrap)) + .position(|p| p.name.as_deref() == Some(param_name_to_unwrap)) .ok_or_else(|| format!("Parameter '{}' not found in {}", param_name_to_unwrap, path))?; let param_object = params_for_unwrap.remove(param_index); let properties = param_object - .get("schema") - .and_then(|s| s.get("properties")) - .and_then(|p| p.as_mapping()) + .schema + .and_then(|s| s.properties) .ok_or_else(|| { format!( "Could not extract properties from '{}'", @@ -155,36 +374,36 @@ fn unwrap_parameters_by_path( })?; for (key, value) in properties { - let mut new_param = Mapping::new(); - new_param.insert("name".into(), key.clone()); - new_param.insert("in".into(), "query".into()); - new_param.insert("schema".into(), value.clone()); - params_for_unwrap.push(new_param.into()); + let new_param = OpenAPIParameter { + name: Some(key), + r#in: Some("query".to_owned()), + schema: Some(value), + ..Default::default() + }; + params_for_unwrap.push(new_param); } Ok(()) } /// Special handler for unwrapping search parameters from `components/schemas`. -fn unwrap_search_parameters(doc: &mut Mapping) -> Result<(), String> { +fn unwrap_search_parameters(doc: &mut OpenAPI) -> Result<(), String> { println!("- Unwrapping searchParameters..."); // Get the definition of SearchParameters from components let search_params_props = doc - .get("components") - .and_then(|c| c.get("schemas")) - .and_then(|s| s.get("SearchParameters")) - .and_then(|sp| sp.get("properties")) - .and_then(|p| p.as_mapping()) + .components + .schemas + .get("SearchParameters") + .and_then(|sp| sp.properties.as_ref()) .cloned() // Clone to avoid borrowing issues .ok_or_else(|| "Could not find schema for SearchParameters".to_string())?; // Navigate to the operation's parameters list let params = doc - .get_mut("paths") - .and_then(|p| p.get_mut("/collections/{collectionName}/documents/search")) + .paths + .get_mut("/collections/{collectionName}/documents/search") .and_then(|p| p.get_mut("get")) - .and_then(|op| op.get_mut("parameters")) - .and_then(|params| params.as_sequence_mut()) + .and_then(|op| op.parameters.as_mut()) .ok_or_else(|| { "Could not find parameters for /collections/{collectionName}/documents/search" .to_string() @@ -193,58 +412,60 @@ fn unwrap_search_parameters(doc: &mut Mapping) -> Result<(), String> { // Find and remove the old parameter object. let param_index = params .iter() - .position(|p| p.get("name").and_then(|n| n.as_str()) == Some("searchParameters")) + .position(|p| p.name.as_deref() == Some("searchParameters")) .ok_or_else(|| "searchParameters object not found".to_string())?; params.remove(param_index); // Add the new individual parameters. for (key, value) in search_params_props { - let mut new_param = Mapping::new(); - new_param.insert("name".into(), key.clone()); - new_param.insert("in".into(), "query".into()); - new_param.insert("schema".into(), value.clone()); - params.push(new_param.into()); + let new_param = OpenAPIParameter { + name: Some(key), + r#in: Some("query".to_owned()), + schema: Some(value), + ..Default::default() + }; + params.push(new_param); } Ok(()) } /// Special handler for unwrapping multi-search parameters from `components/schemas`. -fn unwrap_multi_search_parameters(doc: &mut Mapping) -> Result<(), String> { +fn unwrap_multi_search_parameters(doc: &mut OpenAPI) -> Result<(), String> { println!("- Unwrapping multiSearchParameters..."); // Get the definition of MultiSearchParameters from components - let search_params_props: Mapping = doc - .get("components") - .and_then(|c| c.get("schemas")) - .and_then(|s| s.get("MultiSearchParameters")) - .and_then(|sp| sp.get("properties")) - .and_then(|p| p.as_mapping()) + let search_params_props = doc + .components + .schemas + .get("MultiSearchParameters") + .and_then(|sp| sp.properties.as_ref()) .cloned() .ok_or_else(|| "Could not find schema for MultiSearchParameters".to_string())?; // Navigate to the operation's parameters list let params = doc - .get_mut("paths") - .and_then(|p| p.get_mut("/multi_search")) + .paths + .get_mut("/multi_search") .and_then(|p| p.get_mut("post")) - .and_then(|op| op.get_mut("parameters")) - .and_then(|params| params.as_sequence_mut()) + .and_then(|op| op.parameters.as_mut()) .ok_or_else(|| "Could not find parameters for /multi_search".to_string())?; // Find and remove the old parameter object. let param_index = params .iter() - .position(|p| p.get("name").and_then(|n| n.as_str()) == Some("multiSearchParameters")) + .position(|p| p.name.as_deref() == Some("multiSearchParameters")) .ok_or_else(|| "multiSearchParameters object not found".to_string())?; params.remove(param_index); // Add the new individual parameters. for (key, value) in search_params_props { - let mut new_param = Mapping::new(); - new_param.insert("name".into(), key.clone()); - new_param.insert("in".into(), "query".into()); - new_param.insert("schema".into(), value.clone()); - params.push(new_param.into()); + let new_param = OpenAPIParameter { + name: Some(key), + r#in: Some("query".to_owned()), + schema: Some(value), + ..Default::default() + }; + params.push(new_param); } Ok(()) diff --git a/xtask/src/vendor_attributes.rs b/xtask/src/vendor_attributes.rs index a625f2bf..132d8183 100644 --- a/xtask/src/vendor_attributes.rs +++ b/xtask/src/vendor_attributes.rs @@ -1,161 +1,33 @@ -use serde_yaml::{Mapping, Value}; - -/// Where to apply a vendor (x-*) attribute. -pub enum VendorLocation<'a> { - Schema(&'a str), - SchemaField { - schema: &'a str, - field: &'a str, - }, - Operation { - path: &'a str, - method: &'a str, - }, - OperationField { - path: &'a str, - method: &'a str, - field: &'a str, - }, -} +use crate::preprocess_openapi::{OpenAPI, OpenAPIProperty}; +use indexmap::IndexMap; +use serde_yaml::Value; /// Main helper struct that holds a mutable borrow of the OpenAPI root mapping. pub struct VendorAttributes<'a> { - doc: &'a mut Mapping, + pub doc: &'a mut OpenAPI, } impl<'a> VendorAttributes<'a> { - pub fn new(doc: &'a mut Mapping) -> Self { + pub fn new(doc: &'a mut OpenAPI) -> Self { Self { doc } } - // internal helpers - - fn traverse_value_mut(&mut self, keys: &[&str]) -> Option<&mut Value> { - if keys.is_empty() { - return None; - } - let mut cur: Option<&mut Value> = self.doc.get_mut(keys[0]); - for k in &keys[1..] { - cur = cur.and_then(|v| v.get_mut(k)); - } - cur - } - - fn get_map_mut(&mut self, keys: &[&str]) -> Result<&mut Mapping, String> { - self.traverse_value_mut(keys) - .and_then(|v| v.as_mapping_mut()) - .ok_or_else(|| format!("expected mapping at path: {}", keys.join("."))) - } - - #[inline] - fn insert_into_map(map: &mut Mapping, attr: &str, val: Value) { - map.insert(Value::String(attr.to_owned()), val); - } - - fn set_attr( - &mut self, - location: VendorLocation<'_>, - attr: &str, - val: Value, - ) -> Result<&mut Self, String> { - match location { - VendorLocation::Schema(schema_name) => { - let map = self.get_map_mut(&["components", "schemas", schema_name])?; - Self::insert_into_map(map, attr, val); - Ok(self) - } - VendorLocation::SchemaField { schema, field } => { - let props_map = self - .get_map_mut(&["components", "schemas", schema, "properties"]) - .map_err(|_| format!("schema '{}' has no properties mapping", schema))?; - - let prop_key = Value::String(field.to_string()); - match props_map.get_mut(&prop_key) { - Some(existing_val) => { - if let Some(field_map) = existing_val.as_mapping_mut() { - Self::insert_into_map(field_map, attr, val); - Ok(self) - } else { - Err(format!( - "property '{}' in schema '{}' exists but is not a mapping; cannot set '{}'", - field, schema, attr - )) - } - } - None => { - let mut new_field_map = Mapping::new(); - new_field_map.insert(Value::String(attr.to_string()), val); - props_map.insert(prop_key, Value::Mapping(new_field_map)); - Ok(self) - } - } - } - VendorLocation::Operation { path, method } => { - let op_map = self - .get_map_mut(&["paths", path, method]) - .map_err(|_| format!("operation not found: {} {}", method, path))?; - Self::insert_into_map(op_map, attr, val); - Ok(self) - } - VendorLocation::OperationField { - path, - method, - field, - } => { - let field_map = - self.get_map_mut(&["paths", path, method, field]) - .map_err(|_| { - format!("operation field not found: {} {} {}", method, path, field) - })?; - Self::insert_into_map(field_map, attr, val); - Ok(self) - } - } - } - - pub fn schemas_mark_owned_data(&mut self) -> Result<&mut Self, String> { - let map = self.get_map_mut(&["components", "schemas"])?; - for (schema_n, schema_m) in map { - let (Value::String(schema_name), Value::Mapping(schema_map)) = (schema_n, schema_m) - else { - continue; - }; - if schema_name.ends_with("Response") - || schema_name.contains("Result") - || schema_name.ends_with("Status") - || schema_name.ends_with("Hit") - || ["SearchRequestParams", "SearchHighlight"].contains(&schema_name.as_str()) - { - Self::insert_into_map(schema_map, "x-rust-is-owned-data", Value::Bool(true)); - if let Some(Value::Mapping(props)) = schema_map.get_mut("properties") { - for (_, prop_m) in props { - let Value::Mapping(prop_map) = prop_m else { - continue; - }; - let Some(Value::String(typ)) = prop_map.get("type") else { - continue; - }; - if typ != "object" { - continue; - } - Self::insert_into_map(prop_map, "x-rust-is-owned-data", Value::Bool(true)); - } - } - } - } - Ok(self) - } - pub fn schema_generic_parameter( &mut self, items: [(&str, &str); N], ) -> Result<&mut Self, String> { - for (schema, generic) in items { - self.set_attr( - VendorLocation::Schema(schema), - "x-rust-generic-parameter", + for (schema_name, generic) in items { + let map = self + .doc + .components + .schemas + .get_mut(schema_name) + .ok_or_else(|| format!("schema not found: {schema_name}"))?; + + map.extra.insert( + "x-rust-generic-parameter".to_owned(), Value::String(generic.into()), - )?; + ); } Ok(self) } @@ -164,12 +36,16 @@ impl<'a> VendorAttributes<'a> { &mut self, schemas: [&str; N], ) -> Result<&mut Self, String> { - for schema in schemas { - self.set_attr( - VendorLocation::Schema(schema), - "x-rust-builder", - Value::Bool(true), - )?; + for schema_name in schemas { + let map = self + .doc + .components + .schemas + .get_mut(schema_name) + .ok_or_else(|| format!("schema not found: {schema_name}"))?; + + map.extra + .insert("x-rust-builder".to_owned(), Value::Bool(true)); } Ok(self) } @@ -180,11 +56,32 @@ impl<'a> VendorAttributes<'a> { overrides: [(&str, &str); N], ) -> Result<&mut Self, String> { for (field, rust_type) in overrides { - self.set_attr( - VendorLocation::SchemaField { schema, field }, - "x-rust-type", - Value::String(rust_type.into()), - )?; + let props_map = self + .doc + .components + .schemas + .get_mut(schema) + .ok_or_else(|| format!("schema not found: {schema}"))? + .properties + .as_mut() + .ok_or_else(|| format!("No properties in schema: {schema}"))?; + match props_map.get_mut(field) { + Some(existing_val) => { + existing_val + .extra + .insert("x-rust-type".to_owned(), Value::String(rust_type.into())); + } + None => { + let new_field_map = OpenAPIProperty { + extra: IndexMap::from([( + "x-rust-type".to_owned(), + Value::String(rust_type.into()), + )]), + ..Default::default() + }; + props_map.insert(field.to_owned(), new_field_map); + } + } } Ok(self) } @@ -194,7 +91,6 @@ impl<'a> VendorAttributes<'a> { vendor: self, path, method, - error: None, } } } @@ -203,83 +99,68 @@ pub struct OperationContext<'a, 'b> { vendor: &'b mut VendorAttributes<'a>, path: &'b str, method: &'b str, - error: Option, } impl<'a, 'b> OperationContext<'a, 'b> { - fn try_set(&mut self, attr: &str, val: Value) { - if self.error.is_some() { - return; - } - if let Err(e) = self.vendor.set_attr( - VendorLocation::Operation { - path: self.path, - method: self.method, - }, - attr, - val, - ) { - self.error = Some(e); - } + fn try_set(&mut self, attr: &str, val: Value) -> Result<&mut Self, String> { + let method = self + .vendor + .doc + .paths + .get_mut(self.path) + .ok_or_else(|| format!("operation path not found: {}", self.path))? + .get_mut(self.method) + .ok_or_else(|| format!("operation method not found: {}.{}", self.path, self.method))?; + method.extra.insert(attr.to_owned(), val); + Ok(self) } - fn try_set_field(&mut self, field: &str, attr: &str, val: Value) { - if self.error.is_some() { - return; - } - if let Err(e) = self.vendor.set_attr( - VendorLocation::OperationField { - path: self.path, - method: self.method, - field, - }, - attr, - val, - ) { - self.error = Some(e); - } + fn try_set_request_body(&mut self, attr: &str, val: Value) -> Result<&mut Self, String> { + let method = &mut self + .vendor + .doc + .paths + .get_mut(self.path) + .ok_or_else(|| format!("operation path not found: {}", self.path))? + .get_mut(self.method) + .ok_or_else(|| format!("operation method not found: {}.{}", self.path, self.method))? + .request_body; + let method = match method { + Some(v) => v, + None => { + *method = Some(Default::default()); + method.as_mut().unwrap() + } + }; + method.extra.insert(attr.to_owned(), val); + Ok(self) } - pub fn generic_parameter(mut self, generic: &str) -> Self { - self.try_set("x-rust-generic-parameter", Value::String(generic.into())); - self + pub fn generic_parameter(&mut self, generic: &str) -> Result<&mut Self, String> { + self.try_set("x-rust-generic-parameter", Value::String(generic.into())) } - pub fn params_generic_parameter(mut self, generic: &str) -> Self { - self.try_set_field( - "requestBody", + pub fn params_generic_parameter(&mut self, generic: &str) -> Result<&mut Self, String> { + self.try_set_request_body( "x-rust-params-generic-parameter", Value::String(generic.into()), - ); - self + ) } - pub fn return_type(mut self, typ: &str) -> Self { - self.try_set("x-rust-return-type", Value::String(typ.into())); - self + pub fn return_type(&mut self, typ: &str) -> Result<&mut Self, String> { + self.try_set("x-rust-return-type", Value::String(typ.into())) } - pub fn request_type(mut self, typ: &str) -> Self { - self.try_set_field("requestBody", "x-rust-type", Value::String(typ.into())); - self + pub fn request_type(&mut self, typ: &str) -> Result<&mut Self, String> { + self.try_set_request_body("x-rust-type", Value::String(typ.into())) } - pub fn body_is_raw_text(mut self) -> Self { - self.try_set("x-rust-body-is-raw-text", Value::Bool(true)); - self + pub fn body_is_raw_text(&mut self) -> Result<&mut Self, String> { + self.try_set("x-rust-body-is-raw-text", Value::Bool(true)) } /// Indicate that the response supports plain text besides JSON - pub fn supports_plain_text(mut self) -> Self { - self.try_set("x-supports-plain-text", Value::Bool(true)); - self - } - - /// Return to VendorAttributes if no errors, or propagate the first error - pub fn done(self) -> Result<&'b mut VendorAttributes<'a>, String> { - match self.error { - Some(err) => Err(err), - None => Ok(self.vendor), - } + pub fn supports_plain_text(&mut self) -> Result<&mut Self, String> { + self.try_set("x-supports-plain-text", Value::Bool(true)) } } From d59a4ab68548567d3b4fc3afc6657b113dcfbf0c Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Wed, 12 Nov 2025 23:38:35 +0000 Subject: [PATCH 11/17] Errors no lifetimes --- .../reqwest/api.mustache | 20 ++--- .../reqwest/api_mod.mustache | 8 -- typesense/src/client/alias.rs | 6 +- typesense/src/client/aliases.rs | 9 +- typesense/src/client/collection/document.rs | 6 +- typesense/src/client/collection/documents.rs | 19 ++-- typesense/src/client/collection/mod.rs | 14 ++- typesense/src/client/collections.rs | 12 +-- typesense/src/client/conversations/model.rs | 6 +- typesense/src/client/conversations/models.rs | 4 +- typesense/src/client/key.rs | 7 +- typesense/src/client/keys.rs | 4 +- typesense/src/client/multi_search.rs | 4 +- typesense/src/client/operations.rs | 31 +++---- typesense/src/client/preset.rs | 6 +- typesense/src/client/presets.rs | 8 +- typesense/src/client/stemming/dictionaries.rs | 4 +- typesense/src/client/stemming/dictionary.rs | 6 +- typesense/src/client/stopword.rs | 4 +- typesense/src/client/stopwords.rs | 8 +- typesense_codegen/src/apis/analytics_api.rs | 68 +++++++-------- typesense_codegen/src/apis/collections_api.rs | 74 ++++++++-------- .../src/apis/conversations_api.rs | 40 ++++----- .../src/apis/curation_sets_api.rs | 63 +++++++------- typesense_codegen/src/apis/debug_api.rs | 6 +- typesense_codegen/src/apis/documents_api.rs | 86 +++++++++---------- typesense_codegen/src/apis/health_api.rs | 6 +- typesense_codegen/src/apis/keys_api.rs | 34 ++++---- typesense_codegen/src/apis/mod.rs | 8 -- .../src/apis/nl_search_models_api.rs | 41 +++++---- typesense_codegen/src/apis/operations_api.rs | 49 ++++++----- typesense_codegen/src/apis/presets_api.rs | 30 +++---- typesense_codegen/src/apis/stemming_api.rs | 22 ++--- typesense_codegen/src/apis/stopwords_api.rs | 35 ++++---- typesense_codegen/src/apis/synonyms_api.rs | 62 ++++++------- 35 files changed, 373 insertions(+), 437 deletions(-) diff --git a/openapi-generator-template/reqwest/api.mustache b/openapi-generator-template/reqwest/api.mustache index a819c242..2d47f00f 100644 --- a/openapi-generator-template/reqwest/api.mustache +++ b/openapi-generator-template/reqwest/api.mustache @@ -61,16 +61,16 @@ pub struct {{{operationIdCamelCase}}}Params<'p{{! /// struct for typed successes of method [`{{operationId}}`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum {{{operationIdCamelCase}}}Success<'a> { +pub enum {{{operationIdCamelCase}}}Success { {{#responses}} {{#is2xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'a>{{/isEnum}}), + Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'static>{{/isEnum}}), {{/is2xx}} {{#is3xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'a>{{/isEnum}}), + Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'static>{{/isEnum}}), {{/is3xx}} {{/responses}} - UnknownValue(super::Unknown<'a>), + UnknownValue(serde_json::Value), } {{/operation}} @@ -81,19 +81,19 @@ pub enum {{{operationIdCamelCase}}}Success<'a> { /// struct for typed errors of method [`{{operationId}}`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum {{{operationIdCamelCase}}}Error<'a> { +pub enum {{{operationIdCamelCase}}}Error { {{#responses}} {{#is4xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'a>{{/isEnum}}), + Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'static>{{/isEnum}}), {{/is4xx}} {{#is5xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'a>{{/isEnum}}), + Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'static>{{/isEnum}}), {{/is5xx}} {{#isDefault}} - DefaultResponse({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'a>{{/isEnum}}), + DefaultResponse({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'static>{{/isEnum}}), {{/isDefault}} {{/responses}} - UnknownValue(super::Unknown<'a>), + UnknownValue(serde_json::Value), } {{/operation}} @@ -118,7 +118,7 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}{{#vendorExtensi }}{{^returnType}}(){{/returnType}}{{! }}{{#isArray}}Vec<{{#returnProperty.items}}{{{dataType}}}{{#isModel}}<'static>{{/isModel}}{{/returnProperty.items}}>{{/isArray}}{{! }}{{^isArray}}{{#returnProperty}}{{{dataType}}}{{#isModel}}<'static>{{/isModel}}{{/returnProperty}}{{! -}}{{/isArray}}{{/supportMultipleResponses}}{{/isResponseFile}}{{/vendorExtensions.x-rust-return-type}}, Error<{{{operationIdCamelCase}}}Error<'static>>> { +}}{{/isArray}}{{/supportMultipleResponses}}{{/isResponseFile}}{{/vendorExtensions.x-rust-return-type}}, Error<{{{operationIdCamelCase}}}Error>> { {{/vendorExtensions.x-group-parameters}} let uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode(&{{/isString}}{{{vendorExtensions.x-rust-param-identifier}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isArray}}.join(",").as_ref(){{/isArray}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}.to_string(){{/isContainer}}{{/isPrimitiveType}}{{/isUuid}}{{/isString}}{{#isString}}){{/isString}}{{/pathParams}}); let mut req_builder = configuration.client.request(reqwest::Method::{{{httpMethod}}}, &uri_str); diff --git a/openapi-generator-template/reqwest/api_mod.mustache b/openapi-generator-template/reqwest/api_mod.mustache index d74f558c..9e9a2fe8 100644 --- a/openapi-generator-template/reqwest/api_mod.mustache +++ b/openapi-generator-template/reqwest/api_mod.mustache @@ -1,13 +1,5 @@ use ::std::{error, fmt}; -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] -#[serde(transparent)] -pub struct Unknown<'a> { - pub value: serde_json::Value, - #[serde(skip)] - pub _phantom: core::marker::PhantomData<&'a ()>, -} - {{#withAWSV4Signature}} use aws_sigv4; {{/withAWSV4Signature}} diff --git a/typesense/src/client/alias.rs b/typesense/src/client/alias.rs index 1b41112b..436180be 100644 --- a/typesense/src/client/alias.rs +++ b/typesense/src/client/alias.rs @@ -23,8 +23,7 @@ impl<'a> Alias<'a> { /// Retrieves the details of a collection alias, including the collection it points to. pub async fn retrieve( &self, - ) -> Result, Error>> - { + ) -> Result, Error> { let params = collections_api::GetAliasParams { alias_name: self.alias_name.into(), _phantom: core::marker::PhantomData, @@ -36,8 +35,7 @@ impl<'a> Alias<'a> { /// Deletes a collection alias. pub async fn delete( &self, - ) -> Result, Error>> - { + ) -> Result, Error> { let params = collections_api::DeleteAliasParams { alias_name: self.alias_name.into(), _phantom: core::marker::PhantomData, diff --git a/typesense/src/client/aliases.rs b/typesense/src/client/aliases.rs index 35afcc96..f7a33d5b 100644 --- a/typesense/src/client/aliases.rs +++ b/typesense/src/client/aliases.rs @@ -33,8 +33,7 @@ impl<'a> Aliases<'a> { &self, alias_name: impl Into>, schema: models::CollectionAliasSchema<'_>, - ) -> Result, Error>> - { + ) -> Result, Error> { let params = collections_api::UpsertAliasParams { alias_name: alias_name.into(), collection_alias_schema: Some(schema), @@ -46,10 +45,8 @@ impl<'a> Aliases<'a> { /// Lists all aliases and the corresponding collections that they map to. pub async fn retrieve( &self, - ) -> Result< - models::CollectionAliasesResponse<'static>, - Error>, - > { + ) -> Result, Error> + { execute_wrapper!(self, collections_api::get_aliases) } } diff --git a/typesense/src/client/collection/document.rs b/typesense/src/client/collection/document.rs index b6c97201..afddd392 100644 --- a/typesense/src/client/collection/document.rs +++ b/typesense/src/client/collection/document.rs @@ -48,7 +48,7 @@ where /// /// # Returns /// A `Result` containing the strongly-typed document `D` if successful. - pub async fn retrieve(&self) -> Result>> { + pub async fn retrieve(&self) -> Result> { let params = documents_api::GetDocumentParams { collection_name: self.collection_name.into(), document_id: self.document_id.as_ref().into(), @@ -66,7 +66,7 @@ where /// /// # Returns /// A `Result` containing the deleted document deserialized into `D`. - pub async fn delete(&self) -> Result>> { + pub async fn delete(&self) -> Result> { let params = documents_api::DeleteDocumentParams { collection_name: self.collection_name.into(), document_id: self.document_id.as_ref().into(), @@ -130,7 +130,7 @@ where &self, partial_document: &D::Partial, params: Option, - ) -> Result>> { + ) -> Result> { let params = documents_api::UpdateDocumentParams { collection_name: self.collection_name.into(), document_id: self.document_id.as_ref().into(), diff --git a/typesense/src/client/collection/documents.rs b/typesense/src/client/collection/documents.rs index 861bc973..fc0d67c0 100644 --- a/typesense/src/client/collection/documents.rs +++ b/typesense/src/client/collection/documents.rs @@ -55,7 +55,7 @@ where document: serde_json::Value, action: &str, params: Option, - ) -> Result>> { + ) -> Result> { let params = documents_api::IndexDocumentParams { collection_name: self.collection_name.into(), body: document, @@ -79,7 +79,7 @@ where &self, documents_jsonl: impl Into>, params: ImportDocumentsParameters<'_>, - ) -> Result>> { + ) -> Result> { let params = documents_api::ImportDocumentsParams { body: documents_jsonl.into(), collection_name: self.collection_name.into(), @@ -102,7 +102,7 @@ where pub async fn export_jsonl( &self, params: ExportDocumentsParameters<'_>, - ) -> Result>> { + ) -> Result> { let params = documents_api::ExportDocumentsParams { collection_name: self.collection_name.into(), exclude_fields: params.exclude_fields, @@ -121,8 +121,8 @@ where &self, params: DeleteDocumentsParameters<'_>, ) -> Result< - raw_models::DeleteDocuments200Response<'_>, - Error>, + raw_models::DeleteDocuments200Response<'static>, + Error, > { let params = documents_api::DeleteDocumentsParams { collection_name: self.collection_name.into(), @@ -143,8 +143,7 @@ where pub async fn search( &self, params: raw_models::SearchParameters<'_>, - ) -> Result, Error>> - { + ) -> Result, Error> { let search_params = documents_api::SearchCollectionParams { collection_name: self.collection_name.into(), @@ -243,7 +242,7 @@ where &self, document: &D, params: Option, - ) -> Result>> { + ) -> Result> { let doc_value = serde_json::to_value(document)?; let result_value = self.index(doc_value, "create", params).await?; serde_json::from_value(result_value).map_err(Error::from) @@ -261,7 +260,7 @@ where &self, document: &D, params: Option, - ) -> Result>> { + ) -> Result> { let doc_value = serde_json::to_value(document)?; let result_value = self.index(doc_value, "upsert", params).await?; serde_json::from_value(result_value).map_err(Error::from) @@ -278,7 +277,7 @@ where params: UpdateDocumentsParameters<'_>, ) -> Result< raw_models::UpdateDocuments200Response<'static>, - Error>, + Error, > { let params = documents_api::UpdateDocumentsParams { collection_name: self.collection_name.into(), diff --git a/typesense/src/client/collection/mod.rs b/typesense/src/client/collection/mod.rs index a11ce461..aa9b75b7 100644 --- a/typesense/src/client/collection/mod.rs +++ b/typesense/src/client/collection/mod.rs @@ -55,10 +55,8 @@ where #[inline] pub async fn retrieve( &self, - ) -> Result< - models::CollectionResponse<'static>, - Error>, - > { + ) -> Result, Error> + { let params = collections_api::GetCollectionParams { collection_name: self.collection_name.as_ref().into(), _phantom: core::marker::PhantomData, @@ -70,10 +68,8 @@ where #[inline] pub async fn delete( &self, - ) -> Result< - models::CollectionResponse<'static>, - Error>, - > { + ) -> Result, Error> + { let params = collections_api::DeleteCollectionParams { collection_name: self.collection_name.as_ref().into(), _phantom: core::marker::PhantomData, @@ -91,7 +87,7 @@ where update_schema: models::CollectionUpdateSchema<'_>, ) -> Result< models::CollectionUpdateSchema<'static>, - Error>, + Error, > { let params = collections_api::UpdateCollectionParams { collection_name: self.collection_name.as_ref().into(), diff --git a/typesense/src/client/collections.rs b/typesense/src/client/collections.rs index e9a07679..6fe18b7b 100644 --- a/typesense/src/client/collections.rs +++ b/typesense/src/client/collections.rs @@ -29,10 +29,8 @@ impl<'c> Collections<'c> { pub async fn create( &self, schema: models::CollectionSchema<'_>, - ) -> Result< - models::CollectionResponse<'static>, - Error>, - > { + ) -> Result, Error> + { let params = collections_api::CreateCollectionParams { collection_schema: schema, _phantom: core::marker::PhantomData, @@ -44,10 +42,8 @@ impl<'c> Collections<'c> { pub async fn retrieve( &self, params: GetCollectionsParameters<'_>, - ) -> Result< - Vec>, - Error>, - > { + ) -> Result>, Error> + { let params = GetCollectionsParams { exclude_fields: params.exclude_fields, limit: params.limit, diff --git a/typesense/src/client/conversations/model.rs b/typesense/src/client/conversations/model.rs index d8b1f2ab..ce90cdab 100644 --- a/typesense/src/client/conversations/model.rs +++ b/typesense/src/client/conversations/model.rs @@ -25,7 +25,7 @@ impl<'a> Model<'a> { &self, ) -> Result< models::ConversationModelSchema<'static>, - Error>, + Error, > { let params = conversations_api::RetrieveConversationModelParams { model_id: self.model_id.into(), @@ -43,7 +43,7 @@ impl<'a> Model<'a> { schema: models::ConversationModelUpdateSchema<'_>, ) -> Result< models::ConversationModelSchema<'static>, - Error>, + Error, > { let params = conversations_api::UpdateConversationModelParams { model_id: self.model_id.into(), @@ -58,7 +58,7 @@ impl<'a> Model<'a> { &self, ) -> Result< models::ConversationModelSchema<'static>, - Error>, + Error, > { let params = conversations_api::DeleteConversationModelParams { model_id: self.model_id.into(), diff --git a/typesense/src/client/conversations/models.rs b/typesense/src/client/conversations/models.rs index 01f5511a..1a7aad70 100644 --- a/typesense/src/client/conversations/models.rs +++ b/typesense/src/client/conversations/models.rs @@ -28,7 +28,7 @@ impl<'a> Models<'a> { schema: models::ConversationModelCreateSchema<'_>, ) -> Result< models::ConversationModelSchema<'static>, - Error>, + Error, > { let params = conversations_api::CreateConversationModelParams { conversation_model_create_schema: schema, @@ -42,7 +42,7 @@ impl<'a> Models<'a> { &self, ) -> Result< Vec>, - Error>, + Error, > { execute_wrapper!(self, conversations_api::retrieve_all_conversation_models) } diff --git a/typesense/src/client/key.rs b/typesense/src/client/key.rs index 1284c02a..e64a6365 100644 --- a/typesense/src/client/key.rs +++ b/typesense/src/client/key.rs @@ -25,9 +25,7 @@ impl<'c> Key<'c> { /// For security reasons, this endpoint only returns the key prefix and metadata, /// not the full key value. #[inline] - pub async fn retrieve( - &self, - ) -> Result, Error>> { + pub async fn retrieve(&self) -> Result, Error> { let params = keys_api::GetKeyParams { key_id: self.key_id, _phantom: core::marker::PhantomData, @@ -39,8 +37,7 @@ impl<'c> Key<'c> { #[inline] pub async fn delete( &self, - ) -> Result, Error>> - { + ) -> Result, Error> { let params = keys_api::DeleteKeyParams { key_id: self.key_id, _phantom: core::marker::PhantomData, diff --git a/typesense/src/client/keys.rs b/typesense/src/client/keys.rs index 674d5404..77eb9aaa 100644 --- a/typesense/src/client/keys.rs +++ b/typesense/src/client/keys.rs @@ -36,7 +36,7 @@ impl<'c> Keys<'c> { pub async fn create( &self, schema: models::ApiKeySchema<'_>, - ) -> Result, Error>> { + ) -> Result, Error> { let params = keys_api::CreateKeyParams { api_key_schema: Some(schema), _phantom: core::marker::PhantomData, @@ -48,7 +48,7 @@ impl<'c> Keys<'c> { #[inline] pub async fn retrieve( &self, - ) -> Result, Error>> { + ) -> Result, Error> { execute_wrapper!(self, keys_api::get_keys) } diff --git a/typesense/src/client/multi_search.rs b/typesense/src/client/multi_search.rs index e5f6c92e..1ae3c770 100644 --- a/typesense/src/client/multi_search.rs +++ b/typesense/src/client/multi_search.rs @@ -116,7 +116,7 @@ impl<'c> MultiSearch<'c> { common_search_params: raw_models::MultiSearchParameters<'_>, ) -> Result< raw_models::MultiSearchResult<'static, serde_json::Value>, - Error>, + Error, > { let request_body = raw_models::MultiSearchSearchesParameter { searches: search_requests.searches, @@ -253,7 +253,7 @@ impl<'c> MultiSearch<'c> { &self, search_requests: MultiSearchBody<'_>, common_search_params: raw_models::MultiSearchParameters<'_>, - ) -> Result, Error>> { + ) -> Result, Error> { // Explicitly set `union: true` for the request body let request_body = raw_models::MultiSearchSearchesParameter { union: Some(true), diff --git a/typesense/src/client/operations.rs b/typesense/src/client/operations.rs index 2f9f85f3..48992f06 100644 --- a/typesense/src/client/operations.rs +++ b/typesense/src/client/operations.rs @@ -30,7 +30,7 @@ impl<'a> Operations<'a> { /// Docs: pub async fn debug( &self, - ) -> Result, Error>> { + ) -> Result, Error> { execute_wrapper!(self, debug_api::debug) } @@ -40,7 +40,7 @@ impl<'a> Operations<'a> { /// Docs: pub async fn health( &self, - ) -> Result, Error>> { + ) -> Result, Error> { execute_wrapper!(self, health_api::health) } @@ -74,7 +74,7 @@ impl<'a> Operations<'a> { /// Docs: pub async fn retrieve_metrics( &self, - ) -> Result>> { + ) -> Result> { execute_wrapper!(self, operations_api::retrieve_metrics) } @@ -99,10 +99,8 @@ impl<'a> Operations<'a> { /// Docs: pub async fn retrieve_api_stats( &self, - ) -> Result< - models::ApiStatsResponse<'static>, - Error>, - > { + ) -> Result, Error> + { execute_wrapper!(self, operations_api::retrieve_api_stats) } @@ -113,8 +111,7 @@ impl<'a> Operations<'a> { pub async fn take_snapshot( &self, params: operations_api::TakeSnapshotParams<'_>, - ) -> Result, Error>> - { + ) -> Result, Error> { execute_wrapper!(self, operations_api::take_snapshot, params) } @@ -124,7 +121,7 @@ impl<'a> Operations<'a> { /// Docs: pub async fn vote( &self, - ) -> Result, Error>> { + ) -> Result, Error> { execute_wrapper!(self, operations_api::vote) } @@ -135,7 +132,7 @@ impl<'a> Operations<'a> { &self, ) -> Result< Option>>, - Error>, + Error, > { execute_wrapper!(self, operations_api::get_schema_changes) } @@ -146,8 +143,7 @@ impl<'a> Operations<'a> { /// Docs: pub async fn compact_db( &self, - ) -> Result, Error>> - { + ) -> Result, Error> { execute_wrapper!(self, operations_api::compact_db) } @@ -156,8 +152,7 @@ impl<'a> Operations<'a> { /// Docs: pub async fn clear_cache( &self, - ) -> Result, Error>> - { + ) -> Result, Error> { execute_wrapper!(self, operations_api::clear_cache) } @@ -168,10 +163,8 @@ impl<'a> Operations<'a> { pub async fn toggle_slow_request_log( &self, slow_requests_threshold_ms: i32, - ) -> Result< - models::SuccessStatus<'static>, - Error>, - > { + ) -> Result, Error> + { let params = operations_api::ToggleSlowRequestLogParams { toggle_slow_request_log_request: Some(models::ToggleSlowRequestLogRequest { log_slow_requests_time_ms: slow_requests_threshold_ms, diff --git a/typesense/src/client/preset.rs b/typesense/src/client/preset.rs index 832c4fd7..6de356ae 100644 --- a/typesense/src/client/preset.rs +++ b/typesense/src/client/preset.rs @@ -23,8 +23,7 @@ impl<'a> Preset<'a> { /// Retrieves the details of a preset, given its Id. pub async fn retrieve( &self, - ) -> Result, Error>> - { + ) -> Result, Error> { let params = presets_api::RetrievePresetParams { preset_id: self.preset_id.into(), _phantom: core::marker::PhantomData, @@ -35,8 +34,7 @@ impl<'a> Preset<'a> { /// Permanently deletes a preset, given its Id. pub async fn delete( &self, - ) -> Result, Error>> - { + ) -> Result, Error> { let params = presets_api::DeletePresetParams { preset_id: self.preset_id.into(), _phantom: core::marker::PhantomData, diff --git a/typesense/src/client/presets.rs b/typesense/src/client/presets.rs index d14eb1fe..2e4e5762 100644 --- a/typesense/src/client/presets.rs +++ b/typesense/src/client/presets.rs @@ -25,10 +25,8 @@ impl<'a> Presets<'a> { /// Retrieves the details of all presets. pub async fn retrieve( &self, - ) -> Result< - models::PresetsRetrieveSchema<'static>, - Error>, - > { + ) -> Result, Error> + { execute_wrapper!(self, presets_api::retrieve_all_presets) } @@ -41,7 +39,7 @@ impl<'a> Presets<'a> { &self, preset_id: impl Into>, schema: models::PresetUpsertSchema<'_>, - ) -> Result, Error>> { + ) -> Result, Error> { let params = presets_api::UpsertPresetParams { preset_id: preset_id.into(), preset_upsert_schema: schema, diff --git a/typesense/src/client/stemming/dictionaries.rs b/typesense/src/client/stemming/dictionaries.rs index a81bfe7d..f43c8a4f 100644 --- a/typesense/src/client/stemming/dictionaries.rs +++ b/typesense/src/client/stemming/dictionaries.rs @@ -34,7 +34,7 @@ impl<'a> Dictionaries<'a> { &self, dictionary_id: impl Into>, dictionary_jsonl: impl Into>, - ) -> Result>> { + ) -> Result> { let params = stemming_api::ImportStemmingDictionaryParams { id: dictionary_id.into(), body: dictionary_jsonl.into(), @@ -48,7 +48,7 @@ impl<'a> Dictionaries<'a> { &self, ) -> Result< models::ListStemmingDictionaries200Response<'static>, - Error>, + Error, > { execute_wrapper!(self, stemming_api::list_stemming_dictionaries) } diff --git a/typesense/src/client/stemming/dictionary.rs b/typesense/src/client/stemming/dictionary.rs index c580f1ba..2ccc41cd 100644 --- a/typesense/src/client/stemming/dictionary.rs +++ b/typesense/src/client/stemming/dictionary.rs @@ -29,10 +29,8 @@ impl<'a> Dictionary<'a> { /// Retrieves the details of this specific stemming dictionary. pub async fn retrieve( &self, - ) -> Result< - models::StemmingDictionary<'static>, - Error>, - > { + ) -> Result, Error> + { let params = stemming_api::GetStemmingDictionaryParams { dictionary_id: self.dictionary_id.into(), _phantom: core::marker::PhantomData, diff --git a/typesense/src/client/stopword.rs b/typesense/src/client/stopword.rs index 64f44955..5fb04e86 100644 --- a/typesense/src/client/stopword.rs +++ b/typesense/src/client/stopword.rs @@ -25,7 +25,7 @@ impl<'a> Stopword<'a> { &self, ) -> Result< models::StopwordsSetRetrieveSchema<'static>, - Error>, + Error, > { let params = stopwords_api::RetrieveStopwordsSetParams { set_id: self.set_id.into(), @@ -39,7 +39,7 @@ impl<'a> Stopword<'a> { &self, ) -> Result< models::DeleteStopwordsSet200Response<'static>, - Error>, + Error, > { let params = stopwords_api::DeleteStopwordsSetParams { set_id: self.set_id.into(), diff --git a/typesense/src/client/stopwords.rs b/typesense/src/client/stopwords.rs index 19550c5c..cc833416 100644 --- a/typesense/src/client/stopwords.rs +++ b/typesense/src/client/stopwords.rs @@ -29,10 +29,8 @@ impl<'a> Stopwords<'a> { &self, set_id: impl Into>, schema: models::StopwordsSetUpsertSchema<'_>, - ) -> Result< - models::StopwordsSetSchema<'static>, - Error>, - > { + ) -> Result, Error> + { let params = stopwords_api::UpsertStopwordsSetParams { set_id: set_id.into(), stopwords_set_upsert_schema: schema, @@ -46,7 +44,7 @@ impl<'a> Stopwords<'a> { &self, ) -> Result< models::StopwordsSetsRetrieveAllSchema<'static>, - Error>, + Error, > { execute_wrapper!(self, stopwords_api::retrieve_stopwords_sets) } diff --git a/typesense_codegen/src/apis/analytics_api.rs b/typesense_codegen/src/apis/analytics_api.rs index fe288b24..c5a83d3f 100644 --- a/typesense_codegen/src/apis/analytics_api.rs +++ b/typesense_codegen/src/apis/analytics_api.rs @@ -78,78 +78,77 @@ pub struct UpsertAnalyticsRuleParams<'p> { /// struct for typed errors of method [`create_analytics_event`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CreateAnalyticsEventError<'a> { - Status400(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum CreateAnalyticsEventError { + Status400(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`create_analytics_rule`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CreateAnalyticsRuleError<'a> { - Status400(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum CreateAnalyticsRuleError { + Status400(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`delete_analytics_rule`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteAnalyticsRuleError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum DeleteAnalyticsRuleError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`flush_analytics`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum FlushAnalyticsError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum FlushAnalyticsError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`get_analytics_events`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetAnalyticsEventsError<'a> { - Status400(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum GetAnalyticsEventsError { + Status400(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`get_analytics_status`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetAnalyticsStatusError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum GetAnalyticsStatusError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_analytics_rule`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveAnalyticsRuleError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum RetrieveAnalyticsRuleError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_analytics_rules`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveAnalyticsRulesError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum RetrieveAnalyticsRulesError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`upsert_analytics_rule`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertAnalyticsRuleError<'a> { - Status400(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum UpsertAnalyticsRuleError { + Status400(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// Submit a single analytics event. The event must correspond to an existing analytics rule by name. pub async fn create_analytics_event( configuration: &configuration::Configuration, params: &CreateAnalyticsEventParams<'_>, -) -> Result, Error>> -{ +) -> Result, Error> { let uri_str = format!("{}/analytics/events", configuration.base_path); let mut req_builder = configuration .client @@ -209,8 +208,7 @@ pub async fn create_analytics_event( pub async fn create_analytics_rule( configuration: &configuration::Configuration, params: &CreateAnalyticsRuleParams<'_>, -) -> Result, Error>> -{ +) -> Result, Error> { let uri_str = format!("{}/analytics/rules", configuration.base_path); let mut req_builder = configuration .client @@ -270,7 +268,7 @@ pub async fn create_analytics_rule( pub async fn delete_analytics_rule( configuration: &configuration::Configuration, params: &DeleteAnalyticsRuleParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/analytics/rules/{ruleName}", configuration.base_path, @@ -332,7 +330,7 @@ pub async fn delete_analytics_rule( /// Triggers a flush of analytics data to persistent storage. pub async fn flush_analytics( configuration: &configuration::Configuration, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/analytics/flush", configuration.base_path); let mut req_builder = configuration .client @@ -391,7 +389,7 @@ pub async fn flush_analytics( pub async fn get_analytics_events( configuration: &configuration::Configuration, params: &GetAnalyticsEventsParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/analytics/events", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -450,7 +448,7 @@ pub async fn get_analytics_events( /// Returns sizes of internal analytics buffers and queues. pub async fn get_analytics_status( configuration: &configuration::Configuration, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/analytics/status", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -507,7 +505,7 @@ pub async fn get_analytics_status( pub async fn retrieve_analytics_rule( configuration: &configuration::Configuration, params: &RetrieveAnalyticsRuleParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/analytics/rules/{ruleName}", configuration.base_path, @@ -568,7 +566,7 @@ pub async fn retrieve_analytics_rule( pub async fn retrieve_analytics_rules( configuration: &configuration::Configuration, params: &RetrieveAnalyticsRulesParams<'_>, -) -> Result>, Error>> { +) -> Result>, Error> { let uri_str = format!("{}/analytics/rules", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -628,7 +626,7 @@ pub async fn retrieve_analytics_rules( pub async fn upsert_analytics_rule( configuration: &configuration::Configuration, params: &UpsertAnalyticsRuleParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/analytics/rules/{ruleName}", configuration.base_path, diff --git a/typesense_codegen/src/apis/collections_api.rs b/typesense_codegen/src/apis/collections_api.rs index 53f96766..a443ff74 100644 --- a/typesense_codegen/src/apis/collections_api.rs +++ b/typesense_codegen/src/apis/collections_api.rs @@ -86,81 +86,81 @@ pub struct UpsertAliasParams<'p> { /// struct for typed errors of method [`create_collection`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CreateCollectionError<'a> { - Status400(models::ApiResponse<'a>), - Status409(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum CreateCollectionError { + Status400(models::ApiResponse<'static>), + Status409(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`delete_alias`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteAliasError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum DeleteAliasError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`delete_collection`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteCollectionError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum DeleteCollectionError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`get_alias`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetAliasError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum GetAliasError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`get_aliases`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetAliasesError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum GetAliasesError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`get_collection`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetCollectionError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum GetCollectionError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`get_collections`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetCollectionsError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum GetCollectionsError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`update_collection`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpdateCollectionError<'a> { - Status400(models::ApiResponse<'a>), - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum UpdateCollectionError { + Status400(models::ApiResponse<'static>), + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`upsert_alias`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertAliasError<'a> { - Status400(models::ApiResponse<'a>), - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum UpsertAliasError { + Status400(models::ApiResponse<'static>), + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// When a collection is created, we give it a name and describe the fields that will be indexed from the documents added to the collection. pub async fn create_collection( configuration: &configuration::Configuration, params: &CreateCollectionParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/collections", configuration.base_path); let mut req_builder = configuration .client @@ -219,7 +219,7 @@ pub async fn create_collection( pub async fn delete_alias( configuration: &configuration::Configuration, params: &DeleteAliasParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/aliases/{aliasName}", configuration.base_path, @@ -282,7 +282,7 @@ pub async fn delete_alias( pub async fn delete_collection( configuration: &configuration::Configuration, params: &DeleteCollectionParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/collections/{collectionName}", configuration.base_path, @@ -345,7 +345,7 @@ pub async fn delete_collection( pub async fn get_alias( configuration: &configuration::Configuration, params: &GetAliasParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/aliases/{aliasName}", configuration.base_path, @@ -405,7 +405,7 @@ pub async fn get_alias( /// List all aliases and the corresponding collections that they map to. pub async fn get_aliases( configuration: &configuration::Configuration, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/aliases", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -462,7 +462,7 @@ pub async fn get_aliases( pub async fn get_collection( configuration: &configuration::Configuration, params: &GetCollectionParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/collections/{collectionName}", configuration.base_path, @@ -523,7 +523,7 @@ pub async fn get_collection( pub async fn get_collections( configuration: &configuration::Configuration, params: &GetCollectionsParams<'_>, -) -> Result>, Error>> { +) -> Result>, Error> { let uri_str = format!("{}/collections", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -589,7 +589,7 @@ pub async fn get_collections( pub async fn update_collection( configuration: &configuration::Configuration, params: &UpdateCollectionParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/collections/{collectionName}", configuration.base_path, @@ -653,7 +653,7 @@ pub async fn update_collection( pub async fn upsert_alias( configuration: &configuration::Configuration, params: &UpsertAliasParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/aliases/{aliasName}", configuration.base_path, diff --git a/typesense_codegen/src/apis/conversations_api.rs b/typesense_codegen/src/apis/conversations_api.rs index 44c338e5..d67c931a 100644 --- a/typesense_codegen/src/apis/conversations_api.rs +++ b/typesense_codegen/src/apis/conversations_api.rs @@ -49,45 +49,44 @@ pub struct UpdateConversationModelParams<'p> { /// struct for typed errors of method [`create_conversation_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CreateConversationModelError<'a> { - Status400(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum CreateConversationModelError { + Status400(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`delete_conversation_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteConversationModelError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum DeleteConversationModelError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_all_conversation_models`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveAllConversationModelsError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum RetrieveAllConversationModelsError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_conversation_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveConversationModelError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum RetrieveConversationModelError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`update_conversation_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpdateConversationModelError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum UpdateConversationModelError { + UnknownValue(serde_json::Value), } /// Create a Conversation Model pub async fn create_conversation_model( configuration: &configuration::Configuration, params: &CreateConversationModelParams<'_>, -) -> Result, Error>> -{ +) -> Result, Error> { let uri_str = format!("{}/conversations/models", configuration.base_path); let mut req_builder = configuration .client @@ -147,8 +146,7 @@ pub async fn create_conversation_model( pub async fn delete_conversation_model( configuration: &configuration::Configuration, params: &DeleteConversationModelParams<'_>, -) -> Result, Error>> -{ +) -> Result, Error> { let uri_str = format!( "{}/conversations/models/{modelId}", configuration.base_path, @@ -210,10 +208,8 @@ pub async fn delete_conversation_model( /// Retrieve all conversation models pub async fn retrieve_all_conversation_models( configuration: &configuration::Configuration, -) -> Result< - Vec>, - Error>, -> { +) -> Result>, Error> +{ let uri_str = format!("{}/conversations/models", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -271,8 +267,7 @@ pub async fn retrieve_all_conversation_models( pub async fn retrieve_conversation_model( configuration: &configuration::Configuration, params: &RetrieveConversationModelParams<'_>, -) -> Result, Error>> -{ +) -> Result, Error> { let uri_str = format!( "{}/conversations/models/{modelId}", configuration.base_path, @@ -333,8 +328,7 @@ pub async fn retrieve_conversation_model( pub async fn update_conversation_model( configuration: &configuration::Configuration, params: &UpdateConversationModelParams<'_>, -) -> Result, Error>> -{ +) -> Result, Error> { let uri_str = format!( "{}/conversations/models/{modelId}", configuration.base_path, diff --git a/typesense_codegen/src/apis/curation_sets_api.rs b/typesense_codegen/src/apis/curation_sets_api.rs index e638cd4b..38151429 100644 --- a/typesense_codegen/src/apis/curation_sets_api.rs +++ b/typesense_codegen/src/apis/curation_sets_api.rs @@ -83,71 +83,71 @@ pub struct UpsertCurationSetItemParams<'p> { /// struct for typed errors of method [`delete_curation_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteCurationSetError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum DeleteCurationSetError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`delete_curation_set_item`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteCurationSetItemError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum DeleteCurationSetItemError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_curation_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveCurationSetError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum RetrieveCurationSetError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_curation_set_item`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveCurationSetItemError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum RetrieveCurationSetItemError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_curation_set_items`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveCurationSetItemsError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum RetrieveCurationSetItemsError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_curation_sets`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveCurationSetsError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum RetrieveCurationSetsError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`upsert_curation_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertCurationSetError<'a> { - Status400(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum UpsertCurationSetError { + Status400(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`upsert_curation_set_item`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertCurationSetItemError<'a> { - Status400(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum UpsertCurationSetItemError { + Status400(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// Delete a specific curation set by its name pub async fn delete_curation_set( configuration: &configuration::Configuration, params: &DeleteCurationSetParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/curation_sets/{curationSetName}", configuration.base_path, @@ -210,7 +210,7 @@ pub async fn delete_curation_set( pub async fn delete_curation_set_item( configuration: &configuration::Configuration, params: &DeleteCurationSetItemParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/curation_sets/{curationSetName}/items/{itemId}", configuration.base_path, @@ -274,7 +274,7 @@ pub async fn delete_curation_set_item( pub async fn retrieve_curation_set( configuration: &configuration::Configuration, params: &RetrieveCurationSetParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/curation_sets/{curationSetName}", configuration.base_path, @@ -335,7 +335,7 @@ pub async fn retrieve_curation_set( pub async fn retrieve_curation_set_item( configuration: &configuration::Configuration, params: &RetrieveCurationSetItemParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/curation_sets/{curationSetName}/items/{itemId}", configuration.base_path, @@ -397,8 +397,7 @@ pub async fn retrieve_curation_set_item( pub async fn retrieve_curation_set_items( configuration: &configuration::Configuration, params: &RetrieveCurationSetItemsParams<'_>, -) -> Result>, Error>> -{ +) -> Result>, Error> { let uri_str = format!( "{}/curation_sets/{curationSetName}/items", configuration.base_path, @@ -458,7 +457,7 @@ pub async fn retrieve_curation_set_items( /// Retrieve all curation sets pub async fn retrieve_curation_sets( configuration: &configuration::Configuration, -) -> Result>, Error>> { +) -> Result>, Error> { let uri_str = format!("{}/curation_sets", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -515,7 +514,7 @@ pub async fn retrieve_curation_sets( pub async fn upsert_curation_set( configuration: &configuration::Configuration, params: &UpsertCurationSetParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/curation_sets/{curationSetName}", configuration.base_path, @@ -577,7 +576,7 @@ pub async fn upsert_curation_set( pub async fn upsert_curation_set_item( configuration: &configuration::Configuration, params: &UpsertCurationSetItemParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/curation_sets/{curationSetName}/items/{itemId}", configuration.base_path, diff --git a/typesense_codegen/src/apis/debug_api.rs b/typesense_codegen/src/apis/debug_api.rs index 09ab46ad..faf05f4a 100644 --- a/typesense_codegen/src/apis/debug_api.rs +++ b/typesense_codegen/src/apis/debug_api.rs @@ -17,14 +17,14 @@ use serde::{Deserialize, Serialize, de::Error as _}; /// struct for typed errors of method [`debug`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DebugError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum DebugError { + UnknownValue(serde_json::Value), } /// Print debugging information pub async fn debug( configuration: &configuration::Configuration, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/debug", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); diff --git a/typesense_codegen/src/apis/documents_api.rs b/typesense_codegen/src/apis/documents_api.rs index 803dc311..fcb83805 100644 --- a/typesense_codegen/src/apis/documents_api.rs +++ b/typesense_codegen/src/apis/documents_api.rs @@ -265,91 +265,91 @@ pub struct UpdateDocumentsParams<'p, B> { /// struct for typed errors of method [`delete_document`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteDocumentError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum DeleteDocumentError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`delete_documents`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteDocumentsError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum DeleteDocumentsError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`export_documents`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum ExportDocumentsError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum ExportDocumentsError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`get_document`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetDocumentError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum GetDocumentError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`import_documents`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum ImportDocumentsError<'a> { - Status400(models::ApiResponse<'a>), - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum ImportDocumentsError { + Status400(models::ApiResponse<'static>), + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`index_document`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum IndexDocumentError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum IndexDocumentError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`multi_search`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum MultiSearchError<'a> { - Status400(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum MultiSearchError { + Status400(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`search_collection`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum SearchCollectionError<'a> { - Status400(models::ApiResponse<'a>), - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum SearchCollectionError { + Status400(models::ApiResponse<'static>), + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`update_document`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpdateDocumentError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum UpdateDocumentError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`update_documents`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpdateDocumentsError<'a> { - Status400(models::ApiResponse<'a>), - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum UpdateDocumentsError { + Status400(models::ApiResponse<'static>), + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// Delete an individual document from a collection by using its ID. pub async fn delete_document( configuration: &configuration::Configuration, params: &DeleteDocumentParams<'_>, -) -> Result>> { +) -> Result> { let uri_str = format!( "{}/collections/{collectionName}/documents/{documentId}", configuration.base_path, @@ -413,7 +413,7 @@ pub async fn delete_document( pub async fn delete_documents( configuration: &configuration::Configuration, params: &DeleteDocumentsParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/collections/{collectionName}/documents", configuration.base_path, @@ -488,7 +488,7 @@ pub async fn delete_documents( pub async fn export_documents( configuration: &configuration::Configuration, params: &ExportDocumentsParams<'_>, -) -> Result>> { +) -> Result> { let uri_str = format!( "{}/collections/{collectionName}/documents/export", configuration.base_path, @@ -553,7 +553,7 @@ pub async fn export_documents( pub async fn get_document( configuration: &configuration::Configuration, params: &GetDocumentParams<'_>, -) -> Result>> { +) -> Result> { let uri_str = format!( "{}/collections/{collectionName}/documents/{documentId}", configuration.base_path, @@ -615,7 +615,7 @@ pub async fn get_document( pub async fn import_documents( configuration: &configuration::Configuration, params: &ImportDocumentsParams<'_>, -) -> Result>> { +) -> Result> { let uri_str = format!( "{}/collections/{collectionName}/documents/import", configuration.base_path, @@ -695,7 +695,7 @@ pub async fn import_documents( pub async fn index_document( configuration: &configuration::Configuration, params: &IndexDocumentParams<'_>, -) -> Result>> { +) -> Result> { let uri_str = format!( "{}/collections/{collectionName}/documents", configuration.base_path, @@ -765,7 +765,7 @@ pub async fn index_document( pub async fn multi_search( configuration: &configuration::Configuration, params: &MultiSearchParams<'_>, -) -> Result>> { +) -> Result> { let uri_str = format!("{}/multi_search", configuration.base_path); let mut req_builder = configuration .client @@ -1027,7 +1027,7 @@ pub async fn multi_search( pub async fn search_collection serde::Deserialize<'de> + Serialize>( configuration: &configuration::Configuration, params: &SearchCollectionParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/collections/{collectionName}/documents/search", configuration.base_path, @@ -1311,7 +1311,7 @@ pub async fn search_collection serde::Deserialize<'de> + Serialize>( pub async fn update_document( configuration: &configuration::Configuration, params: &UpdateDocumentParams<'_, B>, -) -> Result>> { +) -> Result> { let uri_str = format!( "{}/collections/{collectionName}/documents/{documentId}", configuration.base_path, @@ -1379,7 +1379,7 @@ pub async fn update_document( pub async fn update_documents( configuration: &configuration::Configuration, params: &UpdateDocumentsParams<'_, B>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/collections/{collectionName}/documents", configuration.base_path, diff --git a/typesense_codegen/src/apis/health_api.rs b/typesense_codegen/src/apis/health_api.rs index ed580bbf..f0b7ae41 100644 --- a/typesense_codegen/src/apis/health_api.rs +++ b/typesense_codegen/src/apis/health_api.rs @@ -17,14 +17,14 @@ use serde::{Deserialize, Serialize, de::Error as _}; /// struct for typed errors of method [`health`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum HealthError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum HealthError { + UnknownValue(serde_json::Value), } /// Checks if Typesense server is ready to accept requests. pub async fn health( configuration: &configuration::Configuration, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/health", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); diff --git a/typesense_codegen/src/apis/keys_api.rs b/typesense_codegen/src/apis/keys_api.rs index 174e1238..a3338f40 100644 --- a/typesense_codegen/src/apis/keys_api.rs +++ b/typesense_codegen/src/apis/keys_api.rs @@ -41,41 +41,41 @@ pub struct GetKeyParams<'p> { /// struct for typed errors of method [`create_key`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CreateKeyError<'a> { - Status400(models::ApiResponse<'a>), - Status409(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum CreateKeyError { + Status400(models::ApiResponse<'static>), + Status409(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`delete_key`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteKeyError<'a> { - Status400(models::ApiResponse<'a>), - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum DeleteKeyError { + Status400(models::ApiResponse<'static>), + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`get_key`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetKeyError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum GetKeyError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`get_keys`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetKeysError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum GetKeysError { + UnknownValue(serde_json::Value), } /// Create an API Key with fine-grain access control. You can restrict access on both a per-collection and per-action level. The generated key is returned only during creation. You want to store this key carefully in a secure place. pub async fn create_key( configuration: &configuration::Configuration, params: &CreateKeyParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/keys", configuration.base_path); let mut req_builder = configuration .client @@ -134,7 +134,7 @@ pub async fn create_key( pub async fn delete_key( configuration: &configuration::Configuration, params: &DeleteKeyParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/keys/{keyId}", configuration.base_path, @@ -197,7 +197,7 @@ pub async fn delete_key( pub async fn get_key( configuration: &configuration::Configuration, params: &GetKeyParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/keys/{keyId}", configuration.base_path, @@ -256,7 +256,7 @@ pub async fn get_key( pub async fn get_keys( configuration: &configuration::Configuration, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/keys", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); diff --git a/typesense_codegen/src/apis/mod.rs b/typesense_codegen/src/apis/mod.rs index ed868efd..6a7d0ac2 100644 --- a/typesense_codegen/src/apis/mod.rs +++ b/typesense_codegen/src/apis/mod.rs @@ -1,13 +1,5 @@ use ::std::{error, fmt}; -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] -#[serde(transparent)] -pub struct Unknown<'a> { - pub value: serde_json::Value, - #[serde(skip)] - pub _phantom: core::marker::PhantomData<&'a ()>, -} - #[derive(Debug, Clone)] pub struct ResponseContent { pub status: reqwest::StatusCode, diff --git a/typesense_codegen/src/apis/nl_search_models_api.rs b/typesense_codegen/src/apis/nl_search_models_api.rs index c84e9f5b..2ee2b37c 100644 --- a/typesense_codegen/src/apis/nl_search_models_api.rs +++ b/typesense_codegen/src/apis/nl_search_models_api.rs @@ -51,48 +51,48 @@ pub struct UpdateNlSearchModelParams<'p> { /// struct for typed errors of method [`create_nl_search_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CreateNlSearchModelError<'a> { - Status400(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum CreateNlSearchModelError { + Status400(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`delete_nl_search_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteNlSearchModelError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum DeleteNlSearchModelError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_all_nl_search_models`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveAllNlSearchModelsError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum RetrieveAllNlSearchModelsError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_nl_search_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveNlSearchModelError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum RetrieveNlSearchModelError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`update_nl_search_model`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpdateNlSearchModelError<'a> { - Status400(models::ApiResponse<'a>), - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum UpdateNlSearchModelError { + Status400(models::ApiResponse<'static>), + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// Create a new NL search model. pub async fn create_nl_search_model( configuration: &configuration::Configuration, params: &CreateNlSearchModelParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/nl_search_models", configuration.base_path); let mut req_builder = configuration .client @@ -152,7 +152,7 @@ pub async fn create_nl_search_model( pub async fn delete_nl_search_model( configuration: &configuration::Configuration, params: &DeleteNlSearchModelParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/nl_search_models/{modelId}", configuration.base_path, @@ -214,8 +214,7 @@ pub async fn delete_nl_search_model( /// Retrieve all NL search models. pub async fn retrieve_all_nl_search_models( configuration: &configuration::Configuration, -) -> Result>, Error>> -{ +) -> Result>, Error> { let uri_str = format!("{}/nl_search_models", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -272,7 +271,7 @@ pub async fn retrieve_all_nl_search_models( pub async fn retrieve_nl_search_model( configuration: &configuration::Configuration, params: &RetrieveNlSearchModelParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/nl_search_models/{modelId}", configuration.base_path, @@ -333,7 +332,7 @@ pub async fn retrieve_nl_search_model( pub async fn update_nl_search_model( configuration: &configuration::Configuration, params: &UpdateNlSearchModelParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/nl_search_models/{modelId}", configuration.base_path, diff --git a/typesense_codegen/src/apis/operations_api.rs b/typesense_codegen/src/apis/operations_api.rs index d8ad1f51..613eef9b 100644 --- a/typesense_codegen/src/apis/operations_api.rs +++ b/typesense_codegen/src/apis/operations_api.rs @@ -32,63 +32,63 @@ pub struct ToggleSlowRequestLogParams<'p> { /// struct for typed errors of method [`clear_cache`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum ClearCacheError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum ClearCacheError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`compact_db`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CompactDbError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum CompactDbError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`get_schema_changes`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetSchemaChangesError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum GetSchemaChangesError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_api_stats`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveApiStatsError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum RetrieveApiStatsError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_metrics`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveMetricsError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum RetrieveMetricsError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`take_snapshot`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum TakeSnapshotError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum TakeSnapshotError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`toggle_slow_request_log`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum ToggleSlowRequestLogError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum ToggleSlowRequestLogError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`vote`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum VoteError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum VoteError { + UnknownValue(serde_json::Value), } /// Clear the cached responses of search requests that are sent with `use_cache` parameter in the LRU cache. pub async fn clear_cache( configuration: &configuration::Configuration, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/operations/cache/clear", configuration.base_path); let mut req_builder = configuration .client @@ -146,7 +146,7 @@ pub async fn clear_cache( /// Typesense uses RocksDB to store your documents on the disk. If you do frequent writes or updates, you could benefit from running a compaction of the underlying RocksDB database. This could reduce the size of the database and decrease read latency. While the database will not block during this operation, we recommend running it during off-peak hours. pub async fn compact_db( configuration: &configuration::Configuration, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/operations/db/compact", configuration.base_path); let mut req_builder = configuration .client @@ -204,8 +204,7 @@ pub async fn compact_db( /// Returns the status of any ongoing schema change operations. If no schema changes are in progress, returns an empty response. pub async fn get_schema_changes( configuration: &configuration::Configuration, -) -> Result>>, Error>> -{ +) -> Result>>, Error> { let uri_str = format!("{}/operations/schema_changes", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -261,7 +260,7 @@ pub async fn get_schema_changes( /// Retrieve the stats about API endpoints. pub async fn retrieve_api_stats( configuration: &configuration::Configuration, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/stats.json", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -317,7 +316,7 @@ pub async fn retrieve_api_stats( /// Retrieve the metrics. pub async fn retrieve_metrics( configuration: &configuration::Configuration, -) -> Result>> { +) -> Result> { let uri_str = format!("{}/metrics.json", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -374,7 +373,7 @@ pub async fn retrieve_metrics( pub async fn take_snapshot( configuration: &configuration::Configuration, params: &TakeSnapshotParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/operations/snapshot", configuration.base_path); let mut req_builder = configuration .client @@ -434,7 +433,7 @@ pub async fn take_snapshot( pub async fn toggle_slow_request_log( configuration: &configuration::Configuration, params: &ToggleSlowRequestLogParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/config", configuration.base_path); let mut req_builder = configuration .client @@ -493,7 +492,7 @@ pub async fn toggle_slow_request_log( /// Triggers a follower node to initiate the raft voting process, which triggers leader re-election. The follower node that you run this operation against will become the new leader, once this command succeeds. pub async fn vote( configuration: &configuration::Configuration, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/operations/vote", configuration.base_path); let mut req_builder = configuration .client diff --git a/typesense_codegen/src/apis/presets_api.rs b/typesense_codegen/src/apis/presets_api.rs index 5d11d6ff..9937fa2a 100644 --- a/typesense_codegen/src/apis/presets_api.rs +++ b/typesense_codegen/src/apis/presets_api.rs @@ -43,39 +43,39 @@ pub struct UpsertPresetParams<'p> { /// struct for typed errors of method [`delete_preset`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeletePresetError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum DeletePresetError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_all_presets`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveAllPresetsError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum RetrieveAllPresetsError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_preset`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrievePresetError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum RetrievePresetError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`upsert_preset`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertPresetError<'a> { - Status400(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum UpsertPresetError { + Status400(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// Permanently deletes a preset, given it's name. pub async fn delete_preset( configuration: &configuration::Configuration, params: &DeletePresetParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/presets/{presetId}", configuration.base_path, @@ -137,7 +137,7 @@ pub async fn delete_preset( /// Retrieve the details of all presets pub async fn retrieve_all_presets( configuration: &configuration::Configuration, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!("{}/presets", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -194,7 +194,7 @@ pub async fn retrieve_all_presets( pub async fn retrieve_preset( configuration: &configuration::Configuration, params: &RetrievePresetParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/presets/{presetId}", configuration.base_path, @@ -255,7 +255,7 @@ pub async fn retrieve_preset( pub async fn upsert_preset( configuration: &configuration::Configuration, params: &UpsertPresetParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/presets/{presetId}", configuration.base_path, diff --git a/typesense_codegen/src/apis/stemming_api.rs b/typesense_codegen/src/apis/stemming_api.rs index f83fb9ab..c8f1213e 100644 --- a/typesense_codegen/src/apis/stemming_api.rs +++ b/typesense_codegen/src/apis/stemming_api.rs @@ -35,31 +35,31 @@ pub struct ImportStemmingDictionaryParams<'p> { /// struct for typed errors of method [`get_stemming_dictionary`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetStemmingDictionaryError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum GetStemmingDictionaryError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`import_stemming_dictionary`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum ImportStemmingDictionaryError<'a> { - Status400(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum ImportStemmingDictionaryError { + Status400(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`list_stemming_dictionaries`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum ListStemmingDictionariesError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum ListStemmingDictionariesError { + UnknownValue(serde_json::Value), } /// Fetch details of a specific stemming dictionary. pub async fn get_stemming_dictionary( configuration: &configuration::Configuration, params: &GetStemmingDictionaryParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/stemming/dictionaries/{dictionaryId}", configuration.base_path, @@ -120,7 +120,7 @@ pub async fn get_stemming_dictionary( pub async fn import_stemming_dictionary( configuration: &configuration::Configuration, params: &ImportStemmingDictionaryParams<'_>, -) -> Result>> { +) -> Result> { let uri_str = format!("{}/stemming/dictionaries/import", configuration.base_path); let mut req_builder = configuration .client @@ -179,7 +179,7 @@ pub async fn list_stemming_dictionaries( configuration: &configuration::Configuration, ) -> Result< models::ListStemmingDictionaries200Response<'static>, - Error>, + Error, > { let uri_str = format!("{}/stemming/dictionaries", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); diff --git a/typesense_codegen/src/apis/stopwords_api.rs b/typesense_codegen/src/apis/stopwords_api.rs index 080805f5..1a6a2e21 100644 --- a/typesense_codegen/src/apis/stopwords_api.rs +++ b/typesense_codegen/src/apis/stopwords_api.rs @@ -43,40 +43,39 @@ pub struct UpsertStopwordsSetParams<'p> { /// struct for typed errors of method [`delete_stopwords_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteStopwordsSetError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum DeleteStopwordsSetError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_stopwords_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveStopwordsSetError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum RetrieveStopwordsSetError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_stopwords_sets`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveStopwordsSetsError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum RetrieveStopwordsSetsError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`upsert_stopwords_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertStopwordsSetError<'a> { - Status400(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum UpsertStopwordsSetError { + Status400(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// Permanently deletes a stopwords set, given it's name. pub async fn delete_stopwords_set( configuration: &configuration::Configuration, params: &DeleteStopwordsSetParams<'_>, -) -> Result, Error>> -{ +) -> Result, Error> { let uri_str = format!( "{}/stopwords/{setId}", configuration.base_path, @@ -139,8 +138,7 @@ pub async fn delete_stopwords_set( pub async fn retrieve_stopwords_set( configuration: &configuration::Configuration, params: &RetrieveStopwordsSetParams<'_>, -) -> Result, Error>> -{ +) -> Result, Error> { let uri_str = format!( "{}/stopwords/{setId}", configuration.base_path, @@ -200,10 +198,7 @@ pub async fn retrieve_stopwords_set( /// Retrieve the details of all stopwords sets pub async fn retrieve_stopwords_sets( configuration: &configuration::Configuration, -) -> Result< - models::StopwordsSetsRetrieveAllSchema<'static>, - Error>, -> { +) -> Result, Error> { let uri_str = format!("{}/stopwords", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -260,7 +255,7 @@ pub async fn retrieve_stopwords_sets( pub async fn upsert_stopwords_set( configuration: &configuration::Configuration, params: &UpsertStopwordsSetParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/stopwords/{setId}", configuration.base_path, diff --git a/typesense_codegen/src/apis/synonyms_api.rs b/typesense_codegen/src/apis/synonyms_api.rs index fb402121..3350319d 100644 --- a/typesense_codegen/src/apis/synonyms_api.rs +++ b/typesense_codegen/src/apis/synonyms_api.rs @@ -83,71 +83,71 @@ pub struct UpsertSynonymSetItemParams<'p> { /// struct for typed errors of method [`delete_synonym_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteSynonymSetError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum DeleteSynonymSetError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`delete_synonym_set_item`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteSynonymSetItemError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum DeleteSynonymSetItemError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_synonym_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveSynonymSetError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum RetrieveSynonymSetError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_synonym_set_item`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveSynonymSetItemError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum RetrieveSynonymSetItemError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_synonym_set_items`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveSynonymSetItemsError<'a> { - Status404(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum RetrieveSynonymSetItemsError { + Status404(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`retrieve_synonym_sets`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum RetrieveSynonymSetsError<'a> { - UnknownValue(super::Unknown<'a>), +pub enum RetrieveSynonymSetsError { + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`upsert_synonym_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertSynonymSetError<'a> { - Status400(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum UpsertSynonymSetError { + Status400(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// struct for typed errors of method [`upsert_synonym_set_item`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpsertSynonymSetItemError<'a> { - Status400(models::ApiResponse<'a>), - UnknownValue(super::Unknown<'a>), +pub enum UpsertSynonymSetItemError { + Status400(models::ApiResponse<'static>), + UnknownValue(serde_json::Value), } /// Delete a specific synonym set by its name pub async fn delete_synonym_set( configuration: &configuration::Configuration, params: &DeleteSynonymSetParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}", configuration.base_path, @@ -210,7 +210,7 @@ pub async fn delete_synonym_set( pub async fn delete_synonym_set_item( configuration: &configuration::Configuration, params: &DeleteSynonymSetItemParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}/items/{itemId}", configuration.base_path, @@ -274,7 +274,7 @@ pub async fn delete_synonym_set_item( pub async fn retrieve_synonym_set( configuration: &configuration::Configuration, params: &RetrieveSynonymSetParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}", configuration.base_path, @@ -335,7 +335,7 @@ pub async fn retrieve_synonym_set( pub async fn retrieve_synonym_set_item( configuration: &configuration::Configuration, params: &RetrieveSynonymSetItemParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}/items/{itemId}", configuration.base_path, @@ -397,7 +397,7 @@ pub async fn retrieve_synonym_set_item( pub async fn retrieve_synonym_set_items( configuration: &configuration::Configuration, params: &RetrieveSynonymSetItemsParams<'_>, -) -> Result>, Error>> { +) -> Result>, Error> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}/items", configuration.base_path, @@ -457,7 +457,7 @@ pub async fn retrieve_synonym_set_items( /// Retrieve all synonym sets pub async fn retrieve_synonym_sets( configuration: &configuration::Configuration, -) -> Result>, Error>> { +) -> Result>, Error> { let uri_str = format!("{}/synonym_sets", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -514,7 +514,7 @@ pub async fn retrieve_synonym_sets( pub async fn upsert_synonym_set( configuration: &configuration::Configuration, params: &UpsertSynonymSetParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}", configuration.base_path, @@ -576,7 +576,7 @@ pub async fn upsert_synonym_set( pub async fn upsert_synonym_set_item( configuration: &configuration::Configuration, params: &UpsertSynonymSetItemParams<'_>, -) -> Result, Error>> { +) -> Result, Error> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}/items/{itemId}", configuration.base_path, From f185c8363b16160b7db8fc3c99e1e3536e9e0723 Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Thu, 13 Nov 2025 00:00:43 +0000 Subject: [PATCH 12/17] Invert to is-used-as-input --- openapi-generator-template/model.mustache | 4 +- preprocessed_openapi.yml | 105 ++++++------------ ...nalytics_rule_200_response_one_of_inner.rs | 17 +-- ...s_rule_200_response_one_of_inner_any_of.rs | 2 +- .../src/models/debug_200_response.rs | 2 +- .../delete_stopwords_set_200_response.rs | 4 +- .../src/models/field_embed_model_config.rs | 22 ++-- xtask/src/preprocess_openapi.rs | 12 +- 8 files changed, 64 insertions(+), 104 deletions(-) diff --git a/openapi-generator-template/model.mustache b/openapi-generator-template/model.mustache index e4668cbf..b1856003 100644 --- a/openapi-generator-template/model.mustache +++ b/openapi-generator-template/model.mustache @@ -153,7 +153,7 @@ pub struct {{{classname}}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{ ### ByteArray }}{{^isModel}}{{#isByteArray}}Vec{{/isByteArray}}{{! ### String - }}{{^isByteArray}}{{#isString}}{{#model}}{{#vendorExtensions.x-rust-is-owned-data}}String{{/vendorExtensions.x-rust-is-owned-data}}{{^vendorExtensions.x-rust-is-owned-data}}Cow<'a, str>{{/vendorExtensions.x-rust-is-owned-data}}{{/model}}{{/isString}}{{! + }}{{^isByteArray}}{{#isString}}{{#model}}{{#vendorExtensions.x-rust-is-used-as-input}}Cow<'a, str>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}String{{/vendorExtensions.x-rust-is-used-as-input}}{{/model}}{{/isString}}{{! ### Arrays }}{{^isString}}{{#isArray}}Vec<{{#items}}{{! ### Array Models @@ -186,7 +186,7 @@ impl<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtension }}{{^vendorExtensions.x-rust-type}}{{#isNullable}}Option<{{/isNullable}}{{! }}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{! }}{{^isEnum}}{{#isByteArray}}Vec{{/isByteArray}}{{! - }}{{^isByteArray}}{{#isString}}{{#model}}{{#vendorExtensions.x-rust-is-owned-data}}String{{/vendorExtensions.x-rust-is-owned-data}}{{^vendorExtensions.x-rust-is-owned-data}}Cow<'a, str>{{/vendorExtensions.x-rust-is-owned-data}}{{/model}}{{/isString}}{{! + }}{{^isByteArray}}{{#isString}}{{#model}}{{#vendorExtensions.x-rust-is-used-as-input}}Cow<'a, str>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}String{{/vendorExtensions.x-rust-is-used-as-input}}{{/model}}{{/isString}}{{! }}{{^isString}}{{#isArray}}Vec<{{#items}}{{! }}{{#isModel}}{{{dataType}}}<'a>{{/isModel}}{{! }}{{^isModel}}{{{dataType}}}{{/isModel}}{{/items}}>{{/isArray}}{{! diff --git a/preprocessed_openapi.yml b/preprocessed_openapi.yml index 9ed67b27..ab2849b5 100644 --- a/preprocessed_openapi.yml +++ b/preprocessed_openapi.yml @@ -3177,7 +3177,9 @@ components: description: | Optional details about the collection, e.g., when it was created, who created it etc. type: object + x-rust-is-used-as-input: true x-rust-builder: true + x-rust-is-used-as-input: true CollectionUpdateSchema: type: object required: @@ -3208,6 +3210,8 @@ components: description: | Optional details about the collection, e.g., when it was created, who created it etc. type: object + x-rust-is-used-as-input: true + x-rust-is-used-as-input: true CollectionResponse: allOf: - $ref: '#/components/schemas/CollectionSchema' @@ -3226,7 +3230,6 @@ components: description: Timestamp of when the collection was created (Unix epoch in seconds) format: int64 readOnly: true - x-rust-is-owned-data: true Field: type: object required: @@ -3342,9 +3345,7 @@ components: type: string query_prefix: type: string - x-rust-is-owned-data: true x-rust-builder: true - x-rust-is-owned-data: true VoiceQueryModelCollectionConfig: description: | Configuration for the voice query model @@ -3353,7 +3354,6 @@ components: model_name: type: string example: ts/whisper/base.en - x-rust-is-owned-data: true CollectionAliasSchema: type: object required: @@ -3362,6 +3362,7 @@ components: collection_name: description: Name of the collection you wish to map the alias to type: string + x-rust-is-used-as-input: true CollectionAlias: type: object required: @@ -3375,7 +3376,6 @@ components: collection_name: description: Name of the collection the alias mapped to type: string - x-rust-is-owned-data: true CollectionAliasesResponse: type: object required: @@ -3386,7 +3386,6 @@ components: items: $ref: '#/components/schemas/CollectionAlias' x-go-type: '[]*CollectionAlias' - x-rust-is-owned-data: true SearchResult: type: object properties: @@ -3435,9 +3434,7 @@ components: description: Custom JSON object that can be returned in the search response type: object additionalProperties: true - x-rust-is-owned-data: true x-rust-generic-parameter: D - x-rust-is-owned-data: true SearchRequestParams: type: object required: @@ -3456,8 +3453,6 @@ components: properties: transcribed_query: type: string - x-rust-is-owned-data: true - x-rust-is-owned-data: true SearchResultConversation: type: object required: @@ -3472,12 +3467,10 @@ components: type: array items: type: object - x-rust-is-owned-data: true conversation_id: type: string query: type: string - x-rust-is-owned-data: true SearchGroupedHit: type: object required: @@ -3496,7 +3489,6 @@ components: $ref: '#/components/schemas/SearchResultHit' x-rust-type: Vec> x-rust-generic-parameter: D - x-rust-is-owned-data: true SearchResultHit: type: object example: @@ -3520,14 +3512,12 @@ components: description: Highlighted version of the matching document type: object additionalProperties: true - x-rust-is-owned-data: true document: description: Can be any key-value pair type: object additionalProperties: type: object x-rust-type: Option - x-rust-is-owned-data: true text_match: type: integer format: int64 @@ -3550,13 +3540,11 @@ components: type: integer typo_prefix_score: type: integer - x-rust-is-owned-data: true geo_distance_meters: description: Can be any key-value pair type: object additionalProperties: type: integer - x-rust-is-owned-data: true vector_distance: description: Distance between the query vector and matching document's vector value type: number @@ -3569,12 +3557,10 @@ components: description: Combined score from rank fusion of text and vector search type: number format: float - x-rust-is-owned-data: true search_index: description: Returned only for union query response. Indicates the index of the query which this document matched to. type: integer x-rust-generic-parameter: D - x-rust-is-owned-data: true SearchHighlight: type: object properties: @@ -3616,8 +3602,6 @@ components: items: type: object x-go-type: interface{} - x-rust-is-owned-data: true - x-rust-is-owned-data: true SearchSynonymSchema: type: object required: @@ -3639,7 +3623,6 @@ components: type: array items: type: string - x-rust-is-owned-data: true SearchSynonym: allOf: - $ref: '#/components/schemas/SearchSynonymSchema' @@ -3650,7 +3633,6 @@ components: id: type: string readOnly: true - x-rust-is-owned-data: true SearchSynonymDeleteResponse: type: object required: @@ -3659,7 +3641,6 @@ components: id: description: The id of the synonym that was deleted type: string - x-rust-is-owned-data: true SearchSynonymsResponse: type: object required: @@ -3670,7 +3651,6 @@ components: items: $ref: '#/components/schemas/SearchSynonym' x-go-type: '[]*SearchSynonym' - x-rust-is-owned-data: true HealthStatus: type: object required: @@ -3678,7 +3658,6 @@ components: properties: ok: type: boolean - x-rust-is-owned-data: true SchemaChangeStatus: type: object properties: @@ -3691,7 +3670,6 @@ components: altered_docs: description: Number of documents that have been altered type: integer - x-rust-is-owned-data: true SuccessStatus: type: object required: @@ -3699,7 +3677,6 @@ components: properties: success: type: boolean - x-rust-is-owned-data: true ApiResponse: type: object required: @@ -3707,7 +3684,6 @@ components: properties: message: type: string - x-rust-is-owned-data: true ApiKeySchema: type: object required: @@ -3730,6 +3706,7 @@ components: expires_at: type: integer format: int64 + x-rust-is-used-as-input: true ApiKey: allOf: - $ref: '#/components/schemas/ApiKeySchema' @@ -3742,7 +3719,6 @@ components: value_prefix: type: string readOnly: true - x-rust-is-owned-data: true ApiKeyDeleteResponse: type: object required: @@ -3752,7 +3728,6 @@ components: description: The id of the API key that was deleted type: integer format: int64 - x-rust-is-owned-data: true ApiKeysResponse: type: object required: @@ -3763,7 +3738,6 @@ components: items: $ref: '#/components/schemas/ApiKey' x-go-type: '[]*ApiKey' - x-rust-is-owned-data: true MultiSearchResult: type: object required: @@ -3777,7 +3751,6 @@ components: conversation: $ref: '#/components/schemas/SearchResultConversation' x-rust-generic-parameter: D - x-rust-is-owned-data: true MultiSearchResultItem: allOf: - $ref: '#/components/schemas/SearchResult' @@ -3791,7 +3764,6 @@ components: type: string description: Error description x-rust-generic-parameter: D - x-rust-is-owned-data: true SearchParameters: type: object properties: @@ -4066,6 +4038,7 @@ components: The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. type: string x-rust-builder: true + x-rust-is-used-as-input: true MultiSearchParameters: description: | Parameters for the multi search API. @@ -4316,6 +4289,7 @@ components: The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. type: string x-rust-builder: true + x-rust-is-used-as-input: true MultiSearchSearchesParameter: type: object required: @@ -4329,6 +4303,7 @@ components: type: array items: $ref: '#/components/schemas/MultiSearchCollectionParameters' + x-rust-is-used-as-input: true MultiSearchCollectionParameters: allOf: - $ref: '#/components/schemas/MultiSearchParameters' @@ -4347,6 +4322,7 @@ components: When true, computes both text match and vector distance scores for all matches in hybrid search. Documents found only through keyword search will get a vector distance score, and documents found only through vector search will get a text match score. default: false x-rust-builder: true + x-rust-is-used-as-input: true FacetCounts: type: object properties: @@ -4363,7 +4339,6 @@ components: type: string parent: type: object - x-rust-is-owned-data: true field_name: type: string stats: @@ -4383,8 +4358,6 @@ components: avg: type: number format: double - x-rust-is-owned-data: true - x-rust-is-owned-data: true AnalyticsEventCreateResponse: type: object required: @@ -4392,7 +4365,6 @@ components: properties: ok: type: boolean - x-rust-is-owned-data: true AnalyticsEvent: type: object required: @@ -4422,6 +4394,8 @@ components: type: string analytics_tag: type: string + x-rust-is-used-as-input: true + x-rust-is-used-as-input: true AnalyticsEventsResponse: type: object required: @@ -4451,8 +4425,6 @@ components: type: string query: type: string - x-rust-is-owned-data: true - x-rust-is-owned-data: true AnalyticsRuleCreate: type: object required: @@ -4495,6 +4467,8 @@ components: type: string weight: type: integer + x-rust-is-used-as-input: true + x-rust-is-used-as-input: true AnalyticsRuleUpdate: description: Fields allowed to update on an analytics rule type: object @@ -4522,11 +4496,12 @@ components: type: string weight: type: integer + x-rust-is-used-as-input: true + x-rust-is-used-as-input: true AnalyticsRule: allOf: - $ref: '#/components/schemas/AnalyticsRuleCreate' - type: object - x-rust-is-owned-data: true AnalyticsStatus: type: object properties: @@ -4544,7 +4519,6 @@ components: type: integer doc_counter_events: type: integer - x-rust-is-owned-data: true APIStatsResponse: type: object properties: @@ -4563,7 +4537,6 @@ components: latency_ms: type: object x-go-type: map[string]float64 - x-rust-is-owned-data: true overloaded_requests_per_second: type: number format: double @@ -4573,7 +4546,6 @@ components: requests_per_second: type: object x-go-type: map[string]float64 - x-rust-is-owned-data: true search_latency_ms: type: number format: double @@ -4589,7 +4561,6 @@ components: write_requests_per_second: type: number format: double - x-rust-is-owned-data: true StopwordsSetUpsertSchema: type: object required: @@ -4603,6 +4574,7 @@ components: type: string locale: type: string + x-rust-is-used-as-input: true StopwordsSetSchema: type: object required: @@ -4619,7 +4591,6 @@ components: type: string locale: type: string - x-rust-is-owned-data: true StopwordsSetRetrieveSchema: type: object required: @@ -4629,7 +4600,6 @@ components: properties: stopwords: $ref: '#/components/schemas/StopwordsSetSchema' - x-rust-is-owned-data: true StopwordsSetsRetrieveAllSchema: type: object required: @@ -4641,7 +4611,6 @@ components: type: array items: $ref: '#/components/schemas/StopwordsSetSchema' - x-rust-is-owned-data: true PresetUpsertSchema: required: - value @@ -4650,6 +4619,7 @@ components: oneOf: - $ref: '#/components/schemas/SearchParameters' - $ref: '#/components/schemas/MultiSearchSearchesParameter' + x-rust-is-used-as-input: true PresetSchema: allOf: - $ref: '#/components/schemas/PresetUpsertSchema' @@ -4659,7 +4629,6 @@ components: properties: name: type: string - x-rust-is-owned-data: true PresetsRetrieveSchema: type: object required: @@ -4670,7 +4639,6 @@ components: items: $ref: '#/components/schemas/PresetSchema' x-go-type: '[]*PresetSchema' - x-rust-is-owned-data: true PresetDeleteSchema: type: object required: @@ -4678,7 +4646,6 @@ components: properties: name: type: string - x-rust-is-owned-data: true DirtyValues: type: string enum: @@ -4686,6 +4653,7 @@ components: - coerce_or_drop - drop - reject + x-rust-is-used-as-input: true IndexAction: type: string enum: @@ -4693,6 +4661,7 @@ components: - update - upsert - emplace + x-rust-is-used-as-input: true DropTokensMode: description: | Dictates the direction in which the words in the query must be dropped when the original words in the query do not appear in any document. Values: right_to_left (default), left_to_right, both_sides:3 A note on both_sides:3 - for queries up to 3 tokens (words) in length, this mode will drop tokens from both sides and exhaustively rank all matching results. If query length is greater than 3 words, Typesense will just fallback to default behavior of right_to_left @@ -4701,6 +4670,7 @@ components: - right_to_left - left_to_right - both_sides:3 + x-rust-is-used-as-input: true ConversationModelCreateSchema: required: - model_name @@ -4723,6 +4693,7 @@ components: history_collection: type: string description: Typesense collection that stores the historical conversations + x-rust-is-used-as-input: true ConversationModelUpdateSchema: type: object properties: @@ -4755,6 +4726,7 @@ components: vllm_url: description: URL of vLLM service type: string + x-rust-is-used-as-input: true ConversationModelSchema: allOf: - $ref: '#/components/schemas/ConversationModelCreateSchema' @@ -4765,7 +4737,6 @@ components: id: type: string description: An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. - x-rust-is-owned-data: true StemmingDictionary: type: object required: @@ -4793,8 +4764,6 @@ components: description: The root form of the word type: string example: person - x-rust-is-owned-data: true - x-rust-is-owned-data: true NLSearchModelBase: type: object properties: @@ -4854,7 +4823,6 @@ components: account_id: description: Account ID for Cloudflare-specific models type: string - x-rust-is-owned-data: true NLSearchModelCreateSchema: allOf: - $ref: '#/components/schemas/NLSearchModelBase' @@ -4863,6 +4831,7 @@ components: id: type: string description: Optional ID for the NL search model + x-rust-is-used-as-input: true NLSearchModelSchema: allOf: - $ref: '#/components/schemas/NLSearchModelCreateSchema' @@ -4873,9 +4842,9 @@ components: id: type: string description: ID of the NL search model - x-rust-is-owned-data: true NLSearchModelUpdateSchema: $ref: '#/components/schemas/NLSearchModelCreateSchema' + x-rust-is-used-as-input: true NLSearchModelDeleteSchema: type: object required: @@ -4884,7 +4853,6 @@ components: id: description: ID of the deleted NL search model type: string - x-rust-is-owned-data: true SynonymItemSchema: type: object required: @@ -4910,6 +4878,7 @@ components: type: array items: type: string + x-rust-is-used-as-input: true SynonymSetCreateSchema: type: object required: @@ -4920,6 +4889,7 @@ components: type: array items: $ref: '#/components/schemas/SynonymItemSchema' + x-rust-is-used-as-input: true SynonymSetSchema: allOf: - $ref: '#/components/schemas/SynonymSetCreateSchema' @@ -4930,7 +4900,6 @@ components: name: type: string description: Name of the synonym set - x-rust-is-owned-data: true SynonymSetsRetrieveSchema: type: object required: @@ -4941,10 +4910,8 @@ components: type: array items: $ref: '#/components/schemas/SynonymSetSchema' - x-rust-is-owned-data: true SynonymSetRetrieveSchema: $ref: '#/components/schemas/SynonymSetCreateSchema' - x-rust-is-owned-data: true SynonymSetDeleteSchema: type: object required: @@ -4953,7 +4920,6 @@ components: name: description: Name of the deleted synonym set type: string - x-rust-is-owned-data: true SynonymItemDeleteSchema: type: object required: @@ -4962,7 +4928,6 @@ components: id: description: ID of the deleted synonym item type: string - x-rust-is-owned-data: true CurationItemCreateSchema: type: object required: @@ -4992,6 +4957,7 @@ components: description: | Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered. type: object + x-rust-is-used-as-input: true sort_by: description: | A sort by clause that is applied to any search query that matches the curation rule. @@ -5019,6 +4985,7 @@ components: id: description: ID of the curation item type: string + x-rust-is-used-as-input: true CurationItemSchema: allOf: - $ref: '#/components/schemas/CurationItemCreateSchema' @@ -5028,7 +4995,6 @@ components: properties: id: type: string - x-rust-is-owned-data: true CurationSetCreateSchema: type: object required: @@ -5042,6 +5008,7 @@ components: description: description: Optional description for the curation set type: string + x-rust-is-used-as-input: true CurationSetSchema: allOf: - $ref: '#/components/schemas/CurationSetCreateSchema' @@ -5051,7 +5018,6 @@ components: properties: name: type: string - x-rust-is-owned-data: true CurationRule: type: object properties: @@ -5074,7 +5040,6 @@ components: description: | Indicates that the curation should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc). type: string - x-rust-is-owned-data: true CurationInclude: type: object required: @@ -5087,7 +5052,6 @@ components: position: description: position number where document should be included in the search results type: integer - x-rust-is-owned-data: true CurationExclude: type: object required: @@ -5096,10 +5060,8 @@ components: id: description: document id that should be excluded from the search results. type: string - x-rust-is-owned-data: true CurationSetRetrieveSchema: $ref: '#/components/schemas/CurationSetCreateSchema' - x-rust-is-owned-data: true CurationSetDeleteSchema: type: object required: @@ -5108,7 +5070,6 @@ components: name: description: Name of the deleted curation set type: string - x-rust-is-owned-data: true CurationItemDeleteSchema: type: object required: @@ -5117,7 +5078,6 @@ components: id: description: ID of the deleted curation item type: string - x-rust-is-owned-data: true ImportDocumentsParameters: type: object properties: @@ -5134,6 +5094,7 @@ components: $ref: '#/components/schemas/IndexAction' dirty_values: $ref: '#/components/schemas/DirtyValues' + x-rust-is-used-as-input: true ExportDocumentsParameters: type: object properties: @@ -5146,12 +5107,14 @@ components: exclude_fields: description: List of fields from the document to exclude in the search result type: string + x-rust-is-used-as-input: true UpdateDocumentsParameters: type: object properties: filter_by: type: string example: 'num_employees:>100 && country: [USA, UK]' + x-rust-is-used-as-input: true DeleteDocumentsParameters: type: object required: @@ -5168,6 +5131,7 @@ components: truncate: description: When true, removes all documents from the collection while preserving the collection and its schema. type: boolean + x-rust-is-used-as-input: true GetCollectionsParameters: type: object properties: @@ -5181,6 +5145,7 @@ components: offset: description: Identifies the starting point to return collections when paginating. type: integer + x-rust-is-used-as-input: true securitySchemes: api_key_header: type: apiKey diff --git a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs index 32fd6ec1..bcc8e74b 100644 --- a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs +++ b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs @@ -15,30 +15,25 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateAnalyticsRule200ResponseOneOfInner<'a> { #[serde(rename = "name")] - pub name: Cow<'a, str>, + pub name: String, #[serde(rename = "type")] pub r#type: Type, #[serde(rename = "collection")] - pub collection: Cow<'a, str>, + pub collection: String, #[serde(rename = "event_type")] - pub event_type: Cow<'a, str>, + pub event_type: String, #[serde(rename = "rule_tag", skip_serializing_if = "Option::is_none")] - pub rule_tag: Option>, + pub rule_tag: Option, #[serde(rename = "params", skip_serializing_if = "Option::is_none")] pub params: Option>>, #[serde(rename = "error", skip_serializing_if = "Option::is_none")] - pub error: Option>, + pub error: Option, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> CreateAnalyticsRule200ResponseOneOfInner<'a> { - pub fn new( - name: Cow<'a, str>, - r#type: Type, - collection: Cow<'a, str>, - event_type: Cow<'a, str>, - ) -> Self { + pub fn new(name: String, r#type: Type, collection: String, event_type: String) -> Self { Self { name, r#type, diff --git a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs index 48dcb036..89a0805b 100644 --- a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs +++ b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs @@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateAnalyticsRule200ResponseOneOfInnerAnyOf<'a> { #[serde(rename = "error", skip_serializing_if = "Option::is_none")] - pub error: Option>, + pub error: Option, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } diff --git a/typesense_codegen/src/models/debug_200_response.rs b/typesense_codegen/src/models/debug_200_response.rs index 0ae00b80..b21ef1c3 100644 --- a/typesense_codegen/src/models/debug_200_response.rs +++ b/typesense_codegen/src/models/debug_200_response.rs @@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Debug200Response<'a> { #[serde(rename = "version", skip_serializing_if = "Option::is_none")] - pub version: Option>, + pub version: Option, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } diff --git a/typesense_codegen/src/models/delete_stopwords_set_200_response.rs b/typesense_codegen/src/models/delete_stopwords_set_200_response.rs index 2a4d584a..4de85de3 100644 --- a/typesense_codegen/src/models/delete_stopwords_set_200_response.rs +++ b/typesense_codegen/src/models/delete_stopwords_set_200_response.rs @@ -15,13 +15,13 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DeleteStopwordsSet200Response<'a> { #[serde(rename = "id")] - pub id: Cow<'a, str>, + pub id: String, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> DeleteStopwordsSet200Response<'a> { - pub fn new(id: Cow<'a, str>) -> Self { + pub fn new(id: String) -> Self { Self { id, _phantom: PhantomData, diff --git a/typesense_codegen/src/models/field_embed_model_config.rs b/typesense_codegen/src/models/field_embed_model_config.rs index 19f89744..9b14bbcd 100644 --- a/typesense_codegen/src/models/field_embed_model_config.rs +++ b/typesense_codegen/src/models/field_embed_model_config.rs @@ -15,31 +15,31 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct FieldEmbedModelConfig<'a> { #[serde(rename = "model_name")] - pub model_name: Cow<'a, str>, + pub model_name: String, #[serde(rename = "api_key", skip_serializing_if = "Option::is_none")] - pub api_key: Option>, + pub api_key: Option, #[serde(rename = "url", skip_serializing_if = "Option::is_none")] - pub url: Option>, + pub url: Option, #[serde(rename = "access_token", skip_serializing_if = "Option::is_none")] - pub access_token: Option>, + pub access_token: Option, #[serde(rename = "refresh_token", skip_serializing_if = "Option::is_none")] - pub refresh_token: Option>, + pub refresh_token: Option, #[serde(rename = "client_id", skip_serializing_if = "Option::is_none")] - pub client_id: Option>, + pub client_id: Option, #[serde(rename = "client_secret", skip_serializing_if = "Option::is_none")] - pub client_secret: Option>, + pub client_secret: Option, #[serde(rename = "project_id", skip_serializing_if = "Option::is_none")] - pub project_id: Option>, + pub project_id: Option, #[serde(rename = "indexing_prefix", skip_serializing_if = "Option::is_none")] - pub indexing_prefix: Option>, + pub indexing_prefix: Option, #[serde(rename = "query_prefix", skip_serializing_if = "Option::is_none")] - pub query_prefix: Option>, + pub query_prefix: Option, #[serde(skip)] pub _phantom: PhantomData<&'a ()>, } impl<'a> FieldEmbedModelConfig<'a> { - pub fn new(model_name: Cow<'a, str>) -> Self { + pub fn new(model_name: String) -> Self { Self { model_name, api_key: None, diff --git a/xtask/src/preprocess_openapi.rs b/xtask/src/preprocess_openapi.rs index 0ce2e073..870e547f 100644 --- a/xtask/src/preprocess_openapi.rs +++ b/xtask/src/preprocess_openapi.rs @@ -254,7 +254,7 @@ fn schemas_mark_owned_data(doc: &mut OpenAPI) { .components .schemas .iter() - .filter(|(n, _)| !n.ends_with("Parameters") && !request_schemas.contains(n.as_str())) + .filter(|(n, _)| n.ends_with("Parameters") || request_schemas.contains(n.as_str())) .map(|(n, _)| n.to_owned()) .collect::>(); drop(request_schemas); @@ -266,7 +266,7 @@ fn schemas_mark_owned_data(doc: &mut OpenAPI) { schema .extra - .insert("x-rust-is-owned-data".to_owned(), Value::Bool(true)); + .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); for (_, prop) in schema.properties.iter_mut().flat_map(|v| v.iter_mut()) { for inner in prop.one_of.iter_mut().flat_map(|v| v.iter_mut()) { @@ -275,7 +275,7 @@ fn schemas_mark_owned_data(doc: &mut OpenAPI) { } inner .extra - .insert("x-rust-is-owned-data".to_owned(), Value::Bool(true)); + .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); } for inner in prop.any_of.iter_mut().flat_map(|v| v.iter_mut()) { if inner.r#type.as_deref() != Some("object") { @@ -283,21 +283,21 @@ fn schemas_mark_owned_data(doc: &mut OpenAPI) { } inner .extra - .insert("x-rust-is-owned-data".to_owned(), Value::Bool(true)); + .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); } if let Some(inner) = &mut prop.items && inner.r#type.as_deref() == Some("object") { inner .extra - .insert("x-rust-is-owned-data".to_owned(), Value::Bool(true)); + .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); } if prop.r#type.as_deref() != Some("object") { continue; } prop.extra - .insert("x-rust-is-owned-data".to_owned(), Value::Bool(true)); + .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); } } } From 9efa0e3a54685811700f9c66480640841ba2be89 Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Thu, 13 Nov 2025 01:05:24 +0000 Subject: [PATCH 13/17] Less lifetimes --- openapi-generator-template/model.mustache | 23 ++++++----- .../reqwest/api.mustache | 14 +++---- preprocessed_openapi.yml | 18 ++++++--- typesense/src/client/alias.rs | 4 +- typesense/src/client/aliases.rs | 5 +-- typesense/src/client/collection/documents.rs | 14 +++---- typesense/src/client/collection/mod.rs | 6 +-- typesense/src/client/collections.rs | 6 +-- typesense/src/client/conversations/model.rs | 6 +-- typesense/src/client/conversations/models.rs | 4 +- typesense/src/client/key.rs | 4 +- typesense/src/client/keys.rs | 6 +-- typesense/src/client/multi_search.rs | 4 +- typesense/src/client/operations.rs | 30 +++++--------- typesense/src/client/preset.rs | 4 +- typesense/src/client/presets.rs | 5 +-- typesense/src/client/stemming/dictionaries.rs | 2 +- typesense/src/client/stemming/dictionary.rs | 3 +- typesense/src/client/stopword.rs | 12 ++---- typesense/src/client/stopwords.rs | 5 +-- typesense/src/traits/multi_search_ext.rs | 33 +++++++--------- typesense_codegen/src/apis/analytics_api.rs | 30 +++++++------- typesense_codegen/src/apis/collections_api.rs | 36 ++++++++--------- .../src/apis/conversations_api.rs | 13 +++---- .../src/apis/curation_sets_api.rs | 28 ++++++------- typesense_codegen/src/apis/debug_api.rs | 2 +- typesense_codegen/src/apis/documents_api.rs | 36 ++++++++--------- typesense_codegen/src/apis/health_api.rs | 2 +- typesense_codegen/src/apis/keys_api.rs | 18 ++++----- .../src/apis/nl_search_models_api.rs | 20 +++++----- typesense_codegen/src/apis/operations_api.rs | 18 ++++----- typesense_codegen/src/apis/presets_api.rs | 14 +++---- typesense_codegen/src/apis/stemming_api.rs | 11 ++---- typesense_codegen/src/apis/stopwords_api.rs | 14 +++---- typesense_codegen/src/apis/synonyms_api.rs | 22 +++++------ .../models/analytics_event_create_response.rs | 11 ++---- .../src/models/analytics_events_response.rs | 15 +++---- .../analytics_events_response_events_inner.rs | 7 +--- .../src/models/analytics_rule.rs | 9 ++--- .../src/models/analytics_status.rs | 7 +--- typesense_codegen/src/models/api_key.rs | 7 +--- .../src/models/api_key_delete_response.rs | 11 ++---- .../src/models/api_keys_response.rs | 15 +++---- typesense_codegen/src/models/api_response.rs | 11 ++---- .../src/models/api_stats_response.rs | 7 +--- .../src/models/collection_alias.rs | 7 +--- .../src/models/collection_aliases_response.rs | 15 +++---- .../src/models/collection_response.rs | 13 +++---- .../src/models/collection_schema.rs | 6 +-- .../src/models/collection_update_schema.rs | 4 +- .../src/models/conversation_model_schema.rs | 7 +--- .../create_analytics_rule_200_response.rs | 8 ++-- ...nalytics_rule_200_response_one_of_inner.rs | 9 ++--- ...s_rule_200_response_one_of_inner_any_of.rs | 11 ++---- .../src/models/curation_exclude.rs | 11 ++---- .../src/models/curation_include.rs | 12 ++---- .../src/models/curation_item_create_schema.rs | 8 ++-- .../src/models/curation_item_delete_schema.rs | 11 ++---- .../src/models/curation_item_schema.rs | 15 +++---- typesense_codegen/src/models/curation_rule.rs | 7 +--- .../src/models/curation_set_delete_schema.rs | 11 ++---- .../src/models/curation_set_schema.rs | 11 ++---- .../src/models/debug_200_response.rs | 11 ++---- .../models/delete_documents_200_response.rs | 11 ++---- .../delete_stopwords_set_200_response.rs | 11 ++---- typesense_codegen/src/models/facet_counts.rs | 11 ++---- .../src/models/facet_counts_counts_inner.rs | 7 +--- .../src/models/facet_counts_stats.rs | 7 +--- typesense_codegen/src/models/field.rs | 10 ++--- typesense_codegen/src/models/field_embed.rs | 11 ++---- .../src/models/field_embed_model_config.rs | 7 +--- typesense_codegen/src/models/health_status.rs | 11 ++---- ...list_stemming_dictionaries_200_response.rs | 11 ++---- .../src/models/multi_search_result.rs | 13 +++---- .../src/models/multi_search_result_item.rs | 19 ++++----- .../src/models/nl_search_model_base.rs | 7 +--- .../models/nl_search_model_delete_schema.rs | 11 ++---- .../src/models/nl_search_model_schema.rs | 7 +--- .../src/models/preset_delete_schema.rs | 11 ++---- typesense_codegen/src/models/preset_schema.rs | 11 ++---- .../src/models/presets_retrieve_schema.rs | 15 +++---- .../src/models/schema_change_status.rs | 7 +--- .../src/models/search_grouped_hit.rs | 14 ++----- .../src/models/search_highlight.rs | 7 +--- .../src/models/search_request_params.rs | 9 ++--- .../search_request_params_voice_query.rs | 7 +--- typesense_codegen/src/models/search_result.rs | 19 ++++----- .../src/models/search_result_conversation.rs | 7 +--- .../src/models/search_result_hit.rs | 13 +++---- .../search_result_hit_hybrid_search_info.rs | 7 +--- .../search_result_hit_text_match_info.rs | 7 +--- .../src/models/search_synonym.rs | 7 +--- .../models/search_synonym_delete_response.rs | 11 ++---- .../src/models/search_synonym_schema.rs | 7 +--- .../src/models/search_synonyms_response.rs | 15 +++---- .../src/models/stemming_dictionary.rs | 16 +++----- .../models/stemming_dictionary_words_inner.rs | 12 ++---- .../models/stopwords_set_retrieve_schema.rs | 11 ++---- .../src/models/stopwords_set_schema.rs | 7 +--- .../stopwords_sets_retrieve_all_schema.rs | 15 +++---- .../src/models/success_status.rs | 11 ++---- .../src/models/synonym_item_delete_schema.rs | 11 ++---- .../src/models/synonym_set_delete_schema.rs | 11 ++---- .../src/models/synonym_set_schema.rs | 16 +++----- .../models/synonym_sets_retrieve_schema.rs | 15 +++---- .../models/update_documents_200_response.rs | 11 ++---- .../voice_query_model_collection_config.rs | 11 ++---- xtask/src/add_vendor_attributes.rs | 15 +++---- xtask/src/preprocess_openapi.rs | 39 ++++++++++++------- 109 files changed, 493 insertions(+), 785 deletions(-) diff --git a/openapi-generator-template/model.mustache b/openapi-generator-template/model.mustache index b1856003..1ff1d53c 100644 --- a/openapi-generator-template/model.mustache +++ b/openapi-generator-template/model.mustache @@ -130,7 +130,7 @@ impl Default for {{classname}} { {{/vendorExtensions.x-rust-builder}}{{! }}{{#vendorExtensions.x-rust-has-byte-array}}#[serde_as]{{/vendorExtensions.x-rust-has-byte-array}}{{! }}{{#oneOf.isEmpty}}#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct {{{classname}}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}> { +pub struct {{{classname}}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}{{#vendorExtensions.x-rust-generic-parameter}}<{{{.}}}>{{/vendorExtensions.x-rust-generic-parameter}}{{/vendorExtensions.x-rust-is-used-as-input}} { {{#vars}} {{#description}} /// {{{.}}} @@ -149,7 +149,7 @@ pub struct {{{classname}}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{ ### Enums }}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{! ### Models - }}{{^isEnum}}{{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{{dataType}}}<'a>{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}{{! + }}{{^isEnum}}{{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{{dataType}}}{{#vendorExtensions.x-rust-is-used-as-input}}{{#model}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}<'static>{{/vendorExtensions.x-rust-is-used-as-input}}{{/model}}{{/vendorExtensions.x-rust-is-used-as-input}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}{{! ### ByteArray }}{{^isModel}}{{#isByteArray}}Vec{{/isByteArray}}{{! ### String @@ -157,7 +157,7 @@ pub struct {{{classname}}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{ ### Arrays }}{{^isString}}{{#isArray}}Vec<{{#items}}{{! ### Array Models - }}{{#isModel}}{{{dataType}}}<'a>{{/isModel}}{{! + }}{{#isModel}}{{{dataType}}}{{#vendorExtensions.x-rust-is-used-as-input}}{{#model}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}<'static>{{/vendorExtensions.x-rust-is-used-as-input}}{{/model}}{{/vendorExtensions.x-rust-is-used-as-input}}{{/isModel}}{{! ### Array other datatypes }}{{^isModel}}{{{dataType}}}{{/isModel}}{{/items}}>{{/isArray}}{{! ### Primitive datatypes @@ -170,12 +170,15 @@ pub struct {{{classname}}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{ }}{{#isNullable}}>{{/isNullable}}{{^required}}>{{/required}}, {{/vendorExtensions.x-rust-type}} {{/vars}} + {{#vendorExtensions.x-rust-is-used-as-input}} #[serde(skip)] {{#vendorExtensions.x-rust-builder}}#[builder(default)]{{/vendorExtensions.x-rust-builder}} pub _phantom: PhantomData<&'a ()>, + {{/vendorExtensions.x-rust-is-used-as-input}} } -impl<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}> {{{classname}}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}> { +impl{{#vendorExtensions.x-rust-is-used-as-input}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}{{#vendorExtensions.x-rust-generic-parameter}}<{{{.}}}>{{/vendorExtensions.x-rust-generic-parameter}}{{/vendorExtensions.x-rust-is-used-as-input}} {{! + }}{{{classname}}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}{{#vendorExtensions.x-rust-generic-parameter}}<{{{.}}}>{{/vendorExtensions.x-rust-generic-parameter}}{{/vendorExtensions.x-rust-is-used-as-input}} { {{#description}} /// {{{.}}} {{/description}} @@ -188,9 +191,9 @@ impl<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtension }}{{^isEnum}}{{#isByteArray}}Vec{{/isByteArray}}{{! }}{{^isByteArray}}{{#isString}}{{#model}}{{#vendorExtensions.x-rust-is-used-as-input}}Cow<'a, str>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}String{{/vendorExtensions.x-rust-is-used-as-input}}{{/model}}{{/isString}}{{! }}{{^isString}}{{#isArray}}Vec<{{#items}}{{! - }}{{#isModel}}{{{dataType}}}<'a>{{/isModel}}{{! + }}{{#isModel}}{{{dataType}}}{{#vendorExtensions.x-rust-is-used-as-input}}{{#model}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}<'static>{{/vendorExtensions.x-rust-is-used-as-input}}{{/model}}{{/vendorExtensions.x-rust-is-used-as-input}}{{/isModel}}{{! }}{{^isModel}}{{{dataType}}}{{/isModel}}{{/items}}>{{/isArray}}{{! - }}{{^isArray}}{{{dataType}}}{{#isModel}}<'a>{{/isModel}}{{! + }}{{^isArray}}{{{dataType}}}{{#isModel}}{{#vendorExtensions.x-rust-is-used-as-input}}{{#model}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}<'static>{{/vendorExtensions.x-rust-is-used-as-input}}{{/model}}{{/vendorExtensions.x-rust-is-used-as-input}}{{/isModel}}{{! }}{{/isArray}}{{/isString}}{{/isByteArray}}{{/isEnum}}{{! }}{{#isNullable}}>{{/isNullable}}{{/vendorExtensions.x-rust-type}}{{! ### Comma for next arguement @@ -210,7 +213,9 @@ impl<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtension {{{name}}}{{^required}}: None{{/required}}{{#required}}{{#isModel}}{{^avoidBoxedModels}}: {{^isNullable}}Box::new({{{name}}}){{/isNullable}}{{#isNullable}}if let Some(x) = {{{name}}} {Some(Box::new(x))} else {None}{{/isNullable}}{{/avoidBoxedModels}}{{/isModel}}{{/required}}, {{/vendorExtensions.x-rust-type}} {{/vars}} + {{#vendorExtensions.x-rust-is-used-as-input}} _phantom: PhantomData, + {{/vendorExtensions.x-rust-is-used-as-input}} } } } @@ -222,16 +227,16 @@ impl<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtension {{/description}} #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum {{classname}}<'a> { +pub enum {{classname}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a>{{/vendorExtensions.x-rust-is-used-as-input}} { {{#composedSchemas.oneOf}} {{#description}} /// {{{.}}} {{/description}} - {{{name}}}({{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{/isModel}}{{#isArray}}Vec<{{{items.dataType}}}<'a>>{{/isArray}}{{^isArray}}{{{dataType}}}<'a>{{/isArray}}{{#isModel}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}), + {{{name}}}({{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{/isModel}}{{#isArray}}Vec<{{{items.dataType}}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a>{{/vendorExtensions.x-rust-is-used-as-input}}>{{/isArray}}{{^isArray}}{{{dataType}}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a>{{/vendorExtensions.x-rust-is-used-as-input}}{{/isArray}}{{#isModel}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}), {{/composedSchemas.oneOf}} } -impl Default for {{classname}}<'_> { +impl Default for {{classname}}{{#vendorExtensions.x-rust-is-used-as-input}}<'_>{{/vendorExtensions.x-rust-is-used-as-input}} { fn default() -> Self { {{#composedSchemas.oneOf}}{{#-first}}Self::{{{name}}}(Default::default()){{/-first}}{{/composedSchemas.oneOf}} } diff --git a/openapi-generator-template/reqwest/api.mustache b/openapi-generator-template/reqwest/api.mustache index 2d47f00f..406f8901 100644 --- a/openapi-generator-template/reqwest/api.mustache +++ b/openapi-generator-template/reqwest/api.mustache @@ -64,10 +64,10 @@ pub struct {{{operationIdCamelCase}}}Params<'p{{! pub enum {{{operationIdCamelCase}}}Success { {{#responses}} {{#is2xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'static>{{/isEnum}}), + Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), {{/is2xx}} {{#is3xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'static>{{/isEnum}}), + Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), {{/is3xx}} {{/responses}} UnknownValue(serde_json::Value), @@ -84,13 +84,13 @@ pub enum {{{operationIdCamelCase}}}Success { pub enum {{{operationIdCamelCase}}}Error { {{#responses}} {{#is4xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'static>{{/isEnum}}), + Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), {{/is4xx}} {{#is5xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'static>{{/isEnum}}), + Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), {{/is5xx}} {{#isDefault}} - DefaultResponse({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}<'static>{{/isEnum}}), + DefaultResponse({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), {{/isDefault}} {{/responses}} UnknownValue(serde_json::Value), @@ -116,8 +116,8 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}{{#vendorExtensi }}{{#isResponseFile}}{{#supportAsync}}reqwest::Response{{/supportAsync}}{{^supportAsync}}reqwest::blocking::Response{{/supportAsync}}{{/isResponseFile}}{{! }}{{^isResponseFile}}{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{^supportMultipleResponses}}{{! }}{{^returnType}}(){{/returnType}}{{! -}}{{#isArray}}Vec<{{#returnProperty.items}}{{{dataType}}}{{#isModel}}<'static>{{/isModel}}{{/returnProperty.items}}>{{/isArray}}{{! -}}{{^isArray}}{{#returnProperty}}{{{dataType}}}{{#isModel}}<'static>{{/isModel}}{{/returnProperty}}{{! +}}{{#isArray}}Vec<{{#returnProperty.items}}{{{dataType}}}{{#isModel}}{{#vendorExtensions.x-rust-is-used-as-input}}<'static>{{/vendorExtensions.x-rust-is-used-as-input}}{{/isModel}}{{/returnProperty.items}}>{{/isArray}}{{! +}}{{^isArray}}{{#returnProperty}}{{{dataType}}}{{#isModel}}{{#vendorExtensions.x-rust-is-used-as-input}}<'static>{{/vendorExtensions.x-rust-is-used-as-input}}{{/isModel}}{{/returnProperty}}{{! }}{{/isArray}}{{/supportMultipleResponses}}{{/isResponseFile}}{{/vendorExtensions.x-rust-return-type}}, Error<{{{operationIdCamelCase}}}Error>> { {{/vendorExtensions.x-group-parameters}} let uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode(&{{/isString}}{{{vendorExtensions.x-rust-param-identifier}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isArray}}.join(",").as_ref(){{/isArray}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}.to_string(){{/isContainer}}{{/isPrimitiveType}}{{/isUuid}}{{/isString}}{{#isString}}){{/isString}}{{/pathParams}}); diff --git a/preprocessed_openapi.yml b/preprocessed_openapi.yml index ab2849b5..b5b62fda 100644 --- a/preprocessed_openapi.yml +++ b/preprocessed_openapi.yml @@ -278,6 +278,7 @@ paths: description: Can be any key-value pair type: object x-go-type: interface{} + x-rust-is-used-as-input: true responses: '201': description: Document successfully created/indexed @@ -319,6 +320,7 @@ paths: description: Can be any key-value pair type: object x-go-type: interface{} + x-rust-is-used-as-input: true x-rust-params-generic-parameter: B x-rust-type: B responses: @@ -844,7 +846,7 @@ paths: schema: $ref: '#/components/schemas/ApiResponse' x-rust-generic-parameter: 'D: for<''de> serde::Deserialize<''de> + Serialize' - x-rust-return-type: models::SearchResult<'static, D> + x-rust-return-type: models::SearchResult /synonym_sets: get: tags: @@ -1500,6 +1502,7 @@ paths: description: Can be any key-value pair type: object x-go-type: interface{} + x-rust-is-used-as-input: true x-rust-params-generic-parameter: B x-rust-type: B responses: @@ -1914,7 +1917,7 @@ paths: type: array items: $ref: '#/components/schemas/SchemaChangeStatus' - x-rust-return-type: Option>> + x-rust-return-type: Option> /operations/snapshot: post: tags: @@ -1997,6 +2000,7 @@ paths: properties: log-slow-requests-time-ms: type: integer + x-rust-is-used-as-input: true responses: '200': description: Compacting the on-disk database succeeded. @@ -2513,6 +2517,7 @@ paths: - type: array items: $ref: '#/components/schemas/AnalyticsRuleCreate' + x-rust-is-used-as-input: true responses: '200': description: Analytics rule(s) successfully created @@ -3414,13 +3419,13 @@ components: type: array items: $ref: '#/components/schemas/SearchGroupedHit' - x-rust-type: Option>> + x-rust-type: Option>> hits: description: The documents that matched the search query type: array items: $ref: '#/components/schemas/SearchResultHit' - x-rust-type: Option>> + x-rust-type: Option>> request_params: $ref: '#/components/schemas/SearchRequestParams' conversation: @@ -3487,7 +3492,7 @@ components: type: array items: $ref: '#/components/schemas/SearchResultHit' - x-rust-type: Vec> + x-rust-type: Vec> x-rust-generic-parameter: D SearchResultHit: type: object @@ -3747,7 +3752,7 @@ components: type: array items: $ref: '#/components/schemas/MultiSearchResultItem' - x-rust-type: Vec> + x-rust-type: Vec> conversation: $ref: '#/components/schemas/SearchResultConversation' x-rust-generic-parameter: D @@ -4619,6 +4624,7 @@ components: oneOf: - $ref: '#/components/schemas/SearchParameters' - $ref: '#/components/schemas/MultiSearchSearchesParameter' + x-rust-is-used-as-input: true x-rust-is-used-as-input: true PresetSchema: allOf: diff --git a/typesense/src/client/alias.rs b/typesense/src/client/alias.rs index 436180be..864143d4 100644 --- a/typesense/src/client/alias.rs +++ b/typesense/src/client/alias.rs @@ -23,7 +23,7 @@ impl<'a> Alias<'a> { /// Retrieves the details of a collection alias, including the collection it points to. pub async fn retrieve( &self, - ) -> Result, Error> { + ) -> Result> { let params = collections_api::GetAliasParams { alias_name: self.alias_name.into(), _phantom: core::marker::PhantomData, @@ -35,7 +35,7 @@ impl<'a> Alias<'a> { /// Deletes a collection alias. pub async fn delete( &self, - ) -> Result, Error> { + ) -> Result> { let params = collections_api::DeleteAliasParams { alias_name: self.alias_name.into(), _phantom: core::marker::PhantomData, diff --git a/typesense/src/client/aliases.rs b/typesense/src/client/aliases.rs index f7a33d5b..e50e0283 100644 --- a/typesense/src/client/aliases.rs +++ b/typesense/src/client/aliases.rs @@ -33,7 +33,7 @@ impl<'a> Aliases<'a> { &self, alias_name: impl Into>, schema: models::CollectionAliasSchema<'_>, - ) -> Result, Error> { + ) -> Result> { let params = collections_api::UpsertAliasParams { alias_name: alias_name.into(), collection_alias_schema: Some(schema), @@ -45,8 +45,7 @@ impl<'a> Aliases<'a> { /// Lists all aliases and the corresponding collections that they map to. pub async fn retrieve( &self, - ) -> Result, Error> - { + ) -> Result> { execute_wrapper!(self, collections_api::get_aliases) } } diff --git a/typesense/src/client/collection/documents.rs b/typesense/src/client/collection/documents.rs index fc0d67c0..91a41f55 100644 --- a/typesense/src/client/collection/documents.rs +++ b/typesense/src/client/collection/documents.rs @@ -120,10 +120,8 @@ where pub async fn delete( &self, params: DeleteDocumentsParameters<'_>, - ) -> Result< - raw_models::DeleteDocuments200Response<'static>, - Error, - > { + ) -> Result> + { let params = documents_api::DeleteDocumentsParams { collection_name: self.collection_name.into(), filter_by: Some(params.filter_by), @@ -143,7 +141,7 @@ where pub async fn search( &self, params: raw_models::SearchParameters<'_>, - ) -> Result, Error> { + ) -> Result, Error> { let search_params = documents_api::SearchCollectionParams { collection_name: self.collection_name.into(), @@ -275,10 +273,8 @@ where &self, document: &D::Partial, params: UpdateDocumentsParameters<'_>, - ) -> Result< - raw_models::UpdateDocuments200Response<'static>, - Error, - > { + ) -> Result> + { let params = documents_api::UpdateDocumentsParams { collection_name: self.collection_name.into(), filter_by: params.filter_by, diff --git a/typesense/src/client/collection/mod.rs b/typesense/src/client/collection/mod.rs index aa9b75b7..b8067f7f 100644 --- a/typesense/src/client/collection/mod.rs +++ b/typesense/src/client/collection/mod.rs @@ -55,8 +55,7 @@ where #[inline] pub async fn retrieve( &self, - ) -> Result, Error> - { + ) -> Result> { let params = collections_api::GetCollectionParams { collection_name: self.collection_name.as_ref().into(), _phantom: core::marker::PhantomData, @@ -68,8 +67,7 @@ where #[inline] pub async fn delete( &self, - ) -> Result, Error> - { + ) -> Result> { let params = collections_api::DeleteCollectionParams { collection_name: self.collection_name.as_ref().into(), _phantom: core::marker::PhantomData, diff --git a/typesense/src/client/collections.rs b/typesense/src/client/collections.rs index 6fe18b7b..723a2853 100644 --- a/typesense/src/client/collections.rs +++ b/typesense/src/client/collections.rs @@ -29,8 +29,7 @@ impl<'c> Collections<'c> { pub async fn create( &self, schema: models::CollectionSchema<'_>, - ) -> Result, Error> - { + ) -> Result> { let params = collections_api::CreateCollectionParams { collection_schema: schema, _phantom: core::marker::PhantomData, @@ -42,8 +41,7 @@ impl<'c> Collections<'c> { pub async fn retrieve( &self, params: GetCollectionsParameters<'_>, - ) -> Result>, Error> - { + ) -> Result, Error> { let params = GetCollectionsParams { exclude_fields: params.exclude_fields, limit: params.limit, diff --git a/typesense/src/client/conversations/model.rs b/typesense/src/client/conversations/model.rs index ce90cdab..78be6265 100644 --- a/typesense/src/client/conversations/model.rs +++ b/typesense/src/client/conversations/model.rs @@ -24,7 +24,7 @@ impl<'a> Model<'a> { pub async fn retrieve( &self, ) -> Result< - models::ConversationModelSchema<'static>, + models::ConversationModelSchema, Error, > { let params = conversations_api::RetrieveConversationModelParams { @@ -42,7 +42,7 @@ impl<'a> Model<'a> { &self, schema: models::ConversationModelUpdateSchema<'_>, ) -> Result< - models::ConversationModelSchema<'static>, + models::ConversationModelSchema, Error, > { let params = conversations_api::UpdateConversationModelParams { @@ -57,7 +57,7 @@ impl<'a> Model<'a> { pub async fn delete( &self, ) -> Result< - models::ConversationModelSchema<'static>, + models::ConversationModelSchema, Error, > { let params = conversations_api::DeleteConversationModelParams { diff --git a/typesense/src/client/conversations/models.rs b/typesense/src/client/conversations/models.rs index 1a7aad70..b178b959 100644 --- a/typesense/src/client/conversations/models.rs +++ b/typesense/src/client/conversations/models.rs @@ -27,7 +27,7 @@ impl<'a> Models<'a> { &self, schema: models::ConversationModelCreateSchema<'_>, ) -> Result< - models::ConversationModelSchema<'static>, + models::ConversationModelSchema, Error, > { let params = conversations_api::CreateConversationModelParams { @@ -41,7 +41,7 @@ impl<'a> Models<'a> { pub async fn retrieve( &self, ) -> Result< - Vec>, + Vec, Error, > { execute_wrapper!(self, conversations_api::retrieve_all_conversation_models) diff --git a/typesense/src/client/key.rs b/typesense/src/client/key.rs index e64a6365..a1ceb9b1 100644 --- a/typesense/src/client/key.rs +++ b/typesense/src/client/key.rs @@ -25,7 +25,7 @@ impl<'c> Key<'c> { /// For security reasons, this endpoint only returns the key prefix and metadata, /// not the full key value. #[inline] - pub async fn retrieve(&self) -> Result, Error> { + pub async fn retrieve(&self) -> Result> { let params = keys_api::GetKeyParams { key_id: self.key_id, _phantom: core::marker::PhantomData, @@ -37,7 +37,7 @@ impl<'c> Key<'c> { #[inline] pub async fn delete( &self, - ) -> Result, Error> { + ) -> Result> { let params = keys_api::DeleteKeyParams { key_id: self.key_id, _phantom: core::marker::PhantomData, diff --git a/typesense/src/client/keys.rs b/typesense/src/client/keys.rs index 77eb9aaa..f0a05098 100644 --- a/typesense/src/client/keys.rs +++ b/typesense/src/client/keys.rs @@ -36,7 +36,7 @@ impl<'c> Keys<'c> { pub async fn create( &self, schema: models::ApiKeySchema<'_>, - ) -> Result, Error> { + ) -> Result> { let params = keys_api::CreateKeyParams { api_key_schema: Some(schema), _phantom: core::marker::PhantomData, @@ -46,9 +46,7 @@ impl<'c> Keys<'c> { /// Lists all API keys and their metadata. #[inline] - pub async fn retrieve( - &self, - ) -> Result, Error> { + pub async fn retrieve(&self) -> Result> { execute_wrapper!(self, keys_api::get_keys) } diff --git a/typesense/src/client/multi_search.rs b/typesense/src/client/multi_search.rs index 1ae3c770..f66680ec 100644 --- a/typesense/src/client/multi_search.rs +++ b/typesense/src/client/multi_search.rs @@ -115,7 +115,7 @@ impl<'c> MultiSearch<'c> { search_requests: MultiSearchBody<'_>, common_search_params: raw_models::MultiSearchParameters<'_>, ) -> Result< - raw_models::MultiSearchResult<'static, serde_json::Value>, + raw_models::MultiSearchResult, Error, > { let request_body = raw_models::MultiSearchSearchesParameter { @@ -253,7 +253,7 @@ impl<'c> MultiSearch<'c> { &self, search_requests: MultiSearchBody<'_>, common_search_params: raw_models::MultiSearchParameters<'_>, - ) -> Result, Error> { + ) -> Result, Error> { // Explicitly set `union: true` for the request body let request_body = raw_models::MultiSearchSearchesParameter { union: Some(true), diff --git a/typesense/src/client/operations.rs b/typesense/src/client/operations.rs index 48992f06..2d48255b 100644 --- a/typesense/src/client/operations.rs +++ b/typesense/src/client/operations.rs @@ -28,9 +28,7 @@ impl<'a> Operations<'a> { /// to the specific node that responded successfully. /// /// Docs: - pub async fn debug( - &self, - ) -> Result, Error> { + pub async fn debug(&self) -> Result> { execute_wrapper!(self, debug_api::debug) } @@ -38,9 +36,7 @@ impl<'a> Operations<'a> { /// When a node is running out of memory / disk, the API response will have an additional resource_error field that's set to either `OUT_OF_DISK`` or `OUT_OF_MEMORY``. /// /// Docs: - pub async fn health( - &self, - ) -> Result, Error> { + pub async fn health(&self) -> Result> { execute_wrapper!(self, health_api::health) } @@ -99,8 +95,7 @@ impl<'a> Operations<'a> { /// Docs: pub async fn retrieve_api_stats( &self, - ) -> Result, Error> - { + ) -> Result> { execute_wrapper!(self, operations_api::retrieve_api_stats) } @@ -111,7 +106,7 @@ impl<'a> Operations<'a> { pub async fn take_snapshot( &self, params: operations_api::TakeSnapshotParams<'_>, - ) -> Result, Error> { + ) -> Result> { execute_wrapper!(self, operations_api::take_snapshot, params) } @@ -119,9 +114,7 @@ impl<'a> Operations<'a> { /// The follower node that you run this operation against will become the new leader, once this command succeeds. /// /// Docs: - pub async fn vote( - &self, - ) -> Result, Error> { + pub async fn vote(&self) -> Result> { execute_wrapper!(self, operations_api::vote) } @@ -130,10 +123,8 @@ impl<'a> Operations<'a> { /// Docs: pub async fn get_schema_changes( &self, - ) -> Result< - Option>>, - Error, - > { + ) -> Result>, Error> + { execute_wrapper!(self, operations_api::get_schema_changes) } @@ -143,7 +134,7 @@ impl<'a> Operations<'a> { /// Docs: pub async fn compact_db( &self, - ) -> Result, Error> { + ) -> Result> { execute_wrapper!(self, operations_api::compact_db) } @@ -152,7 +143,7 @@ impl<'a> Operations<'a> { /// Docs: pub async fn clear_cache( &self, - ) -> Result, Error> { + ) -> Result> { execute_wrapper!(self, operations_api::clear_cache) } @@ -163,8 +154,7 @@ impl<'a> Operations<'a> { pub async fn toggle_slow_request_log( &self, slow_requests_threshold_ms: i32, - ) -> Result, Error> - { + ) -> Result> { let params = operations_api::ToggleSlowRequestLogParams { toggle_slow_request_log_request: Some(models::ToggleSlowRequestLogRequest { log_slow_requests_time_ms: slow_requests_threshold_ms, diff --git a/typesense/src/client/preset.rs b/typesense/src/client/preset.rs index 6de356ae..f19f36f5 100644 --- a/typesense/src/client/preset.rs +++ b/typesense/src/client/preset.rs @@ -23,7 +23,7 @@ impl<'a> Preset<'a> { /// Retrieves the details of a preset, given its Id. pub async fn retrieve( &self, - ) -> Result, Error> { + ) -> Result> { let params = presets_api::RetrievePresetParams { preset_id: self.preset_id.into(), _phantom: core::marker::PhantomData, @@ -34,7 +34,7 @@ impl<'a> Preset<'a> { /// Permanently deletes a preset, given its Id. pub async fn delete( &self, - ) -> Result, Error> { + ) -> Result> { let params = presets_api::DeletePresetParams { preset_id: self.preset_id.into(), _phantom: core::marker::PhantomData, diff --git a/typesense/src/client/presets.rs b/typesense/src/client/presets.rs index 2e4e5762..bd2a3c2d 100644 --- a/typesense/src/client/presets.rs +++ b/typesense/src/client/presets.rs @@ -25,8 +25,7 @@ impl<'a> Presets<'a> { /// Retrieves the details of all presets. pub async fn retrieve( &self, - ) -> Result, Error> - { + ) -> Result> { execute_wrapper!(self, presets_api::retrieve_all_presets) } @@ -39,7 +38,7 @@ impl<'a> Presets<'a> { &self, preset_id: impl Into>, schema: models::PresetUpsertSchema<'_>, - ) -> Result, Error> { + ) -> Result> { let params = presets_api::UpsertPresetParams { preset_id: preset_id.into(), preset_upsert_schema: schema, diff --git a/typesense/src/client/stemming/dictionaries.rs b/typesense/src/client/stemming/dictionaries.rs index f43c8a4f..26715997 100644 --- a/typesense/src/client/stemming/dictionaries.rs +++ b/typesense/src/client/stemming/dictionaries.rs @@ -47,7 +47,7 @@ impl<'a> Dictionaries<'a> { pub async fn retrieve( &self, ) -> Result< - models::ListStemmingDictionaries200Response<'static>, + models::ListStemmingDictionaries200Response, Error, > { execute_wrapper!(self, stemming_api::list_stemming_dictionaries) diff --git a/typesense/src/client/stemming/dictionary.rs b/typesense/src/client/stemming/dictionary.rs index 2ccc41cd..6bc40258 100644 --- a/typesense/src/client/stemming/dictionary.rs +++ b/typesense/src/client/stemming/dictionary.rs @@ -29,8 +29,7 @@ impl<'a> Dictionary<'a> { /// Retrieves the details of this specific stemming dictionary. pub async fn retrieve( &self, - ) -> Result, Error> - { + ) -> Result> { let params = stemming_api::GetStemmingDictionaryParams { dictionary_id: self.dictionary_id.into(), _phantom: core::marker::PhantomData, diff --git a/typesense/src/client/stopword.rs b/typesense/src/client/stopword.rs index 5fb04e86..fdaa99a1 100644 --- a/typesense/src/client/stopword.rs +++ b/typesense/src/client/stopword.rs @@ -23,10 +23,8 @@ impl<'a> Stopword<'a> { /// Retrieves the details of this specific stopwords set. pub async fn retrieve( &self, - ) -> Result< - models::StopwordsSetRetrieveSchema<'static>, - Error, - > { + ) -> Result> + { let params = stopwords_api::RetrieveStopwordsSetParams { set_id: self.set_id.into(), _phantom: core::marker::PhantomData, @@ -37,10 +35,8 @@ impl<'a> Stopword<'a> { /// Permanently deletes this specific stopwords set. pub async fn delete( &self, - ) -> Result< - models::DeleteStopwordsSet200Response<'static>, - Error, - > { + ) -> Result> + { let params = stopwords_api::DeleteStopwordsSetParams { set_id: self.set_id.into(), _phantom: core::marker::PhantomData, diff --git a/typesense/src/client/stopwords.rs b/typesense/src/client/stopwords.rs index cc833416..b896a133 100644 --- a/typesense/src/client/stopwords.rs +++ b/typesense/src/client/stopwords.rs @@ -29,8 +29,7 @@ impl<'a> Stopwords<'a> { &self, set_id: impl Into>, schema: models::StopwordsSetUpsertSchema<'_>, - ) -> Result, Error> - { + ) -> Result> { let params = stopwords_api::UpsertStopwordsSetParams { set_id: set_id.into(), stopwords_set_upsert_schema: schema, @@ -43,7 +42,7 @@ impl<'a> Stopwords<'a> { pub async fn retrieve( &self, ) -> Result< - models::StopwordsSetsRetrieveAllSchema<'static>, + models::StopwordsSetsRetrieveAllSchema, Error, > { execute_wrapper!(self, stopwords_api::retrieve_stopwords_sets) diff --git a/typesense/src/traits/multi_search_ext.rs b/typesense/src/traits/multi_search_ext.rs index 8bb233f2..dba598f3 100644 --- a/typesense/src/traits/multi_search_ext.rs +++ b/typesense/src/traits/multi_search_ext.rs @@ -5,7 +5,7 @@ use serde_json::Value; use crate::{MultiSearchParseError, models::SearchResult}; /// An extension trait for `MultiSearchResult` to provide typed parsing. -pub trait MultiSearchResultExt<'a> { +pub trait MultiSearchResultExt { /// Parses the result at a specific index from a multi-search response into a strongly-typed `SearchResult`. /// /// # Arguments @@ -14,9 +14,9 @@ pub trait MultiSearchResultExt<'a> { /// # Type Parameters /// * `D` - The concrete document type to deserialize the hits into. fn parse_at( - &'a self, + &self, index: usize, - ) -> Result, MultiSearchParseError>; + ) -> Result, MultiSearchParseError>; } /// Small helpers to convert documents stored as `serde_json::Value` into a concrete `D`. @@ -29,9 +29,9 @@ fn deserialize_opt_document( } } -fn convert_hit_ref<'a, D: DeserializeOwned>( - raw_hit: &SearchResultHit<'a, Value>, -) -> Result, serde_json::Error> { +fn convert_hit_ref( + raw_hit: &SearchResultHit, +) -> Result, serde_json::Error> { Ok(SearchResultHit { document: deserialize_opt_document(raw_hit.document.clone())?, highlights: raw_hit.highlights.clone(), @@ -42,13 +42,12 @@ fn convert_hit_ref<'a, D: DeserializeOwned>( vector_distance: raw_hit.vector_distance, hybrid_search_info: raw_hit.hybrid_search_info.clone(), search_index: raw_hit.search_index, - _phantom: core::marker::PhantomData, }) } -fn convert_group_ref<'a, D: DeserializeOwned>( - raw_group: &'a SearchGroupedHit<'_, Value>, -) -> Result, serde_json::Error> { +fn convert_group_ref( + raw_group: &SearchGroupedHit, +) -> Result, serde_json::Error> { let hits = raw_group .hits .iter() @@ -59,14 +58,13 @@ fn convert_group_ref<'a, D: DeserializeOwned>( found: raw_group.found, group_key: raw_group.group_key.clone(), hits, - _phantom: core::marker::PhantomData, }) } /// Convert a single `MultiSearchResultItem` into a strongly-typed `SearchResult`. -fn multi_search_item_to_search_result<'a, D: DeserializeOwned>( - item: &'a MultiSearchResultItem<'_, Value>, -) -> Result, serde_json::Error> { +fn multi_search_item_to_search_result( + item: &MultiSearchResultItem, +) -> Result, serde_json::Error> { let typed_hits = match &item.hits { Some(raw_hits) => Some( raw_hits @@ -101,16 +99,15 @@ fn multi_search_item_to_search_result<'a, D: DeserializeOwned>( conversation: item.conversation.clone(), union_request_params: item.union_request_params.clone(), metadata: item.metadata.clone(), - _phantom: core::marker::PhantomData, }) } /// Extension to parse an item out of a `MultiSearchResult` into a typed `SearchResult`. -impl<'a> MultiSearchResultExt<'a> for MultiSearchResult<'a, Value> { +impl MultiSearchResultExt for MultiSearchResult { fn parse_at( - &'a self, + &self, index: usize, - ) -> Result, MultiSearchParseError> { + ) -> Result, MultiSearchParseError> { let raw_item = self .results .get(index) diff --git a/typesense_codegen/src/apis/analytics_api.rs b/typesense_codegen/src/apis/analytics_api.rs index c5a83d3f..733a8781 100644 --- a/typesense_codegen/src/apis/analytics_api.rs +++ b/typesense_codegen/src/apis/analytics_api.rs @@ -79,7 +79,7 @@ pub struct UpsertAnalyticsRuleParams<'p> { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum CreateAnalyticsEventError { - Status400(models::ApiResponse<'static>), + Status400(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -87,7 +87,7 @@ pub enum CreateAnalyticsEventError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum CreateAnalyticsRuleError { - Status400(models::ApiResponse<'static>), + Status400(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -95,7 +95,7 @@ pub enum CreateAnalyticsRuleError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteAnalyticsRuleError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -110,7 +110,7 @@ pub enum FlushAnalyticsError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetAnalyticsEventsError { - Status400(models::ApiResponse<'static>), + Status400(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -125,7 +125,7 @@ pub enum GetAnalyticsStatusError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveAnalyticsRuleError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -140,7 +140,7 @@ pub enum RetrieveAnalyticsRulesError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum UpsertAnalyticsRuleError { - Status400(models::ApiResponse<'static>), + Status400(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -148,7 +148,7 @@ pub enum UpsertAnalyticsRuleError { pub async fn create_analytics_event( configuration: &configuration::Configuration, params: &CreateAnalyticsEventParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/analytics/events", configuration.base_path); let mut req_builder = configuration .client @@ -208,7 +208,7 @@ pub async fn create_analytics_event( pub async fn create_analytics_rule( configuration: &configuration::Configuration, params: &CreateAnalyticsRuleParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/analytics/rules", configuration.base_path); let mut req_builder = configuration .client @@ -268,7 +268,7 @@ pub async fn create_analytics_rule( pub async fn delete_analytics_rule( configuration: &configuration::Configuration, params: &DeleteAnalyticsRuleParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/analytics/rules/{ruleName}", configuration.base_path, @@ -330,7 +330,7 @@ pub async fn delete_analytics_rule( /// Triggers a flush of analytics data to persistent storage. pub async fn flush_analytics( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/analytics/flush", configuration.base_path); let mut req_builder = configuration .client @@ -389,7 +389,7 @@ pub async fn flush_analytics( pub async fn get_analytics_events( configuration: &configuration::Configuration, params: &GetAnalyticsEventsParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/analytics/events", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -448,7 +448,7 @@ pub async fn get_analytics_events( /// Returns sizes of internal analytics buffers and queues. pub async fn get_analytics_status( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/analytics/status", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -505,7 +505,7 @@ pub async fn get_analytics_status( pub async fn retrieve_analytics_rule( configuration: &configuration::Configuration, params: &RetrieveAnalyticsRuleParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/analytics/rules/{ruleName}", configuration.base_path, @@ -566,7 +566,7 @@ pub async fn retrieve_analytics_rule( pub async fn retrieve_analytics_rules( configuration: &configuration::Configuration, params: &RetrieveAnalyticsRulesParams<'_>, -) -> Result>, Error> { +) -> Result, Error> { let uri_str = format!("{}/analytics/rules", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -626,7 +626,7 @@ pub async fn retrieve_analytics_rules( pub async fn upsert_analytics_rule( configuration: &configuration::Configuration, params: &UpsertAnalyticsRuleParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/analytics/rules/{ruleName}", configuration.base_path, diff --git a/typesense_codegen/src/apis/collections_api.rs b/typesense_codegen/src/apis/collections_api.rs index a443ff74..99a420a4 100644 --- a/typesense_codegen/src/apis/collections_api.rs +++ b/typesense_codegen/src/apis/collections_api.rs @@ -87,8 +87,8 @@ pub struct UpsertAliasParams<'p> { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum CreateCollectionError { - Status400(models::ApiResponse<'static>), - Status409(models::ApiResponse<'static>), + Status400(models::ApiResponse), + Status409(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -96,7 +96,7 @@ pub enum CreateCollectionError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteAliasError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -104,7 +104,7 @@ pub enum DeleteAliasError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteCollectionError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -112,7 +112,7 @@ pub enum DeleteCollectionError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetAliasError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -127,7 +127,7 @@ pub enum GetAliasesError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetCollectionError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -142,8 +142,8 @@ pub enum GetCollectionsError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum UpdateCollectionError { - Status400(models::ApiResponse<'static>), - Status404(models::ApiResponse<'static>), + Status400(models::ApiResponse), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -151,8 +151,8 @@ pub enum UpdateCollectionError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum UpsertAliasError { - Status400(models::ApiResponse<'static>), - Status404(models::ApiResponse<'static>), + Status400(models::ApiResponse), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -160,7 +160,7 @@ pub enum UpsertAliasError { pub async fn create_collection( configuration: &configuration::Configuration, params: &CreateCollectionParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/collections", configuration.base_path); let mut req_builder = configuration .client @@ -219,7 +219,7 @@ pub async fn create_collection( pub async fn delete_alias( configuration: &configuration::Configuration, params: &DeleteAliasParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/aliases/{aliasName}", configuration.base_path, @@ -282,7 +282,7 @@ pub async fn delete_alias( pub async fn delete_collection( configuration: &configuration::Configuration, params: &DeleteCollectionParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/collections/{collectionName}", configuration.base_path, @@ -345,7 +345,7 @@ pub async fn delete_collection( pub async fn get_alias( configuration: &configuration::Configuration, params: &GetAliasParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/aliases/{aliasName}", configuration.base_path, @@ -405,7 +405,7 @@ pub async fn get_alias( /// List all aliases and the corresponding collections that they map to. pub async fn get_aliases( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/aliases", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -462,7 +462,7 @@ pub async fn get_aliases( pub async fn get_collection( configuration: &configuration::Configuration, params: &GetCollectionParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/collections/{collectionName}", configuration.base_path, @@ -523,7 +523,7 @@ pub async fn get_collection( pub async fn get_collections( configuration: &configuration::Configuration, params: &GetCollectionsParams<'_>, -) -> Result>, Error> { +) -> Result, Error> { let uri_str = format!("{}/collections", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -653,7 +653,7 @@ pub async fn update_collection( pub async fn upsert_alias( configuration: &configuration::Configuration, params: &UpsertAliasParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/aliases/{aliasName}", configuration.base_path, diff --git a/typesense_codegen/src/apis/conversations_api.rs b/typesense_codegen/src/apis/conversations_api.rs index d67c931a..a357be09 100644 --- a/typesense_codegen/src/apis/conversations_api.rs +++ b/typesense_codegen/src/apis/conversations_api.rs @@ -50,7 +50,7 @@ pub struct UpdateConversationModelParams<'p> { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum CreateConversationModelError { - Status400(models::ApiResponse<'static>), + Status400(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -86,7 +86,7 @@ pub enum UpdateConversationModelError { pub async fn create_conversation_model( configuration: &configuration::Configuration, params: &CreateConversationModelParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/conversations/models", configuration.base_path); let mut req_builder = configuration .client @@ -146,7 +146,7 @@ pub async fn create_conversation_model( pub async fn delete_conversation_model( configuration: &configuration::Configuration, params: &DeleteConversationModelParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/conversations/models/{modelId}", configuration.base_path, @@ -208,8 +208,7 @@ pub async fn delete_conversation_model( /// Retrieve all conversation models pub async fn retrieve_all_conversation_models( configuration: &configuration::Configuration, -) -> Result>, Error> -{ +) -> Result, Error> { let uri_str = format!("{}/conversations/models", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -267,7 +266,7 @@ pub async fn retrieve_all_conversation_models( pub async fn retrieve_conversation_model( configuration: &configuration::Configuration, params: &RetrieveConversationModelParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/conversations/models/{modelId}", configuration.base_path, @@ -328,7 +327,7 @@ pub async fn retrieve_conversation_model( pub async fn update_conversation_model( configuration: &configuration::Configuration, params: &UpdateConversationModelParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/conversations/models/{modelId}", configuration.base_path, diff --git a/typesense_codegen/src/apis/curation_sets_api.rs b/typesense_codegen/src/apis/curation_sets_api.rs index 38151429..518eab07 100644 --- a/typesense_codegen/src/apis/curation_sets_api.rs +++ b/typesense_codegen/src/apis/curation_sets_api.rs @@ -84,7 +84,7 @@ pub struct UpsertCurationSetItemParams<'p> { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteCurationSetError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -92,7 +92,7 @@ pub enum DeleteCurationSetError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteCurationSetItemError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -100,7 +100,7 @@ pub enum DeleteCurationSetItemError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveCurationSetError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -108,7 +108,7 @@ pub enum RetrieveCurationSetError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveCurationSetItemError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -116,7 +116,7 @@ pub enum RetrieveCurationSetItemError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveCurationSetItemsError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -131,7 +131,7 @@ pub enum RetrieveCurationSetsError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum UpsertCurationSetError { - Status400(models::ApiResponse<'static>), + Status400(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -139,7 +139,7 @@ pub enum UpsertCurationSetError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum UpsertCurationSetItemError { - Status400(models::ApiResponse<'static>), + Status400(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -147,7 +147,7 @@ pub enum UpsertCurationSetItemError { pub async fn delete_curation_set( configuration: &configuration::Configuration, params: &DeleteCurationSetParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/curation_sets/{curationSetName}", configuration.base_path, @@ -210,7 +210,7 @@ pub async fn delete_curation_set( pub async fn delete_curation_set_item( configuration: &configuration::Configuration, params: &DeleteCurationSetItemParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/curation_sets/{curationSetName}/items/{itemId}", configuration.base_path, @@ -335,7 +335,7 @@ pub async fn retrieve_curation_set( pub async fn retrieve_curation_set_item( configuration: &configuration::Configuration, params: &RetrieveCurationSetItemParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/curation_sets/{curationSetName}/items/{itemId}", configuration.base_path, @@ -397,7 +397,7 @@ pub async fn retrieve_curation_set_item( pub async fn retrieve_curation_set_items( configuration: &configuration::Configuration, params: &RetrieveCurationSetItemsParams<'_>, -) -> Result>, Error> { +) -> Result, Error> { let uri_str = format!( "{}/curation_sets/{curationSetName}/items", configuration.base_path, @@ -457,7 +457,7 @@ pub async fn retrieve_curation_set_items( /// Retrieve all curation sets pub async fn retrieve_curation_sets( configuration: &configuration::Configuration, -) -> Result>, Error> { +) -> Result, Error> { let uri_str = format!("{}/curation_sets", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -514,7 +514,7 @@ pub async fn retrieve_curation_sets( pub async fn upsert_curation_set( configuration: &configuration::Configuration, params: &UpsertCurationSetParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/curation_sets/{curationSetName}", configuration.base_path, @@ -576,7 +576,7 @@ pub async fn upsert_curation_set( pub async fn upsert_curation_set_item( configuration: &configuration::Configuration, params: &UpsertCurationSetItemParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/curation_sets/{curationSetName}/items/{itemId}", configuration.base_path, diff --git a/typesense_codegen/src/apis/debug_api.rs b/typesense_codegen/src/apis/debug_api.rs index faf05f4a..eecdf103 100644 --- a/typesense_codegen/src/apis/debug_api.rs +++ b/typesense_codegen/src/apis/debug_api.rs @@ -24,7 +24,7 @@ pub enum DebugError { /// Print debugging information pub async fn debug( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/debug", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); diff --git a/typesense_codegen/src/apis/documents_api.rs b/typesense_codegen/src/apis/documents_api.rs index fcb83805..77f583db 100644 --- a/typesense_codegen/src/apis/documents_api.rs +++ b/typesense_codegen/src/apis/documents_api.rs @@ -266,7 +266,7 @@ pub struct UpdateDocumentsParams<'p, B> { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteDocumentError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -274,7 +274,7 @@ pub enum DeleteDocumentError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteDocumentsError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -282,7 +282,7 @@ pub enum DeleteDocumentsError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ExportDocumentsError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -290,7 +290,7 @@ pub enum ExportDocumentsError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetDocumentError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -298,8 +298,8 @@ pub enum GetDocumentError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ImportDocumentsError { - Status400(models::ApiResponse<'static>), - Status404(models::ApiResponse<'static>), + Status400(models::ApiResponse), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -307,7 +307,7 @@ pub enum ImportDocumentsError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum IndexDocumentError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -315,7 +315,7 @@ pub enum IndexDocumentError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum MultiSearchError { - Status400(models::ApiResponse<'static>), + Status400(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -323,8 +323,8 @@ pub enum MultiSearchError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SearchCollectionError { - Status400(models::ApiResponse<'static>), - Status404(models::ApiResponse<'static>), + Status400(models::ApiResponse), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -332,7 +332,7 @@ pub enum SearchCollectionError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum UpdateDocumentError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -340,8 +340,8 @@ pub enum UpdateDocumentError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum UpdateDocumentsError { - Status400(models::ApiResponse<'static>), - Status404(models::ApiResponse<'static>), + Status400(models::ApiResponse), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -413,7 +413,7 @@ pub async fn delete_document( pub async fn delete_documents( configuration: &configuration::Configuration, params: &DeleteDocumentsParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/collections/{collectionName}/documents", configuration.base_path, @@ -1027,7 +1027,7 @@ pub async fn multi_search( pub async fn search_collection serde::Deserialize<'de> + Serialize>( configuration: &configuration::Configuration, params: &SearchCollectionParams<'_>, -) -> Result, Error> { +) -> Result, Error> { let uri_str = format!( "{}/collections/{collectionName}/documents/search", configuration.base_path, @@ -1287,12 +1287,12 @@ pub async fn search_collection serde::Deserialize<'de> + Serialize>( ContentType::Json => serde_json::from_str(&content).map_err(Error::from), ContentType::Text => { return Err(Error::from(serde_json::Error::custom( - "Received `text/plain` content type response that cannot be converted to `models::SearchResult<'static, D>`", + "Received `text/plain` content type response that cannot be converted to `models::SearchResult`", ))); } ContentType::Unsupported(unknown_type) => { return Err(Error::from(serde_json::Error::custom(format!( - "Received `{unknown_type}` content type response that cannot be converted to `models::SearchResult<'static, D>`" + "Received `{unknown_type}` content type response that cannot be converted to `models::SearchResult`" )))); } } @@ -1379,7 +1379,7 @@ pub async fn update_document( pub async fn update_documents( configuration: &configuration::Configuration, params: &UpdateDocumentsParams<'_, B>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/collections/{collectionName}/documents", configuration.base_path, diff --git a/typesense_codegen/src/apis/health_api.rs b/typesense_codegen/src/apis/health_api.rs index f0b7ae41..f8900dde 100644 --- a/typesense_codegen/src/apis/health_api.rs +++ b/typesense_codegen/src/apis/health_api.rs @@ -24,7 +24,7 @@ pub enum HealthError { /// Checks if Typesense server is ready to accept requests. pub async fn health( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/health", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); diff --git a/typesense_codegen/src/apis/keys_api.rs b/typesense_codegen/src/apis/keys_api.rs index a3338f40..c9b7e6c0 100644 --- a/typesense_codegen/src/apis/keys_api.rs +++ b/typesense_codegen/src/apis/keys_api.rs @@ -42,8 +42,8 @@ pub struct GetKeyParams<'p> { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum CreateKeyError { - Status400(models::ApiResponse<'static>), - Status409(models::ApiResponse<'static>), + Status400(models::ApiResponse), + Status409(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -51,8 +51,8 @@ pub enum CreateKeyError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteKeyError { - Status400(models::ApiResponse<'static>), - Status404(models::ApiResponse<'static>), + Status400(models::ApiResponse), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -60,7 +60,7 @@ pub enum DeleteKeyError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetKeyError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -75,7 +75,7 @@ pub enum GetKeysError { pub async fn create_key( configuration: &configuration::Configuration, params: &CreateKeyParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/keys", configuration.base_path); let mut req_builder = configuration .client @@ -134,7 +134,7 @@ pub async fn create_key( pub async fn delete_key( configuration: &configuration::Configuration, params: &DeleteKeyParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/keys/{keyId}", configuration.base_path, @@ -197,7 +197,7 @@ pub async fn delete_key( pub async fn get_key( configuration: &configuration::Configuration, params: &GetKeyParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/keys/{keyId}", configuration.base_path, @@ -256,7 +256,7 @@ pub async fn get_key( pub async fn get_keys( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/keys", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); diff --git a/typesense_codegen/src/apis/nl_search_models_api.rs b/typesense_codegen/src/apis/nl_search_models_api.rs index 2ee2b37c..9aca2551 100644 --- a/typesense_codegen/src/apis/nl_search_models_api.rs +++ b/typesense_codegen/src/apis/nl_search_models_api.rs @@ -52,7 +52,7 @@ pub struct UpdateNlSearchModelParams<'p> { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum CreateNlSearchModelError { - Status400(models::ApiResponse<'static>), + Status400(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -60,7 +60,7 @@ pub enum CreateNlSearchModelError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteNlSearchModelError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -75,7 +75,7 @@ pub enum RetrieveAllNlSearchModelsError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveNlSearchModelError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -83,8 +83,8 @@ pub enum RetrieveNlSearchModelError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum UpdateNlSearchModelError { - Status400(models::ApiResponse<'static>), - Status404(models::ApiResponse<'static>), + Status400(models::ApiResponse), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -92,7 +92,7 @@ pub enum UpdateNlSearchModelError { pub async fn create_nl_search_model( configuration: &configuration::Configuration, params: &CreateNlSearchModelParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/nl_search_models", configuration.base_path); let mut req_builder = configuration .client @@ -152,7 +152,7 @@ pub async fn create_nl_search_model( pub async fn delete_nl_search_model( configuration: &configuration::Configuration, params: &DeleteNlSearchModelParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/nl_search_models/{modelId}", configuration.base_path, @@ -214,7 +214,7 @@ pub async fn delete_nl_search_model( /// Retrieve all NL search models. pub async fn retrieve_all_nl_search_models( configuration: &configuration::Configuration, -) -> Result>, Error> { +) -> Result, Error> { let uri_str = format!("{}/nl_search_models", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -271,7 +271,7 @@ pub async fn retrieve_all_nl_search_models( pub async fn retrieve_nl_search_model( configuration: &configuration::Configuration, params: &RetrieveNlSearchModelParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/nl_search_models/{modelId}", configuration.base_path, @@ -332,7 +332,7 @@ pub async fn retrieve_nl_search_model( pub async fn update_nl_search_model( configuration: &configuration::Configuration, params: &UpdateNlSearchModelParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/nl_search_models/{modelId}", configuration.base_path, diff --git a/typesense_codegen/src/apis/operations_api.rs b/typesense_codegen/src/apis/operations_api.rs index 613eef9b..b85c1e8e 100644 --- a/typesense_codegen/src/apis/operations_api.rs +++ b/typesense_codegen/src/apis/operations_api.rs @@ -88,7 +88,7 @@ pub enum VoteError { /// Clear the cached responses of search requests that are sent with `use_cache` parameter in the LRU cache. pub async fn clear_cache( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/operations/cache/clear", configuration.base_path); let mut req_builder = configuration .client @@ -146,7 +146,7 @@ pub async fn clear_cache( /// Typesense uses RocksDB to store your documents on the disk. If you do frequent writes or updates, you could benefit from running a compaction of the underlying RocksDB database. This could reduce the size of the database and decrease read latency. While the database will not block during this operation, we recommend running it during off-peak hours. pub async fn compact_db( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/operations/db/compact", configuration.base_path); let mut req_builder = configuration .client @@ -204,7 +204,7 @@ pub async fn compact_db( /// Returns the status of any ongoing schema change operations. If no schema changes are in progress, returns an empty response. pub async fn get_schema_changes( configuration: &configuration::Configuration, -) -> Result>>, Error> { +) -> Result>, Error> { let uri_str = format!("{}/operations/schema_changes", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -237,12 +237,12 @@ pub async fn get_schema_changes( ContentType::Json => serde_json::from_str(&content).map_err(Error::from), ContentType::Text => { return Err(Error::from(serde_json::Error::custom( - "Received `text/plain` content type response that cannot be converted to `Option>>`", + "Received `text/plain` content type response that cannot be converted to `Option>`", ))); } ContentType::Unsupported(unknown_type) => { return Err(Error::from(serde_json::Error::custom(format!( - "Received `{unknown_type}` content type response that cannot be converted to `Option>>`" + "Received `{unknown_type}` content type response that cannot be converted to `Option>`" )))); } } @@ -260,7 +260,7 @@ pub async fn get_schema_changes( /// Retrieve the stats about API endpoints. pub async fn retrieve_api_stats( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/stats.json", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -373,7 +373,7 @@ pub async fn retrieve_metrics( pub async fn take_snapshot( configuration: &configuration::Configuration, params: &TakeSnapshotParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/operations/snapshot", configuration.base_path); let mut req_builder = configuration .client @@ -433,7 +433,7 @@ pub async fn take_snapshot( pub async fn toggle_slow_request_log( configuration: &configuration::Configuration, params: &ToggleSlowRequestLogParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/config", configuration.base_path); let mut req_builder = configuration .client @@ -492,7 +492,7 @@ pub async fn toggle_slow_request_log( /// Triggers a follower node to initiate the raft voting process, which triggers leader re-election. The follower node that you run this operation against will become the new leader, once this command succeeds. pub async fn vote( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/operations/vote", configuration.base_path); let mut req_builder = configuration .client diff --git a/typesense_codegen/src/apis/presets_api.rs b/typesense_codegen/src/apis/presets_api.rs index 9937fa2a..7edaed09 100644 --- a/typesense_codegen/src/apis/presets_api.rs +++ b/typesense_codegen/src/apis/presets_api.rs @@ -44,7 +44,7 @@ pub struct UpsertPresetParams<'p> { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeletePresetError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -59,7 +59,7 @@ pub enum RetrieveAllPresetsError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrievePresetError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -67,7 +67,7 @@ pub enum RetrievePresetError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum UpsertPresetError { - Status400(models::ApiResponse<'static>), + Status400(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -75,7 +75,7 @@ pub enum UpsertPresetError { pub async fn delete_preset( configuration: &configuration::Configuration, params: &DeletePresetParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/presets/{presetId}", configuration.base_path, @@ -137,7 +137,7 @@ pub async fn delete_preset( /// Retrieve the details of all presets pub async fn retrieve_all_presets( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/presets", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -194,7 +194,7 @@ pub async fn retrieve_all_presets( pub async fn retrieve_preset( configuration: &configuration::Configuration, params: &RetrievePresetParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/presets/{presetId}", configuration.base_path, @@ -255,7 +255,7 @@ pub async fn retrieve_preset( pub async fn upsert_preset( configuration: &configuration::Configuration, params: &UpsertPresetParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/presets/{presetId}", configuration.base_path, diff --git a/typesense_codegen/src/apis/stemming_api.rs b/typesense_codegen/src/apis/stemming_api.rs index c8f1213e..45ce58c1 100644 --- a/typesense_codegen/src/apis/stemming_api.rs +++ b/typesense_codegen/src/apis/stemming_api.rs @@ -36,7 +36,7 @@ pub struct ImportStemmingDictionaryParams<'p> { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetStemmingDictionaryError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -44,7 +44,7 @@ pub enum GetStemmingDictionaryError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ImportStemmingDictionaryError { - Status400(models::ApiResponse<'static>), + Status400(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -59,7 +59,7 @@ pub enum ListStemmingDictionariesError { pub async fn get_stemming_dictionary( configuration: &configuration::Configuration, params: &GetStemmingDictionaryParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/stemming/dictionaries/{dictionaryId}", configuration.base_path, @@ -177,10 +177,7 @@ pub async fn import_stemming_dictionary( /// Retrieve a list of all available stemming dictionaries. pub async fn list_stemming_dictionaries( configuration: &configuration::Configuration, -) -> Result< - models::ListStemmingDictionaries200Response<'static>, - Error, -> { +) -> Result> { let uri_str = format!("{}/stemming/dictionaries", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); diff --git a/typesense_codegen/src/apis/stopwords_api.rs b/typesense_codegen/src/apis/stopwords_api.rs index 1a6a2e21..08cdffc8 100644 --- a/typesense_codegen/src/apis/stopwords_api.rs +++ b/typesense_codegen/src/apis/stopwords_api.rs @@ -44,7 +44,7 @@ pub struct UpsertStopwordsSetParams<'p> { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteStopwordsSetError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -52,7 +52,7 @@ pub enum DeleteStopwordsSetError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveStopwordsSetError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -67,7 +67,7 @@ pub enum RetrieveStopwordsSetsError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum UpsertStopwordsSetError { - Status400(models::ApiResponse<'static>), + Status400(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -75,7 +75,7 @@ pub enum UpsertStopwordsSetError { pub async fn delete_stopwords_set( configuration: &configuration::Configuration, params: &DeleteStopwordsSetParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/stopwords/{setId}", configuration.base_path, @@ -138,7 +138,7 @@ pub async fn delete_stopwords_set( pub async fn retrieve_stopwords_set( configuration: &configuration::Configuration, params: &RetrieveStopwordsSetParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/stopwords/{setId}", configuration.base_path, @@ -198,7 +198,7 @@ pub async fn retrieve_stopwords_set( /// Retrieve the details of all stopwords sets pub async fn retrieve_stopwords_sets( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result> { let uri_str = format!("{}/stopwords", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -255,7 +255,7 @@ pub async fn retrieve_stopwords_sets( pub async fn upsert_stopwords_set( configuration: &configuration::Configuration, params: &UpsertStopwordsSetParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/stopwords/{setId}", configuration.base_path, diff --git a/typesense_codegen/src/apis/synonyms_api.rs b/typesense_codegen/src/apis/synonyms_api.rs index 3350319d..9dea9d80 100644 --- a/typesense_codegen/src/apis/synonyms_api.rs +++ b/typesense_codegen/src/apis/synonyms_api.rs @@ -84,7 +84,7 @@ pub struct UpsertSynonymSetItemParams<'p> { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteSynonymSetError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -92,7 +92,7 @@ pub enum DeleteSynonymSetError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteSynonymSetItemError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -100,7 +100,7 @@ pub enum DeleteSynonymSetItemError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveSynonymSetError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -108,7 +108,7 @@ pub enum RetrieveSynonymSetError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveSynonymSetItemError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -116,7 +116,7 @@ pub enum RetrieveSynonymSetItemError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RetrieveSynonymSetItemsError { - Status404(models::ApiResponse<'static>), + Status404(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -131,7 +131,7 @@ pub enum RetrieveSynonymSetsError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum UpsertSynonymSetError { - Status400(models::ApiResponse<'static>), + Status400(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -139,7 +139,7 @@ pub enum UpsertSynonymSetError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum UpsertSynonymSetItemError { - Status400(models::ApiResponse<'static>), + Status400(models::ApiResponse), UnknownValue(serde_json::Value), } @@ -147,7 +147,7 @@ pub enum UpsertSynonymSetItemError { pub async fn delete_synonym_set( configuration: &configuration::Configuration, params: &DeleteSynonymSetParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}", configuration.base_path, @@ -210,7 +210,7 @@ pub async fn delete_synonym_set( pub async fn delete_synonym_set_item( configuration: &configuration::Configuration, params: &DeleteSynonymSetItemParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}/items/{itemId}", configuration.base_path, @@ -457,7 +457,7 @@ pub async fn retrieve_synonym_set_items( /// Retrieve all synonym sets pub async fn retrieve_synonym_sets( configuration: &configuration::Configuration, -) -> Result>, Error> { +) -> Result, Error> { let uri_str = format!("{}/synonym_sets", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -514,7 +514,7 @@ pub async fn retrieve_synonym_sets( pub async fn upsert_synonym_set( configuration: &configuration::Configuration, params: &UpsertSynonymSetParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}", configuration.base_path, diff --git a/typesense_codegen/src/models/analytics_event_create_response.rs b/typesense_codegen/src/models/analytics_event_create_response.rs index ec776abd..f1969509 100644 --- a/typesense_codegen/src/models/analytics_event_create_response.rs +++ b/typesense_codegen/src/models/analytics_event_create_response.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AnalyticsEventCreateResponse<'a> { +pub struct AnalyticsEventCreateResponse { #[serde(rename = "ok")] pub ok: bool, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> AnalyticsEventCreateResponse<'a> { +impl AnalyticsEventCreateResponse { pub fn new(ok: bool) -> Self { - Self { - ok, - _phantom: PhantomData, - } + Self { ok } } } diff --git a/typesense_codegen/src/models/analytics_events_response.rs b/typesense_codegen/src/models/analytics_events_response.rs index f50647ed..ff474b63 100644 --- a/typesense_codegen/src/models/analytics_events_response.rs +++ b/typesense_codegen/src/models/analytics_events_response.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AnalyticsEventsResponse<'a> { +pub struct AnalyticsEventsResponse { #[serde(rename = "events")] - pub events: Vec>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, + pub events: Vec, } -impl<'a> AnalyticsEventsResponse<'a> { - pub fn new(events: Vec>) -> Self { - Self { - events, - _phantom: PhantomData, - } +impl AnalyticsEventsResponse { + pub fn new(events: Vec) -> Self { + Self { events } } } diff --git a/typesense_codegen/src/models/analytics_events_response_events_inner.rs b/typesense_codegen/src/models/analytics_events_response_events_inner.rs index 42dd55cf..32cd41de 100644 --- a/typesense_codegen/src/models/analytics_events_response_events_inner.rs +++ b/typesense_codegen/src/models/analytics_events_response_events_inner.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AnalyticsEventsResponseEventsInner<'a> { +pub struct AnalyticsEventsResponseEventsInner { #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, #[serde(rename = "event_type", skip_serializing_if = "Option::is_none")] @@ -30,11 +30,9 @@ pub struct AnalyticsEventsResponseEventsInner<'a> { pub doc_ids: Option>, #[serde(rename = "query", skip_serializing_if = "Option::is_none")] pub query: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> AnalyticsEventsResponseEventsInner<'a> { +impl AnalyticsEventsResponseEventsInner { pub fn new() -> Self { Self { name: None, @@ -45,7 +43,6 @@ impl<'a> AnalyticsEventsResponseEventsInner<'a> { doc_id: None, doc_ids: None, query: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/analytics_rule.rs b/typesense_codegen/src/models/analytics_rule.rs index dc1bbd82..33c5ae15 100644 --- a/typesense_codegen/src/models/analytics_rule.rs +++ b/typesense_codegen/src/models/analytics_rule.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AnalyticsRule<'a> { +pub struct AnalyticsRule { #[serde(rename = "name")] pub name: String, #[serde(rename = "type")] @@ -25,12 +25,10 @@ pub struct AnalyticsRule<'a> { #[serde(rename = "rule_tag", skip_serializing_if = "Option::is_none")] pub rule_tag: Option, #[serde(rename = "params", skip_serializing_if = "Option::is_none")] - pub params: Option>>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, + pub params: Option>>, } -impl<'a> AnalyticsRule<'a> { +impl AnalyticsRule { pub fn new(name: String, r#type: Type, collection: String, event_type: String) -> Self { Self { name, @@ -39,7 +37,6 @@ impl<'a> AnalyticsRule<'a> { event_type, rule_tag: None, params: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/analytics_status.rs b/typesense_codegen/src/models/analytics_status.rs index 81096011..97c059fb 100644 --- a/typesense_codegen/src/models/analytics_status.rs +++ b/typesense_codegen/src/models/analytics_status.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AnalyticsStatus<'a> { +pub struct AnalyticsStatus { #[serde( rename = "popular_prefix_queries", skip_serializing_if = "Option::is_none" @@ -37,11 +37,9 @@ pub struct AnalyticsStatus<'a> { pub doc_log_events: Option, #[serde(rename = "doc_counter_events", skip_serializing_if = "Option::is_none")] pub doc_counter_events: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> AnalyticsStatus<'a> { +impl AnalyticsStatus { pub fn new() -> Self { Self { popular_prefix_queries: None, @@ -51,7 +49,6 @@ impl<'a> AnalyticsStatus<'a> { query_counter_events: None, doc_log_events: None, doc_counter_events: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/api_key.rs b/typesense_codegen/src/models/api_key.rs index 6b570c0e..f74b7dde 100644 --- a/typesense_codegen/src/models/api_key.rs +++ b/typesense_codegen/src/models/api_key.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ApiKey<'a> { +pub struct ApiKey { #[serde(rename = "value", skip_serializing_if = "Option::is_none")] pub value: Option, #[serde(rename = "description")] @@ -28,11 +28,9 @@ pub struct ApiKey<'a> { pub id: Option, #[serde(rename = "value_prefix", skip_serializing_if = "Option::is_none")] pub value_prefix: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> ApiKey<'a> { +impl ApiKey { pub fn new(description: String, actions: Vec, collections: Vec) -> Self { Self { value: None, @@ -42,7 +40,6 @@ impl<'a> ApiKey<'a> { expires_at: None, id: None, value_prefix: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/api_key_delete_response.rs b/typesense_codegen/src/models/api_key_delete_response.rs index e7c501cd..77b33e7f 100644 --- a/typesense_codegen/src/models/api_key_delete_response.rs +++ b/typesense_codegen/src/models/api_key_delete_response.rs @@ -13,19 +13,14 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ApiKeyDeleteResponse<'a> { +pub struct ApiKeyDeleteResponse { /// The id of the API key that was deleted #[serde(rename = "id")] pub id: i64, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> ApiKeyDeleteResponse<'a> { +impl ApiKeyDeleteResponse { pub fn new(id: i64) -> Self { - Self { - id, - _phantom: PhantomData, - } + Self { id } } } diff --git a/typesense_codegen/src/models/api_keys_response.rs b/typesense_codegen/src/models/api_keys_response.rs index 3844ca97..fd1cce2b 100644 --- a/typesense_codegen/src/models/api_keys_response.rs +++ b/typesense_codegen/src/models/api_keys_response.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ApiKeysResponse<'a> { +pub struct ApiKeysResponse { #[serde(rename = "keys")] - pub keys: Vec>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, + pub keys: Vec, } -impl<'a> ApiKeysResponse<'a> { - pub fn new(keys: Vec>) -> Self { - Self { - keys, - _phantom: PhantomData, - } +impl ApiKeysResponse { + pub fn new(keys: Vec) -> Self { + Self { keys } } } diff --git a/typesense_codegen/src/models/api_response.rs b/typesense_codegen/src/models/api_response.rs index 8f474400..9820f874 100644 --- a/typesense_codegen/src/models/api_response.rs +++ b/typesense_codegen/src/models/api_response.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ApiResponse<'a> { +pub struct ApiResponse { #[serde(rename = "message")] pub message: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> ApiResponse<'a> { +impl ApiResponse { pub fn new(message: String) -> Self { - Self { - message, - _phantom: PhantomData, - } + Self { message } } } diff --git a/typesense_codegen/src/models/api_stats_response.rs b/typesense_codegen/src/models/api_stats_response.rs index 3013c114..5273fbc5 100644 --- a/typesense_codegen/src/models/api_stats_response.rs +++ b/typesense_codegen/src/models/api_stats_response.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ApiStatsResponse<'a> { +pub struct ApiStatsResponse { #[serde(rename = "delete_latency_ms", skip_serializing_if = "Option::is_none")] pub delete_latency_ms: Option, #[serde( @@ -64,11 +64,9 @@ pub struct ApiStatsResponse<'a> { skip_serializing_if = "Option::is_none" )] pub write_requests_per_second: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> ApiStatsResponse<'a> { +impl ApiStatsResponse { pub fn new() -> Self { Self { delete_latency_ms: None, @@ -84,7 +82,6 @@ impl<'a> ApiStatsResponse<'a> { total_requests_per_second: None, write_latency_ms: None, write_requests_per_second: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/collection_alias.rs b/typesense_codegen/src/models/collection_alias.rs index b1dab9b9..d014916a 100644 --- a/typesense_codegen/src/models/collection_alias.rs +++ b/typesense_codegen/src/models/collection_alias.rs @@ -13,23 +13,20 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CollectionAlias<'a> { +pub struct CollectionAlias { /// Name of the collection alias #[serde(rename = "name")] pub name: String, /// Name of the collection the alias mapped to #[serde(rename = "collection_name")] pub collection_name: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> CollectionAlias<'a> { +impl CollectionAlias { pub fn new(name: String, collection_name: String) -> Self { Self { name, collection_name, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/collection_aliases_response.rs b/typesense_codegen/src/models/collection_aliases_response.rs index 55a45fd2..7ace9da0 100644 --- a/typesense_codegen/src/models/collection_aliases_response.rs +++ b/typesense_codegen/src/models/collection_aliases_response.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CollectionAliasesResponse<'a> { +pub struct CollectionAliasesResponse { #[serde(rename = "aliases")] - pub aliases: Vec>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, + pub aliases: Vec, } -impl<'a> CollectionAliasesResponse<'a> { - pub fn new(aliases: Vec>) -> Self { - Self { - aliases, - _phantom: PhantomData, - } +impl CollectionAliasesResponse { + pub fn new(aliases: Vec) -> Self { + Self { aliases } } } diff --git a/typesense_codegen/src/models/collection_response.rs b/typesense_codegen/src/models/collection_response.rs index 3a42c1b5..a15fc833 100644 --- a/typesense_codegen/src/models/collection_response.rs +++ b/typesense_codegen/src/models/collection_response.rs @@ -13,13 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CollectionResponse<'a> { +pub struct CollectionResponse { /// Name of the collection #[serde(rename = "name")] pub name: String, /// A list of fields for querying, filtering and faceting #[serde(rename = "fields")] - pub fields: Vec>, + pub fields: Vec, /// The name of an int32 / float field that determines the order in which the search results are ranked when a sort_by clause is not provided during searching. This field must indicate some kind of popularity. #[serde( rename = "default_sorting_field", @@ -42,7 +42,7 @@ pub struct CollectionResponse<'a> { #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] pub symbols_to_index: Option>, #[serde(rename = "voice_query_model", skip_serializing_if = "Option::is_none")] - pub voice_query_model: Option>>, + pub voice_query_model: Option>, /// Optional details about the collection, e.g., when it was created, who created it etc. #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] pub metadata: Option, @@ -52,14 +52,12 @@ pub struct CollectionResponse<'a> { /// Timestamp of when the collection was created (Unix epoch in seconds) #[serde(rename = "created_at")] pub created_at: i64, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> CollectionResponse<'a> { +impl CollectionResponse { pub fn new( name: String, - fields: Vec>, + fields: Vec, num_documents: i64, created_at: i64, ) -> Self { @@ -75,7 +73,6 @@ impl<'a> CollectionResponse<'a> { metadata: None, num_documents, created_at, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/collection_schema.rs b/typesense_codegen/src/models/collection_schema.rs index d8224445..d6190424 100644 --- a/typesense_codegen/src/models/collection_schema.rs +++ b/typesense_codegen/src/models/collection_schema.rs @@ -22,7 +22,7 @@ pub struct CollectionSchema<'a> { pub name: Cow<'a, str>, /// A list of fields for querying, filtering and faceting #[serde(rename = "fields")] - pub fields: Vec>, + pub fields: Vec, /// The name of an int32 / float field that determines the order in which the search results are ranked when a sort_by clause is not provided during searching. This field must indicate some kind of popularity. #[serde( rename = "default_sorting_field", @@ -45,7 +45,7 @@ pub struct CollectionSchema<'a> { #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] pub symbols_to_index: Option>, #[serde(rename = "voice_query_model", skip_serializing_if = "Option::is_none")] - pub voice_query_model: Option>>, + pub voice_query_model: Option>, /// Optional details about the collection, e.g., when it was created, who created it etc. #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] pub metadata: Option, @@ -55,7 +55,7 @@ pub struct CollectionSchema<'a> { } impl<'a> CollectionSchema<'a> { - pub fn new(name: Cow<'a, str>, fields: Vec>) -> Self { + pub fn new(name: Cow<'a, str>, fields: Vec) -> Self { Self { name, fields, diff --git a/typesense_codegen/src/models/collection_update_schema.rs b/typesense_codegen/src/models/collection_update_schema.rs index be5b7503..387deede 100644 --- a/typesense_codegen/src/models/collection_update_schema.rs +++ b/typesense_codegen/src/models/collection_update_schema.rs @@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize}; pub struct CollectionUpdateSchema<'a> { /// A list of fields for querying, filtering and faceting #[serde(rename = "fields")] - pub fields: Vec>, + pub fields: Vec, /// List of synonym set names to associate with this collection #[serde(rename = "synonym_sets", skip_serializing_if = "Option::is_none")] pub synonym_sets: Option>, @@ -28,7 +28,7 @@ pub struct CollectionUpdateSchema<'a> { } impl<'a> CollectionUpdateSchema<'a> { - pub fn new(fields: Vec>) -> Self { + pub fn new(fields: Vec) -> Self { Self { fields, synonym_sets: None, diff --git a/typesense_codegen/src/models/conversation_model_schema.rs b/typesense_codegen/src/models/conversation_model_schema.rs index b872e67d..c7fc5a7f 100644 --- a/typesense_codegen/src/models/conversation_model_schema.rs +++ b/typesense_codegen/src/models/conversation_model_schema.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ConversationModelSchema<'a> { +pub struct ConversationModelSchema { /// An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. #[serde(rename = "id")] pub id: String, @@ -41,11 +41,9 @@ pub struct ConversationModelSchema<'a> { /// URL of vLLM service #[serde(rename = "vllm_url", skip_serializing_if = "Option::is_none")] pub vllm_url: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> ConversationModelSchema<'a> { +impl ConversationModelSchema { pub fn new(id: String, model_name: String, history_collection: String, max_bytes: i32) -> Self { Self { id, @@ -57,7 +55,6 @@ impl<'a> ConversationModelSchema<'a> { ttl: None, max_bytes, vllm_url: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/create_analytics_rule_200_response.rs b/typesense_codegen/src/models/create_analytics_rule_200_response.rs index e8fe0e0a..f2fb5d56 100644 --- a/typesense_codegen/src/models/create_analytics_rule_200_response.rs +++ b/typesense_codegen/src/models/create_analytics_rule_200_response.rs @@ -14,12 +14,12 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum CreateAnalyticsRule200Response<'a> { - AnalyticsRule(Box>), - Array(Vec>), +pub enum CreateAnalyticsRule200Response { + AnalyticsRule(Box), + Array(Vec), } -impl Default for CreateAnalyticsRule200Response<'_> { +impl Default for CreateAnalyticsRule200Response { fn default() -> Self { Self::AnalyticsRule(Default::default()) } diff --git a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs index bcc8e74b..14cd754a 100644 --- a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs +++ b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CreateAnalyticsRule200ResponseOneOfInner<'a> { +pub struct CreateAnalyticsRule200ResponseOneOfInner { #[serde(rename = "name")] pub name: String, #[serde(rename = "type")] @@ -25,14 +25,12 @@ pub struct CreateAnalyticsRule200ResponseOneOfInner<'a> { #[serde(rename = "rule_tag", skip_serializing_if = "Option::is_none")] pub rule_tag: Option, #[serde(rename = "params", skip_serializing_if = "Option::is_none")] - pub params: Option>>, + pub params: Option>>, #[serde(rename = "error", skip_serializing_if = "Option::is_none")] pub error: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> CreateAnalyticsRule200ResponseOneOfInner<'a> { +impl CreateAnalyticsRule200ResponseOneOfInner { pub fn new(name: String, r#type: Type, collection: String, event_type: String) -> Self { Self { name, @@ -42,7 +40,6 @@ impl<'a> CreateAnalyticsRule200ResponseOneOfInner<'a> { rule_tag: None, params: None, error: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs index 89a0805b..59c3e416 100644 --- a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs +++ b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CreateAnalyticsRule200ResponseOneOfInnerAnyOf<'a> { +pub struct CreateAnalyticsRule200ResponseOneOfInnerAnyOf { #[serde(rename = "error", skip_serializing_if = "Option::is_none")] pub error: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> CreateAnalyticsRule200ResponseOneOfInnerAnyOf<'a> { +impl CreateAnalyticsRule200ResponseOneOfInnerAnyOf { pub fn new() -> Self { - Self { - error: None, - _phantom: PhantomData, - } + Self { error: None } } } diff --git a/typesense_codegen/src/models/curation_exclude.rs b/typesense_codegen/src/models/curation_exclude.rs index fa306ac8..b8b392b6 100644 --- a/typesense_codegen/src/models/curation_exclude.rs +++ b/typesense_codegen/src/models/curation_exclude.rs @@ -13,19 +13,14 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationExclude<'a> { +pub struct CurationExclude { /// document id that should be excluded from the search results. #[serde(rename = "id")] pub id: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> CurationExclude<'a> { +impl CurationExclude { pub fn new(id: String) -> Self { - Self { - id, - _phantom: PhantomData, - } + Self { id } } } diff --git a/typesense_codegen/src/models/curation_include.rs b/typesense_codegen/src/models/curation_include.rs index f1970455..ffcf2ed7 100644 --- a/typesense_codegen/src/models/curation_include.rs +++ b/typesense_codegen/src/models/curation_include.rs @@ -13,23 +13,17 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationInclude<'a> { +pub struct CurationInclude { /// document id that should be included #[serde(rename = "id")] pub id: String, /// position number where document should be included in the search results #[serde(rename = "position")] pub position: i32, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> CurationInclude<'a> { +impl CurationInclude { pub fn new(id: String, position: i32) -> Self { - Self { - id, - position, - _phantom: PhantomData, - } + Self { id, position } } } diff --git a/typesense_codegen/src/models/curation_item_create_schema.rs b/typesense_codegen/src/models/curation_item_create_schema.rs index da1a5cc2..7e0fab6a 100644 --- a/typesense_codegen/src/models/curation_item_create_schema.rs +++ b/typesense_codegen/src/models/curation_item_create_schema.rs @@ -15,13 +15,13 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CurationItemCreateSchema<'a> { #[serde(rename = "rule")] - pub rule: Box>, + pub rule: Box, /// List of document `id`s that should be included in the search results with their corresponding `position`s. #[serde(rename = "includes", skip_serializing_if = "Option::is_none")] - pub includes: Option>>, + pub includes: Option>, /// List of document `id`s that should be excluded from the search results. #[serde(rename = "excludes", skip_serializing_if = "Option::is_none")] - pub excludes: Option>>, + pub excludes: Option>, /// A filter by clause that is applied to any search query that matches the curation rule. #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] pub filter_by: Option>, @@ -63,7 +63,7 @@ pub struct CurationItemCreateSchema<'a> { } impl<'a> CurationItemCreateSchema<'a> { - pub fn new(rule: models::CurationRule<'a>) -> Self { + pub fn new(rule: models::CurationRule) -> Self { Self { rule: Box::new(rule), includes: None, diff --git a/typesense_codegen/src/models/curation_item_delete_schema.rs b/typesense_codegen/src/models/curation_item_delete_schema.rs index 201c5ebe..8b090dab 100644 --- a/typesense_codegen/src/models/curation_item_delete_schema.rs +++ b/typesense_codegen/src/models/curation_item_delete_schema.rs @@ -13,19 +13,14 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationItemDeleteSchema<'a> { +pub struct CurationItemDeleteSchema { /// ID of the deleted curation item #[serde(rename = "id")] pub id: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> CurationItemDeleteSchema<'a> { +impl CurationItemDeleteSchema { pub fn new(id: String) -> Self { - Self { - id, - _phantom: PhantomData, - } + Self { id } } } diff --git a/typesense_codegen/src/models/curation_item_schema.rs b/typesense_codegen/src/models/curation_item_schema.rs index 598d88f1..aad7260f 100644 --- a/typesense_codegen/src/models/curation_item_schema.rs +++ b/typesense_codegen/src/models/curation_item_schema.rs @@ -13,15 +13,15 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationItemSchema<'a> { +pub struct CurationItemSchema { #[serde(rename = "rule")] - pub rule: Box>, + pub rule: Box, /// List of document `id`s that should be included in the search results with their corresponding `position`s. #[serde(rename = "includes", skip_serializing_if = "Option::is_none")] - pub includes: Option>>, + pub includes: Option>, /// List of document `id`s that should be excluded from the search results. #[serde(rename = "excludes", skip_serializing_if = "Option::is_none")] - pub excludes: Option>>, + pub excludes: Option>, /// A filter by clause that is applied to any search query that matches the curation rule. #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] pub filter_by: Option, @@ -57,12 +57,10 @@ pub struct CurationItemSchema<'a> { pub stop_processing: Option, #[serde(rename = "id")] pub id: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> CurationItemSchema<'a> { - pub fn new(rule: models::CurationRule<'a>, id: String) -> Self { +impl CurationItemSchema { + pub fn new(rule: models::CurationRule, id: String) -> Self { Self { rule: Box::new(rule), includes: None, @@ -77,7 +75,6 @@ impl<'a> CurationItemSchema<'a> { effective_to_ts: None, stop_processing: None, id, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/curation_rule.rs b/typesense_codegen/src/models/curation_rule.rs index 42268064..1f43f409 100644 --- a/typesense_codegen/src/models/curation_rule.rs +++ b/typesense_codegen/src/models/curation_rule.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationRule<'a> { +pub struct CurationRule { /// List of tag values to associate with this curation rule. #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] pub tags: Option>, @@ -26,18 +26,15 @@ pub struct CurationRule<'a> { /// Indicates that the curation should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc). #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] pub filter_by: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> CurationRule<'a> { +impl CurationRule { pub fn new() -> Self { Self { tags: None, query: None, r#match: None, filter_by: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/curation_set_delete_schema.rs b/typesense_codegen/src/models/curation_set_delete_schema.rs index 6a4ae1dc..5f9e5f1b 100644 --- a/typesense_codegen/src/models/curation_set_delete_schema.rs +++ b/typesense_codegen/src/models/curation_set_delete_schema.rs @@ -13,19 +13,14 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationSetDeleteSchema<'a> { +pub struct CurationSetDeleteSchema { /// Name of the deleted curation set #[serde(rename = "name")] pub name: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> CurationSetDeleteSchema<'a> { +impl CurationSetDeleteSchema { pub fn new(name: String) -> Self { - Self { - name, - _phantom: PhantomData, - } + Self { name } } } diff --git a/typesense_codegen/src/models/curation_set_schema.rs b/typesense_codegen/src/models/curation_set_schema.rs index 2e471d00..a0523915 100644 --- a/typesense_codegen/src/models/curation_set_schema.rs +++ b/typesense_codegen/src/models/curation_set_schema.rs @@ -13,26 +13,23 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CurationSetSchema<'a> { +pub struct CurationSetSchema { /// Array of curation items #[serde(rename = "items")] - pub items: Vec>, + pub items: Vec>, /// Optional description for the curation set #[serde(rename = "description", skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(rename = "name")] pub name: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> CurationSetSchema<'a> { - pub fn new(items: Vec>, name: String) -> Self { +impl CurationSetSchema { + pub fn new(items: Vec>, name: String) -> Self { Self { items, description: None, name, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/debug_200_response.rs b/typesense_codegen/src/models/debug_200_response.rs index b21ef1c3..1faf1752 100644 --- a/typesense_codegen/src/models/debug_200_response.rs +++ b/typesense_codegen/src/models/debug_200_response.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct Debug200Response<'a> { +pub struct Debug200Response { #[serde(rename = "version", skip_serializing_if = "Option::is_none")] pub version: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> Debug200Response<'a> { +impl Debug200Response { pub fn new() -> Self { - Self { - version: None, - _phantom: PhantomData, - } + Self { version: None } } } diff --git a/typesense_codegen/src/models/delete_documents_200_response.rs b/typesense_codegen/src/models/delete_documents_200_response.rs index ac78b8f3..b759bd7f 100644 --- a/typesense_codegen/src/models/delete_documents_200_response.rs +++ b/typesense_codegen/src/models/delete_documents_200_response.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct DeleteDocuments200Response<'a> { +pub struct DeleteDocuments200Response { #[serde(rename = "num_deleted")] pub num_deleted: i32, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> DeleteDocuments200Response<'a> { +impl DeleteDocuments200Response { pub fn new(num_deleted: i32) -> Self { - Self { - num_deleted, - _phantom: PhantomData, - } + Self { num_deleted } } } diff --git a/typesense_codegen/src/models/delete_stopwords_set_200_response.rs b/typesense_codegen/src/models/delete_stopwords_set_200_response.rs index 4de85de3..a1449698 100644 --- a/typesense_codegen/src/models/delete_stopwords_set_200_response.rs +++ b/typesense_codegen/src/models/delete_stopwords_set_200_response.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct DeleteStopwordsSet200Response<'a> { +pub struct DeleteStopwordsSet200Response { #[serde(rename = "id")] pub id: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> DeleteStopwordsSet200Response<'a> { +impl DeleteStopwordsSet200Response { pub fn new(id: String) -> Self { - Self { - id, - _phantom: PhantomData, - } + Self { id } } } diff --git a/typesense_codegen/src/models/facet_counts.rs b/typesense_codegen/src/models/facet_counts.rs index c340d58e..3535edd4 100644 --- a/typesense_codegen/src/models/facet_counts.rs +++ b/typesense_codegen/src/models/facet_counts.rs @@ -13,24 +13,21 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct FacetCounts<'a> { +pub struct FacetCounts { #[serde(rename = "counts", skip_serializing_if = "Option::is_none")] - pub counts: Option>>, + pub counts: Option>, #[serde(rename = "field_name", skip_serializing_if = "Option::is_none")] pub field_name: Option, #[serde(rename = "stats", skip_serializing_if = "Option::is_none")] - pub stats: Option>>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, + pub stats: Option>, } -impl<'a> FacetCounts<'a> { +impl FacetCounts { pub fn new() -> Self { Self { counts: None, field_name: None, stats: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/facet_counts_counts_inner.rs b/typesense_codegen/src/models/facet_counts_counts_inner.rs index 94375a8b..b65feeb2 100644 --- a/typesense_codegen/src/models/facet_counts_counts_inner.rs +++ b/typesense_codegen/src/models/facet_counts_counts_inner.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct FacetCountsCountsInner<'a> { +pub struct FacetCountsCountsInner { #[serde(rename = "count", skip_serializing_if = "Option::is_none")] pub count: Option, #[serde(rename = "highlighted", skip_serializing_if = "Option::is_none")] @@ -22,18 +22,15 @@ pub struct FacetCountsCountsInner<'a> { pub value: Option, #[serde(rename = "parent", skip_serializing_if = "Option::is_none")] pub parent: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> FacetCountsCountsInner<'a> { +impl FacetCountsCountsInner { pub fn new() -> Self { Self { count: None, highlighted: None, value: None, parent: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/facet_counts_stats.rs b/typesense_codegen/src/models/facet_counts_stats.rs index 8fc473b6..cf654ba5 100644 --- a/typesense_codegen/src/models/facet_counts_stats.rs +++ b/typesense_codegen/src/models/facet_counts_stats.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct FacetCountsStats<'a> { +pub struct FacetCountsStats { #[serde(rename = "max", skip_serializing_if = "Option::is_none")] pub max: Option, #[serde(rename = "min", skip_serializing_if = "Option::is_none")] @@ -24,11 +24,9 @@ pub struct FacetCountsStats<'a> { pub total_values: Option, #[serde(rename = "avg", skip_serializing_if = "Option::is_none")] pub avg: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> FacetCountsStats<'a> { +impl FacetCountsStats { pub fn new() -> Self { Self { max: None, @@ -36,7 +34,6 @@ impl<'a> FacetCountsStats<'a> { sum: None, total_values: None, avg: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/field.rs b/typesense_codegen/src/models/field.rs index a8b0fd0e..e7220a1e 100644 --- a/typesense_codegen/src/models/field.rs +++ b/typesense_codegen/src/models/field.rs @@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize}; #[builder(on(Cow<'_, str>, into))] #[builder(on(String, into))] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct Field<'a> { +pub struct Field { #[serde(rename = "name")] pub name: String, #[serde(rename = "type")] @@ -62,13 +62,10 @@ pub struct Field<'a> { #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] pub symbols_to_index: Option>, #[serde(rename = "embed", skip_serializing_if = "Option::is_none")] - pub embed: Option>>, - #[serde(skip)] - #[builder(default)] - pub _phantom: PhantomData<&'a ()>, + pub embed: Option>, } -impl<'a> Field<'a> { +impl Field { pub fn new(name: String, r#type: String) -> Self { Self { name, @@ -90,7 +87,6 @@ impl<'a> Field<'a> { token_separators: None, symbols_to_index: None, embed: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/field_embed.rs b/typesense_codegen/src/models/field_embed.rs index 9c7b96ba..025660b2 100644 --- a/typesense_codegen/src/models/field_embed.rs +++ b/typesense_codegen/src/models/field_embed.rs @@ -13,21 +13,18 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct FieldEmbed<'a> { +pub struct FieldEmbed { #[serde(rename = "from")] pub from: Vec, #[serde(rename = "model_config")] - pub model_config: Box>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, + pub model_config: Box, } -impl<'a> FieldEmbed<'a> { - pub fn new(from: Vec, model_config: models::FieldEmbedModelConfig<'a>) -> Self { +impl FieldEmbed { + pub fn new(from: Vec, model_config: models::FieldEmbedModelConfig) -> Self { Self { from, model_config: Box::new(model_config), - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/field_embed_model_config.rs b/typesense_codegen/src/models/field_embed_model_config.rs index 9b14bbcd..4afcdac8 100644 --- a/typesense_codegen/src/models/field_embed_model_config.rs +++ b/typesense_codegen/src/models/field_embed_model_config.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct FieldEmbedModelConfig<'a> { +pub struct FieldEmbedModelConfig { #[serde(rename = "model_name")] pub model_name: String, #[serde(rename = "api_key", skip_serializing_if = "Option::is_none")] @@ -34,11 +34,9 @@ pub struct FieldEmbedModelConfig<'a> { pub indexing_prefix: Option, #[serde(rename = "query_prefix", skip_serializing_if = "Option::is_none")] pub query_prefix: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> FieldEmbedModelConfig<'a> { +impl FieldEmbedModelConfig { pub fn new(model_name: String) -> Self { Self { model_name, @@ -51,7 +49,6 @@ impl<'a> FieldEmbedModelConfig<'a> { project_id: None, indexing_prefix: None, query_prefix: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/health_status.rs b/typesense_codegen/src/models/health_status.rs index 8e0ca531..d0cbb42c 100644 --- a/typesense_codegen/src/models/health_status.rs +++ b/typesense_codegen/src/models/health_status.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct HealthStatus<'a> { +pub struct HealthStatus { #[serde(rename = "ok")] pub ok: bool, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> HealthStatus<'a> { +impl HealthStatus { pub fn new(ok: bool) -> Self { - Self { - ok, - _phantom: PhantomData, - } + Self { ok } } } diff --git a/typesense_codegen/src/models/list_stemming_dictionaries_200_response.rs b/typesense_codegen/src/models/list_stemming_dictionaries_200_response.rs index 02f676cd..658047f6 100644 --- a/typesense_codegen/src/models/list_stemming_dictionaries_200_response.rs +++ b/typesense_codegen/src/models/list_stemming_dictionaries_200_response.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ListStemmingDictionaries200Response<'a> { +pub struct ListStemmingDictionaries200Response { #[serde(rename = "dictionaries", skip_serializing_if = "Option::is_none")] pub dictionaries: Option>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> ListStemmingDictionaries200Response<'a> { +impl ListStemmingDictionaries200Response { pub fn new() -> Self { - Self { - dictionaries: None, - _phantom: PhantomData, - } + Self { dictionaries: None } } } diff --git a/typesense_codegen/src/models/multi_search_result.rs b/typesense_codegen/src/models/multi_search_result.rs index 5c2093ef..1f6c9ab5 100644 --- a/typesense_codegen/src/models/multi_search_result.rs +++ b/typesense_codegen/src/models/multi_search_result.rs @@ -13,21 +13,18 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct MultiSearchResult<'a, D> { +pub struct MultiSearchResult { #[serde(rename = "results")] - pub results: Vec>, + pub results: Vec>, #[serde(rename = "conversation", skip_serializing_if = "Option::is_none")] - pub conversation: Option>>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, + pub conversation: Option>, } -impl<'a, D> MultiSearchResult<'a, D> { - pub fn new(results: Vec>) -> Self { +impl MultiSearchResult { + pub fn new(results: Vec>) -> Self { Self { results, conversation: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/multi_search_result_item.rs b/typesense_codegen/src/models/multi_search_result_item.rs index 9f294cde..a82c4e0a 100644 --- a/typesense_codegen/src/models/multi_search_result_item.rs +++ b/typesense_codegen/src/models/multi_search_result_item.rs @@ -13,9 +13,9 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct MultiSearchResultItem<'a, D> { +pub struct MultiSearchResultItem { #[serde(rename = "facet_counts", skip_serializing_if = "Option::is_none")] - pub facet_counts: Option>>, + pub facet_counts: Option>, /// The number of documents found #[serde(rename = "found", skip_serializing_if = "Option::is_none")] pub found: Option, @@ -34,20 +34,20 @@ pub struct MultiSearchResultItem<'a, D> { #[serde(rename = "page", skip_serializing_if = "Option::is_none")] pub page: Option, #[serde(rename = "grouped_hits", skip_serializing_if = "Option::is_none")] - pub grouped_hits: Option>>, + pub grouped_hits: Option>>, /// The documents that matched the search query #[serde(rename = "hits", skip_serializing_if = "Option::is_none")] - pub hits: Option>>, + pub hits: Option>>, #[serde(rename = "request_params", skip_serializing_if = "Option::is_none")] - pub request_params: Option>>, + pub request_params: Option>, #[serde(rename = "conversation", skip_serializing_if = "Option::is_none")] - pub conversation: Option>>, + pub conversation: Option>, /// Returned only for union query response. #[serde( rename = "union_request_params", skip_serializing_if = "Option::is_none" )] - pub union_request_params: Option>>, + pub union_request_params: Option>, /// Custom JSON object that can be returned in the search response #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] pub metadata: Option>, @@ -57,11 +57,9 @@ pub struct MultiSearchResultItem<'a, D> { /// Error description #[serde(rename = "error", skip_serializing_if = "Option::is_none")] pub error: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a, D> MultiSearchResultItem<'a, D> { +impl MultiSearchResultItem { pub fn new() -> Self { Self { facet_counts: None, @@ -79,7 +77,6 @@ impl<'a, D> MultiSearchResultItem<'a, D> { metadata: None, code: None, error: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/nl_search_model_base.rs b/typesense_codegen/src/models/nl_search_model_base.rs index a806361d..5c297b90 100644 --- a/typesense_codegen/src/models/nl_search_model_base.rs +++ b/typesense_codegen/src/models/nl_search_model_base.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct NlSearchModelBase<'a> { +pub struct NlSearchModelBase { /// Name of the NL model to use #[serde(rename = "model_name", skip_serializing_if = "Option::is_none")] pub model_name: Option, @@ -68,11 +68,9 @@ pub struct NlSearchModelBase<'a> { /// Account ID for Cloudflare-specific models #[serde(rename = "account_id", skip_serializing_if = "Option::is_none")] pub account_id: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> NlSearchModelBase<'a> { +impl NlSearchModelBase { pub fn new() -> Self { Self { model_name: None, @@ -93,7 +91,6 @@ impl<'a> NlSearchModelBase<'a> { region: None, max_output_tokens: None, account_id: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/nl_search_model_delete_schema.rs b/typesense_codegen/src/models/nl_search_model_delete_schema.rs index 9ab0d2ae..6bed2260 100644 --- a/typesense_codegen/src/models/nl_search_model_delete_schema.rs +++ b/typesense_codegen/src/models/nl_search_model_delete_schema.rs @@ -13,19 +13,14 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct NlSearchModelDeleteSchema<'a> { +pub struct NlSearchModelDeleteSchema { /// ID of the deleted NL search model #[serde(rename = "id")] pub id: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> NlSearchModelDeleteSchema<'a> { +impl NlSearchModelDeleteSchema { pub fn new(id: String) -> Self { - Self { - id, - _phantom: PhantomData, - } + Self { id } } } diff --git a/typesense_codegen/src/models/nl_search_model_schema.rs b/typesense_codegen/src/models/nl_search_model_schema.rs index c64c9a51..61279b74 100644 --- a/typesense_codegen/src/models/nl_search_model_schema.rs +++ b/typesense_codegen/src/models/nl_search_model_schema.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct NlSearchModelSchema<'a> { +pub struct NlSearchModelSchema { /// Name of the NL model to use #[serde(rename = "model_name", skip_serializing_if = "Option::is_none")] pub model_name: Option, @@ -71,11 +71,9 @@ pub struct NlSearchModelSchema<'a> { /// ID of the NL search model #[serde(rename = "id")] pub id: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> NlSearchModelSchema<'a> { +impl NlSearchModelSchema { pub fn new(id: String) -> Self { Self { model_name: None, @@ -97,7 +95,6 @@ impl<'a> NlSearchModelSchema<'a> { max_output_tokens: None, account_id: None, id, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/preset_delete_schema.rs b/typesense_codegen/src/models/preset_delete_schema.rs index bd5a8b4c..b964ab5b 100644 --- a/typesense_codegen/src/models/preset_delete_schema.rs +++ b/typesense_codegen/src/models/preset_delete_schema.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct PresetDeleteSchema<'a> { +pub struct PresetDeleteSchema { #[serde(rename = "name")] pub name: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> PresetDeleteSchema<'a> { +impl PresetDeleteSchema { pub fn new(name: String) -> Self { - Self { - name, - _phantom: PhantomData, - } + Self { name } } } diff --git a/typesense_codegen/src/models/preset_schema.rs b/typesense_codegen/src/models/preset_schema.rs index 16dbf506..6dfee9d8 100644 --- a/typesense_codegen/src/models/preset_schema.rs +++ b/typesense_codegen/src/models/preset_schema.rs @@ -13,21 +13,18 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct PresetSchema<'a> { +pub struct PresetSchema { #[serde(rename = "value")] - pub value: Box>, + pub value: Box>, #[serde(rename = "name")] pub name: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> PresetSchema<'a> { - pub fn new(value: models::PresetUpsertSchemaValue<'a>, name: String) -> Self { +impl PresetSchema { + pub fn new(value: models::PresetUpsertSchemaValue<'static>, name: String) -> Self { Self { value: Box::new(value), name, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/presets_retrieve_schema.rs b/typesense_codegen/src/models/presets_retrieve_schema.rs index 5f6dffe8..1da3e0b9 100644 --- a/typesense_codegen/src/models/presets_retrieve_schema.rs +++ b/typesense_codegen/src/models/presets_retrieve_schema.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct PresetsRetrieveSchema<'a> { +pub struct PresetsRetrieveSchema { #[serde(rename = "presets")] - pub presets: Vec>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, + pub presets: Vec, } -impl<'a> PresetsRetrieveSchema<'a> { - pub fn new(presets: Vec>) -> Self { - Self { - presets, - _phantom: PhantomData, - } +impl PresetsRetrieveSchema { + pub fn new(presets: Vec) -> Self { + Self { presets } } } diff --git a/typesense_codegen/src/models/schema_change_status.rs b/typesense_codegen/src/models/schema_change_status.rs index db49514b..d5891f4a 100644 --- a/typesense_codegen/src/models/schema_change_status.rs +++ b/typesense_codegen/src/models/schema_change_status.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SchemaChangeStatus<'a> { +pub struct SchemaChangeStatus { /// Name of the collection being modified #[serde(rename = "collection", skip_serializing_if = "Option::is_none")] pub collection: Option, @@ -23,17 +23,14 @@ pub struct SchemaChangeStatus<'a> { /// Number of documents that have been altered #[serde(rename = "altered_docs", skip_serializing_if = "Option::is_none")] pub altered_docs: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> SchemaChangeStatus<'a> { +impl SchemaChangeStatus { pub fn new() -> Self { Self { collection: None, validated_docs: None, altered_docs: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_grouped_hit.rs b/typesense_codegen/src/models/search_grouped_hit.rs index 9401a5f7..4f3fbb3b 100644 --- a/typesense_codegen/src/models/search_grouped_hit.rs +++ b/typesense_codegen/src/models/search_grouped_hit.rs @@ -13,28 +13,22 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchGroupedHit<'a, D> { +pub struct SearchGroupedHit { #[serde(rename = "found", skip_serializing_if = "Option::is_none")] pub found: Option, #[serde(rename = "group_key")] pub group_key: Vec, /// The documents that matched the search query #[serde(rename = "hits")] - pub hits: Vec>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, + pub hits: Vec>, } -impl<'a, D> SearchGroupedHit<'a, D> { - pub fn new( - group_key: Vec, - hits: Vec>, - ) -> Self { +impl SearchGroupedHit { + pub fn new(group_key: Vec, hits: Vec>) -> Self { Self { found: None, group_key, hits, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_highlight.rs b/typesense_codegen/src/models/search_highlight.rs index 5e9922b6..728551bb 100644 --- a/typesense_codegen/src/models/search_highlight.rs +++ b/typesense_codegen/src/models/search_highlight.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchHighlight<'a> { +pub struct SearchHighlight { #[serde(rename = "field", skip_serializing_if = "Option::is_none")] pub field: Option, /// Present only for (non-array) string fields @@ -33,11 +33,9 @@ pub struct SearchHighlight<'a> { pub indices: Option>, #[serde(rename = "matched_tokens", skip_serializing_if = "Option::is_none")] pub matched_tokens: Option>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> SearchHighlight<'a> { +impl SearchHighlight { pub fn new() -> Self { Self { field: None, @@ -47,7 +45,6 @@ impl<'a> SearchHighlight<'a> { values: None, indices: None, matched_tokens: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_request_params.rs b/typesense_codegen/src/models/search_request_params.rs index bf2bbb2b..afc81fb6 100644 --- a/typesense_codegen/src/models/search_request_params.rs +++ b/typesense_codegen/src/models/search_request_params.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchRequestParams<'a> { +pub struct SearchRequestParams { #[serde(rename = "collection_name")] pub collection_name: String, #[serde(rename = "q")] @@ -21,19 +21,16 @@ pub struct SearchRequestParams<'a> { #[serde(rename = "per_page")] pub per_page: i32, #[serde(rename = "voice_query", skip_serializing_if = "Option::is_none")] - pub voice_query: Option>>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, + pub voice_query: Option>, } -impl<'a> SearchRequestParams<'a> { +impl SearchRequestParams { pub fn new(collection_name: String, q: String, per_page: i32) -> Self { Self { collection_name, q, per_page, voice_query: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_request_params_voice_query.rs b/typesense_codegen/src/models/search_request_params_voice_query.rs index adb01b45..dcce04d9 100644 --- a/typesense_codegen/src/models/search_request_params_voice_query.rs +++ b/typesense_codegen/src/models/search_request_params_voice_query.rs @@ -13,18 +13,15 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchRequestParamsVoiceQuery<'a> { +pub struct SearchRequestParamsVoiceQuery { #[serde(rename = "transcribed_query", skip_serializing_if = "Option::is_none")] pub transcribed_query: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> SearchRequestParamsVoiceQuery<'a> { +impl SearchRequestParamsVoiceQuery { pub fn new() -> Self { Self { transcribed_query: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_result.rs b/typesense_codegen/src/models/search_result.rs index a03c1428..ff29324a 100644 --- a/typesense_codegen/src/models/search_result.rs +++ b/typesense_codegen/src/models/search_result.rs @@ -13,9 +13,9 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchResult<'a, D> { +pub struct SearchResult { #[serde(rename = "facet_counts", skip_serializing_if = "Option::is_none")] - pub facet_counts: Option>>, + pub facet_counts: Option>, /// The number of documents found #[serde(rename = "found", skip_serializing_if = "Option::is_none")] pub found: Option, @@ -34,28 +34,26 @@ pub struct SearchResult<'a, D> { #[serde(rename = "page", skip_serializing_if = "Option::is_none")] pub page: Option, #[serde(rename = "grouped_hits", skip_serializing_if = "Option::is_none")] - pub grouped_hits: Option>>, + pub grouped_hits: Option>>, /// The documents that matched the search query #[serde(rename = "hits", skip_serializing_if = "Option::is_none")] - pub hits: Option>>, + pub hits: Option>>, #[serde(rename = "request_params", skip_serializing_if = "Option::is_none")] - pub request_params: Option>>, + pub request_params: Option>, #[serde(rename = "conversation", skip_serializing_if = "Option::is_none")] - pub conversation: Option>>, + pub conversation: Option>, /// Returned only for union query response. #[serde( rename = "union_request_params", skip_serializing_if = "Option::is_none" )] - pub union_request_params: Option>>, + pub union_request_params: Option>, /// Custom JSON object that can be returned in the search response #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] pub metadata: Option>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a, D> SearchResult<'a, D> { +impl SearchResult { pub fn new() -> Self { Self { facet_counts: None, @@ -71,7 +69,6 @@ impl<'a, D> SearchResult<'a, D> { conversation: None, union_request_params: None, metadata: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_result_conversation.rs b/typesense_codegen/src/models/search_result_conversation.rs index aaa045d9..ba9e8d33 100644 --- a/typesense_codegen/src/models/search_result_conversation.rs +++ b/typesense_codegen/src/models/search_result_conversation.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchResultConversation<'a> { +pub struct SearchResultConversation { #[serde(rename = "answer")] pub answer: String, #[serde(rename = "conversation_history")] @@ -22,11 +22,9 @@ pub struct SearchResultConversation<'a> { pub conversation_id: String, #[serde(rename = "query")] pub query: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> SearchResultConversation<'a> { +impl SearchResultConversation { pub fn new( answer: String, conversation_history: Vec, @@ -38,7 +36,6 @@ impl<'a> SearchResultConversation<'a> { conversation_history, conversation_id, query, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_result_hit.rs b/typesense_codegen/src/models/search_result_hit.rs index 30a84a17..fad17641 100644 --- a/typesense_codegen/src/models/search_result_hit.rs +++ b/typesense_codegen/src/models/search_result_hit.rs @@ -13,10 +13,10 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchResultHit<'a, D> { +pub struct SearchResultHit { /// (Deprecated) Contains highlighted portions of the search fields #[serde(rename = "highlights", skip_serializing_if = "Option::is_none")] - pub highlights: Option>>, + pub highlights: Option>, /// Highlighted version of the matching document #[serde(rename = "highlight", skip_serializing_if = "Option::is_none")] pub highlight: Option>, @@ -26,7 +26,7 @@ pub struct SearchResultHit<'a, D> { #[serde(rename = "text_match", skip_serializing_if = "Option::is_none")] pub text_match: Option, #[serde(rename = "text_match_info", skip_serializing_if = "Option::is_none")] - pub text_match_info: Option>>, + pub text_match_info: Option>, /// Can be any key-value pair #[serde( rename = "geo_distance_meters", @@ -37,15 +37,13 @@ pub struct SearchResultHit<'a, D> { #[serde(rename = "vector_distance", skip_serializing_if = "Option::is_none")] pub vector_distance: Option, #[serde(rename = "hybrid_search_info", skip_serializing_if = "Option::is_none")] - pub hybrid_search_info: Option>>, + pub hybrid_search_info: Option>, /// Returned only for union query response. Indicates the index of the query which this document matched to. #[serde(rename = "search_index", skip_serializing_if = "Option::is_none")] pub search_index: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a, D> SearchResultHit<'a, D> { +impl SearchResultHit { pub fn new() -> Self { Self { highlights: None, @@ -57,7 +55,6 @@ impl<'a, D> SearchResultHit<'a, D> { vector_distance: None, hybrid_search_info: None, search_index: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_result_hit_hybrid_search_info.rs b/typesense_codegen/src/models/search_result_hit_hybrid_search_info.rs index ee83a376..db8b0546 100644 --- a/typesense_codegen/src/models/search_result_hit_hybrid_search_info.rs +++ b/typesense_codegen/src/models/search_result_hit_hybrid_search_info.rs @@ -14,20 +14,17 @@ use serde::{Deserialize, Serialize}; /// SearchResultHitHybridSearchInfo : Information about hybrid search scoring #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchResultHitHybridSearchInfo<'a> { +pub struct SearchResultHitHybridSearchInfo { /// Combined score from rank fusion of text and vector search #[serde(rename = "rank_fusion_score", skip_serializing_if = "Option::is_none")] pub rank_fusion_score: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> SearchResultHitHybridSearchInfo<'a> { +impl SearchResultHitHybridSearchInfo { /// Information about hybrid search scoring pub fn new() -> Self { Self { rank_fusion_score: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_result_hit_text_match_info.rs b/typesense_codegen/src/models/search_result_hit_text_match_info.rs index 9b3976ec..70824cf7 100644 --- a/typesense_codegen/src/models/search_result_hit_text_match_info.rs +++ b/typesense_codegen/src/models/search_result_hit_text_match_info.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchResultHitTextMatchInfo<'a> { +pub struct SearchResultHitTextMatchInfo { #[serde(rename = "best_field_score", skip_serializing_if = "Option::is_none")] pub best_field_score: Option, #[serde(rename = "best_field_weight", skip_serializing_if = "Option::is_none")] @@ -28,11 +28,9 @@ pub struct SearchResultHitTextMatchInfo<'a> { pub tokens_matched: Option, #[serde(rename = "typo_prefix_score", skip_serializing_if = "Option::is_none")] pub typo_prefix_score: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> SearchResultHitTextMatchInfo<'a> { +impl SearchResultHitTextMatchInfo { pub fn new() -> Self { Self { best_field_score: None, @@ -42,7 +40,6 @@ impl<'a> SearchResultHitTextMatchInfo<'a> { score: None, tokens_matched: None, typo_prefix_score: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_synonym.rs b/typesense_codegen/src/models/search_synonym.rs index 7d383205..a568e417 100644 --- a/typesense_codegen/src/models/search_synonym.rs +++ b/typesense_codegen/src/models/search_synonym.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchSynonym<'a> { +pub struct SearchSynonym { /// For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. #[serde(rename = "root", skip_serializing_if = "Option::is_none")] pub root: Option, @@ -28,11 +28,9 @@ pub struct SearchSynonym<'a> { pub symbols_to_index: Option>, #[serde(rename = "id")] pub id: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> SearchSynonym<'a> { +impl SearchSynonym { pub fn new(synonyms: Vec, id: String) -> Self { Self { root: None, @@ -40,7 +38,6 @@ impl<'a> SearchSynonym<'a> { locale: None, symbols_to_index: None, id, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_synonym_delete_response.rs b/typesense_codegen/src/models/search_synonym_delete_response.rs index 6e4e3d9c..e992247b 100644 --- a/typesense_codegen/src/models/search_synonym_delete_response.rs +++ b/typesense_codegen/src/models/search_synonym_delete_response.rs @@ -13,19 +13,14 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchSynonymDeleteResponse<'a> { +pub struct SearchSynonymDeleteResponse { /// The id of the synonym that was deleted #[serde(rename = "id")] pub id: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> SearchSynonymDeleteResponse<'a> { +impl SearchSynonymDeleteResponse { pub fn new(id: String) -> Self { - Self { - id, - _phantom: PhantomData, - } + Self { id } } } diff --git a/typesense_codegen/src/models/search_synonym_schema.rs b/typesense_codegen/src/models/search_synonym_schema.rs index 8b640295..88cf3edb 100644 --- a/typesense_codegen/src/models/search_synonym_schema.rs +++ b/typesense_codegen/src/models/search_synonym_schema.rs @@ -13,7 +13,7 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchSynonymSchema<'a> { +pub struct SearchSynonymSchema { /// For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. #[serde(rename = "root", skip_serializing_if = "Option::is_none")] pub root: Option, @@ -26,18 +26,15 @@ pub struct SearchSynonymSchema<'a> { /// By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is. #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] pub symbols_to_index: Option>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> SearchSynonymSchema<'a> { +impl SearchSynonymSchema { pub fn new(synonyms: Vec) -> Self { Self { root: None, synonyms, locale: None, symbols_to_index: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_synonyms_response.rs b/typesense_codegen/src/models/search_synonyms_response.rs index ba1bc426..2b6f8f88 100644 --- a/typesense_codegen/src/models/search_synonyms_response.rs +++ b/typesense_codegen/src/models/search_synonyms_response.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SearchSynonymsResponse<'a> { +pub struct SearchSynonymsResponse { #[serde(rename = "synonyms")] - pub synonyms: Vec>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, + pub synonyms: Vec, } -impl<'a> SearchSynonymsResponse<'a> { - pub fn new(synonyms: Vec>) -> Self { - Self { - synonyms, - _phantom: PhantomData, - } +impl SearchSynonymsResponse { + pub fn new(synonyms: Vec) -> Self { + Self { synonyms } } } diff --git a/typesense_codegen/src/models/stemming_dictionary.rs b/typesense_codegen/src/models/stemming_dictionary.rs index 106149ca..13efd545 100644 --- a/typesense_codegen/src/models/stemming_dictionary.rs +++ b/typesense_codegen/src/models/stemming_dictionary.rs @@ -13,23 +13,17 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct StemmingDictionary<'a> { +pub struct StemmingDictionary { /// Unique identifier for the dictionary #[serde(rename = "id")] pub id: String, /// List of word mappings in the dictionary #[serde(rename = "words")] - pub words: Vec>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, + pub words: Vec, } -impl<'a> StemmingDictionary<'a> { - pub fn new(id: String, words: Vec>) -> Self { - Self { - id, - words, - _phantom: PhantomData, - } +impl StemmingDictionary { + pub fn new(id: String, words: Vec) -> Self { + Self { id, words } } } diff --git a/typesense_codegen/src/models/stemming_dictionary_words_inner.rs b/typesense_codegen/src/models/stemming_dictionary_words_inner.rs index 1683b5a0..5d17ba6c 100644 --- a/typesense_codegen/src/models/stemming_dictionary_words_inner.rs +++ b/typesense_codegen/src/models/stemming_dictionary_words_inner.rs @@ -13,23 +13,17 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct StemmingDictionaryWordsInner<'a> { +pub struct StemmingDictionaryWordsInner { /// The word form to be stemmed #[serde(rename = "word")] pub word: String, /// The root form of the word #[serde(rename = "root")] pub root: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> StemmingDictionaryWordsInner<'a> { +impl StemmingDictionaryWordsInner { pub fn new(word: String, root: String) -> Self { - Self { - word, - root, - _phantom: PhantomData, - } + Self { word, root } } } diff --git a/typesense_codegen/src/models/stopwords_set_retrieve_schema.rs b/typesense_codegen/src/models/stopwords_set_retrieve_schema.rs index 2fabdbe8..514bf354 100644 --- a/typesense_codegen/src/models/stopwords_set_retrieve_schema.rs +++ b/typesense_codegen/src/models/stopwords_set_retrieve_schema.rs @@ -13,18 +13,15 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct StopwordsSetRetrieveSchema<'a> { +pub struct StopwordsSetRetrieveSchema { #[serde(rename = "stopwords")] - pub stopwords: Box>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, + pub stopwords: Box, } -impl<'a> StopwordsSetRetrieveSchema<'a> { - pub fn new(stopwords: models::StopwordsSetSchema<'a>) -> Self { +impl StopwordsSetRetrieveSchema { + pub fn new(stopwords: models::StopwordsSetSchema) -> Self { Self { stopwords: Box::new(stopwords), - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/stopwords_set_schema.rs b/typesense_codegen/src/models/stopwords_set_schema.rs index e90a2b82..2a400795 100644 --- a/typesense_codegen/src/models/stopwords_set_schema.rs +++ b/typesense_codegen/src/models/stopwords_set_schema.rs @@ -13,24 +13,21 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct StopwordsSetSchema<'a> { +pub struct StopwordsSetSchema { #[serde(rename = "id")] pub id: String, #[serde(rename = "stopwords")] pub stopwords: Vec, #[serde(rename = "locale", skip_serializing_if = "Option::is_none")] pub locale: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> StopwordsSetSchema<'a> { +impl StopwordsSetSchema { pub fn new(id: String, stopwords: Vec) -> Self { Self { id, stopwords, locale: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/stopwords_sets_retrieve_all_schema.rs b/typesense_codegen/src/models/stopwords_sets_retrieve_all_schema.rs index 368d338c..dc4a2f04 100644 --- a/typesense_codegen/src/models/stopwords_sets_retrieve_all_schema.rs +++ b/typesense_codegen/src/models/stopwords_sets_retrieve_all_schema.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct StopwordsSetsRetrieveAllSchema<'a> { +pub struct StopwordsSetsRetrieveAllSchema { #[serde(rename = "stopwords")] - pub stopwords: Vec>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, + pub stopwords: Vec, } -impl<'a> StopwordsSetsRetrieveAllSchema<'a> { - pub fn new(stopwords: Vec>) -> Self { - Self { - stopwords, - _phantom: PhantomData, - } +impl StopwordsSetsRetrieveAllSchema { + pub fn new(stopwords: Vec) -> Self { + Self { stopwords } } } diff --git a/typesense_codegen/src/models/success_status.rs b/typesense_codegen/src/models/success_status.rs index dc41d00a..d671cd28 100644 --- a/typesense_codegen/src/models/success_status.rs +++ b/typesense_codegen/src/models/success_status.rs @@ -13,18 +13,13 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SuccessStatus<'a> { +pub struct SuccessStatus { #[serde(rename = "success")] pub success: bool, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> SuccessStatus<'a> { +impl SuccessStatus { pub fn new(success: bool) -> Self { - Self { - success, - _phantom: PhantomData, - } + Self { success } } } diff --git a/typesense_codegen/src/models/synonym_item_delete_schema.rs b/typesense_codegen/src/models/synonym_item_delete_schema.rs index 215386a8..9cc3360f 100644 --- a/typesense_codegen/src/models/synonym_item_delete_schema.rs +++ b/typesense_codegen/src/models/synonym_item_delete_schema.rs @@ -13,19 +13,14 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SynonymItemDeleteSchema<'a> { +pub struct SynonymItemDeleteSchema { /// ID of the deleted synonym item #[serde(rename = "id")] pub id: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> SynonymItemDeleteSchema<'a> { +impl SynonymItemDeleteSchema { pub fn new(id: String) -> Self { - Self { - id, - _phantom: PhantomData, - } + Self { id } } } diff --git a/typesense_codegen/src/models/synonym_set_delete_schema.rs b/typesense_codegen/src/models/synonym_set_delete_schema.rs index f63038b6..b7aa2d96 100644 --- a/typesense_codegen/src/models/synonym_set_delete_schema.rs +++ b/typesense_codegen/src/models/synonym_set_delete_schema.rs @@ -13,19 +13,14 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SynonymSetDeleteSchema<'a> { +pub struct SynonymSetDeleteSchema { /// Name of the deleted synonym set #[serde(rename = "name")] pub name: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> SynonymSetDeleteSchema<'a> { +impl SynonymSetDeleteSchema { pub fn new(name: String) -> Self { - Self { - name, - _phantom: PhantomData, - } + Self { name } } } diff --git a/typesense_codegen/src/models/synonym_set_schema.rs b/typesense_codegen/src/models/synonym_set_schema.rs index ee1d81f0..e035355b 100644 --- a/typesense_codegen/src/models/synonym_set_schema.rs +++ b/typesense_codegen/src/models/synonym_set_schema.rs @@ -13,23 +13,17 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SynonymSetSchema<'a> { +pub struct SynonymSetSchema { /// Array of synonym items #[serde(rename = "items")] - pub items: Vec>, + pub items: Vec>, /// Name of the synonym set #[serde(rename = "name")] pub name: String, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> SynonymSetSchema<'a> { - pub fn new(items: Vec>, name: String) -> Self { - Self { - items, - name, - _phantom: PhantomData, - } +impl SynonymSetSchema { + pub fn new(items: Vec>, name: String) -> Self { + Self { items, name } } } diff --git a/typesense_codegen/src/models/synonym_sets_retrieve_schema.rs b/typesense_codegen/src/models/synonym_sets_retrieve_schema.rs index ea9fd3c9..d18f21ea 100644 --- a/typesense_codegen/src/models/synonym_sets_retrieve_schema.rs +++ b/typesense_codegen/src/models/synonym_sets_retrieve_schema.rs @@ -13,19 +13,14 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SynonymSetsRetrieveSchema<'a> { +pub struct SynonymSetsRetrieveSchema { /// Array of synonym sets #[serde(rename = "synonym_sets")] - pub synonym_sets: Vec>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, + pub synonym_sets: Vec, } -impl<'a> SynonymSetsRetrieveSchema<'a> { - pub fn new(synonym_sets: Vec>) -> Self { - Self { - synonym_sets, - _phantom: PhantomData, - } +impl SynonymSetsRetrieveSchema { + pub fn new(synonym_sets: Vec) -> Self { + Self { synonym_sets } } } diff --git a/typesense_codegen/src/models/update_documents_200_response.rs b/typesense_codegen/src/models/update_documents_200_response.rs index e948033b..fd887fc8 100644 --- a/typesense_codegen/src/models/update_documents_200_response.rs +++ b/typesense_codegen/src/models/update_documents_200_response.rs @@ -13,19 +13,14 @@ use ::std::{borrow::Cow, marker::PhantomData}; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct UpdateDocuments200Response<'a> { +pub struct UpdateDocuments200Response { /// The number of documents that have been updated #[serde(rename = "num_updated")] pub num_updated: i32, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> UpdateDocuments200Response<'a> { +impl UpdateDocuments200Response { pub fn new(num_updated: i32) -> Self { - Self { - num_updated, - _phantom: PhantomData, - } + Self { num_updated } } } diff --git a/typesense_codegen/src/models/voice_query_model_collection_config.rs b/typesense_codegen/src/models/voice_query_model_collection_config.rs index 6042a7bc..72b2d8ab 100644 --- a/typesense_codegen/src/models/voice_query_model_collection_config.rs +++ b/typesense_codegen/src/models/voice_query_model_collection_config.rs @@ -14,19 +14,14 @@ use serde::{Deserialize, Serialize}; /// VoiceQueryModelCollectionConfig : Configuration for the voice query model #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct VoiceQueryModelCollectionConfig<'a> { +pub struct VoiceQueryModelCollectionConfig { #[serde(rename = "model_name", skip_serializing_if = "Option::is_none")] pub model_name: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> VoiceQueryModelCollectionConfig<'a> { +impl VoiceQueryModelCollectionConfig { /// Configuration for the voice query model pub fn new() -> Self { - Self { - model_name: None, - _phantom: PhantomData, - } + Self { model_name: None } } } diff --git a/xtask/src/add_vendor_attributes.rs b/xtask/src/add_vendor_attributes.rs index 9eece4e3..25612080 100644 --- a/xtask/src/add_vendor_attributes.rs +++ b/xtask/src/add_vendor_attributes.rs @@ -24,28 +24,25 @@ pub fn add_vendor_attributes(doc: &mut OpenAPI) -> Result<(), String> { attrs.schema_field_type_overrides( "SearchResult", [ - ("hits", "Option>>"), - ( - "grouped_hits", - "Option>>", - ), + ("hits", "Option>>"), + ("grouped_hits", "Option>>"), ], )?; attrs.schema_field_type_overrides( "SearchGroupedHit", - [("hits", "Vec>")], + [("hits", "Vec>")], )?; attrs.schema_field_type_overrides("SearchResultHit", [("document", "Option")])?; attrs.schema_field_type_overrides( "MultiSearchResult", - [("results", "Vec>")], + [("results", "Vec>")], )?; // Operations attrs .operation("/collections/{collectionName}/documents/search", "get") .generic_parameter("D: for<'de> serde::Deserialize<'de> + Serialize")? - .return_type("models::SearchResult<'static, D>")?; + .return_type("models::SearchResult")?; attrs .operation("/multi_search", "post") @@ -54,7 +51,7 @@ pub fn add_vendor_attributes(doc: &mut OpenAPI) -> Result<(), String> { // The endpoint return `null` if no schema changes are in progress attrs .operation("/operations/schema_changes", "get") - .return_type("Option>>")?; + .return_type("Option>")?; // The documents /import endpoint expects a text/plain body and response attrs diff --git a/xtask/src/preprocess_openapi.rs b/xtask/src/preprocess_openapi.rs index 870e547f..318c79e7 100644 --- a/xtask/src/preprocess_openapi.rs +++ b/xtask/src/preprocess_openapi.rs @@ -229,22 +229,31 @@ fn collect_property(prop: &OpenAPIProperty) -> Vec { fn schemas_mark_owned_data(doc: &mut OpenAPI) { let mut request_schemas = HashSet::new(); - doc.paths.iter().for_each(|(_, pms)| { - pms.iter().for_each(|(_, pm)| { - if let Some(ps) = &pm.parameters { - ps.iter().for_each(|p| { - if let Some(s) = &p.schema { + doc.paths.iter_mut().for_each(|(_, pms)| { + pms.iter_mut().for_each(|(_, pm)| { + if let Some(ps) = &mut pm.parameters { + ps.iter_mut().for_each(|p| { + if let Some(s) = &mut p.schema { + if s.r#type.as_deref() == Some("object") || s.one_of.is_some() { + s.extra + .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); + } request_schemas.extend(collect_property(s)); } }) } - if let Some(reqb) = &pm.request_body - && let Some(cs) = &reqb.content + + if let Some(reqb) = &mut pm.request_body + && let Some(cs) = &mut reqb.content { - cs.iter().for_each(|(_, c)| { - c.schema.as_ref().iter().for_each(|cp| { - request_schemas.extend(collect_property(cp)); - }) + cs.iter_mut().for_each(|(_, c)| { + if let Some(s) = &mut c.schema { + if s.r#type.as_deref() == Some("object") || s.one_of.is_some() { + s.extra + .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); + } + request_schemas.extend(collect_property(s)); + } }) } }) @@ -270,7 +279,7 @@ fn schemas_mark_owned_data(doc: &mut OpenAPI) { for (_, prop) in schema.properties.iter_mut().flat_map(|v| v.iter_mut()) { for inner in prop.one_of.iter_mut().flat_map(|v| v.iter_mut()) { - if inner.r#type.as_deref() != Some("object") { + if inner.r#type.as_deref() != Some("object") && inner.one_of.is_none() { continue; } inner @@ -278,7 +287,7 @@ fn schemas_mark_owned_data(doc: &mut OpenAPI) { .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); } for inner in prop.any_of.iter_mut().flat_map(|v| v.iter_mut()) { - if inner.r#type.as_deref() != Some("object") { + if inner.r#type.as_deref() != Some("object") && inner.one_of.is_none() { continue; } inner @@ -286,14 +295,14 @@ fn schemas_mark_owned_data(doc: &mut OpenAPI) { .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); } if let Some(inner) = &mut prop.items - && inner.r#type.as_deref() == Some("object") + && (inner.r#type.as_deref() == Some("object") || inner.one_of.is_some()) { inner .extra .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); } - if prop.r#type.as_deref() != Some("object") { + if prop.r#type.as_deref() != Some("object") && prop.one_of.is_none() { continue; } prop.extra From 2728a6cb82c35368e9b3dfd06b23cddaec6fd112 Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Thu, 13 Nov 2025 02:00:39 +0000 Subject: [PATCH 14/17] OpenAPI fields reorder --- preprocessed_openapi.yml | 1062 +++++++++++++++---------------- xtask/src/preprocess_openapi.rs | 14 +- 2 files changed, 539 insertions(+), 537 deletions(-) diff --git a/preprocessed_openapi.yml b/preprocessed_openapi.yml index b5b62fda..627f7daf 100644 --- a/preprocessed_openapi.yml +++ b/preprocessed_openapi.yml @@ -96,19 +96,19 @@ paths: - name: exclude_fields in: query schema: - description: Comma-separated list of fields from the collection to exclude from the response type: string + description: Comma-separated list of fields from the collection to exclude from the response - name: limit in: query schema: + type: integer description: | Number of collections to fetch. Default: returns all collections. - type: integer - name: offset in: query schema: - description: Identifies the starting point to return collections when paginating. type: integer + description: Identifies the starting point to return collections when paginating. responses: '200': description: List of all collections @@ -126,8 +126,8 @@ paths: description: When a collection is created, we give it a name and describe the fields that will be indexed from the documents added to the collection. operationId: createCollection requestBody: - description: The collection object to be created required: true + description: The collection object to be created content: application/json: schema: @@ -160,9 +160,9 @@ paths: operationId: getCollection parameters: - name: collectionName + required: true in: path description: The name of the collection to retrieve - required: true schema: type: string responses: @@ -186,14 +186,14 @@ paths: operationId: updateCollection parameters: - name: collectionName + required: true in: path description: The name of the collection to update - required: true schema: type: string requestBody: - description: The document object with fields to be updated required: true + description: The document object with fields to be updated content: application/json: schema: @@ -225,9 +225,9 @@ paths: operationId: deleteCollection parameters: - name: collectionName + required: true in: path description: The name of the collection to delete - required: true schema: type: string responses: @@ -252,9 +252,9 @@ paths: operationId: indexDocument parameters: - name: collectionName + required: true in: path description: The name of the collection to add the document to - required: true schema: type: string - name: action @@ -270,13 +270,13 @@ paths: schema: $ref: '#/components/schemas/DirtyValues' requestBody: - description: The document object to be indexed required: true + description: The document object to be indexed content: application/json: schema: - description: Can be any key-value pair type: object + description: Can be any key-value pair x-go-type: interface{} x-rust-is-used-as-input: true responses: @@ -285,8 +285,8 @@ paths: content: application/json: schema: - description: Can be any key-value pair type: object + description: Can be any key-value pair '404': description: Collection not found content: @@ -301,9 +301,9 @@ paths: operationId: updateDocuments parameters: - name: collectionName + required: true in: path description: The name of the collection to update documents in - required: true schema: type: string - name: filter_by @@ -312,13 +312,13 @@ paths: type: string example: 'num_employees:>100 && country: [USA, UK]' requestBody: - description: The document fields to be updated required: true + description: The document fields to be updated content: application/json: schema: - description: Can be any key-value pair type: object + description: Can be any key-value pair x-go-type: interface{} x-rust-is-used-as-input: true x-rust-params-generic-parameter: B @@ -334,8 +334,8 @@ paths: - num_updated properties: num_updated: - description: The number of documents that have been updated type: integer + description: The number of documents that have been updated example: 1 '400': description: Bad request, see error message for details @@ -358,9 +358,9 @@ paths: operationId: deleteDocuments parameters: - name: collectionName + required: true in: path description: The name of the collection to delete documents from - required: true schema: type: string - name: filter_by @@ -371,8 +371,8 @@ paths: - name: batch_size in: query schema: - description: Batch size parameter controls the number of documents that should be deleted at a time. A larger value will speed up deletions, but will impact performance of other operations running on the server. type: integer + description: Batch size parameter controls the number of documents that should be deleted at a time. A larger value will speed up deletions, but will impact performance of other operations running on the server. - name: ignore_not_found in: query schema: @@ -380,8 +380,8 @@ paths: - name: truncate in: query schema: - description: When true, removes all documents from the collection while preserving the collection and its schema. type: boolean + description: When true, removes all documents from the collection while preserving the collection and its schema. responses: '200': description: Documents successfully deleted @@ -409,202 +409,202 @@ paths: operationId: searchCollection parameters: - name: collectionName + required: true in: path description: The name of the collection to search for the document under - required: true schema: type: string - name: q in: query schema: - description: The query text to search for in the collection. Use * as the search string to return all documents. This is typically useful when used in conjunction with filter_by. type: string + description: The query text to search for in the collection. Use * as the search string to return all documents. This is typically useful when used in conjunction with filter_by. - name: query_by in: query schema: - description: A list of `string` fields that should be queried against. Multiple fields are separated with a comma. type: string + description: A list of `string` fields that should be queried against. Multiple fields are separated with a comma. - name: nl_query in: query schema: - description: Whether to use natural language processing to parse the query. type: boolean + description: Whether to use natural language processing to parse the query. - name: nl_model_id in: query schema: - description: The ID of the natural language model to use. type: string + description: The ID of the natural language model to use. - name: query_by_weights in: query schema: - description: The relative weight to give each `query_by` field when ranking results. This can be used to boost fields in priority, when looking for matches. Multiple fields are separated with a comma. type: string + description: The relative weight to give each `query_by` field when ranking results. This can be used to boost fields in priority, when looking for matches. Multiple fields are separated with a comma. - name: text_match_type in: query schema: - description: In a multi-field matching context, this parameter determines how the representative text match score of a record is calculated. Possible values are max_score (default) or max_weight. type: string + description: In a multi-field matching context, this parameter determines how the representative text match score of a record is calculated. Possible values are max_score (default) or max_weight. - name: prefix in: query schema: - description: Boolean field to indicate that the last word in the query should be treated as a prefix, and not as a whole word. This is used for building autocomplete and instant search interfaces. Defaults to true. type: string + description: Boolean field to indicate that the last word in the query should be treated as a prefix, and not as a whole word. This is used for building autocomplete and instant search interfaces. Defaults to true. - name: infix in: query schema: - description: If infix index is enabled for this field, infix searching can be done on a per-field basis by sending a comma separated string parameter called infix to the search query. This parameter can have 3 values; `off` infix search is disabled, which is default `always` infix search is performed along with regular search `fallback` infix search is performed if regular search does not produce results type: string + description: If infix index is enabled for this field, infix searching can be done on a per-field basis by sending a comma separated string parameter called infix to the search query. This parameter can have 3 values; `off` infix search is disabled, which is default `always` infix search is performed along with regular search `fallback` infix search is performed if regular search does not produce results - name: max_extra_prefix in: query schema: - description: There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query "K2100" has 2 extra symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. type: integer + description: There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query "K2100" has 2 extra symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. - name: max_extra_suffix in: query schema: - description: There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query "K2100" has 2 extra symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. type: integer + description: There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query "K2100" has 2 extra symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. - name: filter_by in: query schema: - description: Filter conditions for refining your open api validator search results. Separate multiple conditions with &&. type: string + description: Filter conditions for refining your open api validator search results. Separate multiple conditions with &&. example: 'num_employees:>100 && country: [USA, UK]' - name: max_filter_by_candidates in: query schema: - description: Controls the number of similar words that Typesense considers during fuzzy search on filter_by values. Useful for controlling prefix matches like company_name:Acm*. type: integer + description: Controls the number of similar words that Typesense considers during fuzzy search on filter_by values. Useful for controlling prefix matches like company_name:Acm*. - name: sort_by in: query schema: - description: A list of numerical fields and their corresponding sort orders that will be used for ordering your results. Up to 3 sort fields can be specified. The text similarity score is exposed as a special `_text_match` field that you can use in the list of sorting fields. If no `sort_by` parameter is specified, results are sorted by `_text_match:desc,default_sorting_field:desc` type: string + description: A list of numerical fields and their corresponding sort orders that will be used for ordering your results. Up to 3 sort fields can be specified. The text similarity score is exposed as a special `_text_match` field that you can use in the list of sorting fields. If no `sort_by` parameter is specified, results are sorted by `_text_match:desc,default_sorting_field:desc` example: num_employees:desc - name: facet_by in: query schema: - description: A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. type: string + description: A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. - name: max_facet_values in: query schema: - description: Maximum number of facet values to be returned. type: integer + description: Maximum number of facet values to be returned. - name: facet_query in: query schema: - description: Facet values that are returned can now be filtered via this parameter. The matching facet text is also highlighted. For example, when faceting by `category`, you can set `facet_query=category:shoe` to return only facet values that contain the prefix "shoe". type: string + description: Facet values that are returned can now be filtered via this parameter. The matching facet text is also highlighted. For example, when faceting by `category`, you can set `facet_query=category:shoe` to return only facet values that contain the prefix "shoe". - name: num_typos in: query schema: + type: string description: | The number of typographical errors (1 or 2) that would be tolerated. Default: 2 - type: string - name: page in: query schema: - description: Results from this specific page number would be fetched. type: integer + description: Results from this specific page number would be fetched. - name: per_page in: query schema: - description: 'Number of results to fetch per page. Default: 10' type: integer + description: 'Number of results to fetch per page. Default: 10' - name: limit in: query schema: + type: integer description: | Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10. - type: integer - name: offset in: query schema: - description: Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. type: integer + description: Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. - name: group_by in: query schema: - description: You can aggregate search results into groups or buckets by specify one or more `group_by` fields. Separate multiple fields with a comma. To group on a particular field, it must be a faceted field. type: string + description: You can aggregate search results into groups or buckets by specify one or more `group_by` fields. Separate multiple fields with a comma. To group on a particular field, it must be a faceted field. - name: group_limit in: query schema: + type: integer description: | Maximum number of hits to be returned for every group. If the `group_limit` is set as `K` then only the top K hits in each group are returned in the response. Default: 3 - type: integer - name: group_missing_values in: query schema: + type: boolean description: | Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true - type: boolean - name: include_fields in: query schema: - description: List of fields from the document to include in the search result type: string + description: List of fields from the document to include in the search result - name: exclude_fields in: query schema: - description: List of fields from the document to exclude in the search result type: string + description: List of fields from the document to exclude in the search result - name: highlight_full_fields in: query schema: - description: List of fields which should be highlighted fully without snippeting type: string + description: List of fields which should be highlighted fully without snippeting - name: highlight_affix_num_tokens in: query schema: + type: integer description: | The number of tokens that should surround the highlighted text on each side. Default: 4 - type: integer - name: highlight_start_tag in: query schema: + type: string description: | The start tag used for the highlighted snippets. Default: `` - type: string - name: highlight_end_tag in: query schema: + type: string description: | The end tag used for the highlighted snippets. Default: `` - type: string - name: enable_highlight_v1 in: query schema: - description: | - Flag for enabling/disabling the deprecated, old highlight structure in the response. Default: true type: boolean default: true + description: | + Flag for enabling/disabling the deprecated, old highlight structure in the response. Default: true - name: enable_analytics in: query schema: - description: | - Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). type: boolean default: true + description: | + Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). - name: snippet_threshold in: query schema: + type: integer description: | Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 - type: integer - name: synonym_sets in: query schema: - description: List of synonym set names to associate with this search query type: string + description: List of synonym set names to associate with this search query example: synonym_set_1,synonym_set_2 - name: drop_tokens_threshold in: query schema: + type: integer description: | If the number of results found for a specific query is less than this number, Typesense will attempt to drop the tokens in the query until enough results are found. Tokens that have the least individual hits are dropped first. Set to 0 to disable. Default: 10 - type: integer - name: drop_tokens_mode in: query schema: @@ -612,220 +612,220 @@ paths: - name: typo_tokens_threshold in: query schema: + type: integer description: | If the number of results found for a specific query is less than this number, Typesense will attempt to look for tokens with more typos until enough results are found. Default: 100 - type: integer - name: enable_typos_for_alpha_numerical_tokens in: query schema: + type: boolean description: | Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. - type: boolean - name: filter_curated_hits in: query schema: + type: boolean description: | Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false - type: boolean - name: enable_synonyms in: query schema: + type: boolean description: | If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true - type: boolean - name: synonym_prefix in: query schema: + type: boolean description: | Allow synonym resolution on word prefixes in the query. Default: false - type: boolean - name: synonym_num_typos in: query schema: + type: integer description: | Allow synonym resolution on typo-corrected words in the query. Default: 0 - type: integer - name: pinned_hits in: query schema: + type: string description: | A list of records to unconditionally include in the search results at specific positions. An example use case would be to feature or promote certain items on the top of search results. A list of `record_id:hit_position`. Eg: to include a record with ID 123 at Position 1 and another record with ID 456 at Position 5, you'd specify `123:1,456:5`. You could also use the Overrides feature to override search results based on rules. Overrides are applied first, followed by `pinned_hits` and finally `hidden_hits`. - type: string - name: hidden_hits in: query schema: + type: string description: | A list of records to unconditionally hide from search results. A list of `record_id`s to hide. Eg: to hide records with IDs 123 and 456, you'd specify `123,456`. You could also use the Overrides feature to override search results based on rules. Overrides are applied first, followed by `pinned_hits` and finally `hidden_hits`. - type: string - name: override_tags in: query schema: - description: Comma separated list of tags to trigger the curations rules that match the tags. type: string + description: Comma separated list of tags to trigger the curations rules that match the tags. - name: highlight_fields in: query schema: + type: string description: | A list of custom fields that must be highlighted even if you don't query for them - type: string - name: split_join_tokens in: query schema: + type: string description: | Treat space as typo: search for q=basket ball if q=basketball is not found or vice-versa. Splitting/joining of tokens will only be attempted if the original query produces no results. To always trigger this behavior, set value to `always``. To disable, set value to `off`. Default is `fallback`. - type: string - name: pre_segmented_query in: query schema: + type: boolean description: | You can index content from any logographic language into Typesense if you are able to segment / split the text into space-separated words yourself before indexing and querying. Set this parameter to true to do the same - type: boolean - name: preset in: query schema: + type: string description: | Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. - type: string - name: enable_overrides in: query schema: - description: | - If you have some overrides defined but want to disable all of them during query time, you can do that by setting this parameter to false type: boolean default: false + description: | + If you have some overrides defined but want to disable all of them during query time, you can do that by setting this parameter to false - name: prioritize_exact_match in: query schema: - description: | - Set this parameter to true to ensure that an exact match is ranked above the others type: boolean default: true + description: | + Set this parameter to true to ensure that an exact match is ranked above the others - name: max_candidates in: query schema: + type: integer description: | Control the number of words that Typesense considers for typo and prefix searching. - type: integer - name: prioritize_token_position in: query schema: - description: | - Make Typesense prioritize documents where the query words appear earlier in the text. type: boolean default: false + description: | + Make Typesense prioritize documents where the query words appear earlier in the text. - name: prioritize_num_matching_fields in: query schema: - description: | - Make Typesense prioritize documents where the query words appear in more number of fields. type: boolean default: true + description: | + Make Typesense prioritize documents where the query words appear in more number of fields. - name: enable_typos_for_numerical_tokens in: query schema: - description: | - Make Typesense disable typos for numerical tokens. type: boolean default: true + description: | + Make Typesense disable typos for numerical tokens. - name: exhaustive_search in: query schema: + type: boolean description: | Setting this to true will make Typesense consider all prefixes and typo corrections of the words in the query without stopping early when enough results are found (drop_tokens_threshold and typo_tokens_threshold configurations are ignored). - type: boolean - name: search_cutoff_ms in: query schema: + type: integer description: | Typesense will attempt to return results early if the cutoff time has elapsed. This is not a strict guarantee and facet computation is not bound by this parameter. - type: integer - name: use_cache in: query schema: + type: boolean description: | Enable server side caching of search query results. By default, caching is disabled. - type: boolean - name: cache_ttl in: query schema: + type: integer description: | The duration (in seconds) that determines how long the search query is cached. This value can be set on a per-query basis. Default: 60. - type: integer - name: min_len_1typo in: query schema: + type: integer description: | Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos. - type: integer - name: min_len_2typo in: query schema: + type: integer description: | Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos. - type: integer - name: vector_query in: query schema: + type: string description: | Vector query expression for fetching documents "closest" to a given query/document vector. - type: string - name: remote_embedding_timeout_ms in: query schema: + type: integer description: | Timeout (in milliseconds) for fetching remote embeddings. - type: integer - name: remote_embedding_num_tries in: query schema: + type: integer description: | Number of times to retry fetching remote embeddings. - type: integer - name: facet_strategy in: query schema: + type: string description: | Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). - type: string - name: stopwords in: query schema: + type: string description: | Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query. - type: string - name: facet_return_parent in: query schema: + type: string description: | Comma separated string of nested facet fields whose parent object should be returned in facet response. - type: string - name: voice_query in: query schema: + type: string description: | The base64 encoded audio file in 16 khz 16-bit WAV format. - type: string - name: conversation in: query schema: + type: boolean description: | Enable conversational search. - type: boolean - name: conversation_model_id in: query schema: + type: string description: | The Id of Conversation Model to be used. - type: string - name: conversation_id in: query schema: + type: string description: | The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. - type: string responses: '200': description: Search results @@ -872,9 +872,9 @@ paths: operationId: retrieveSynonymSet parameters: - name: synonymSetName + required: true in: path description: The name of the synonym set to retrieve - required: true schema: type: string responses: @@ -898,14 +898,14 @@ paths: operationId: upsertSynonymSet parameters: - name: synonymSetName + required: true in: path description: The name of the synonym set to create/update - required: true schema: type: string requestBody: - description: The synonym set to be created/updated required: true + description: The synonym set to be created/updated content: application/json: schema: @@ -931,9 +931,9 @@ paths: operationId: deleteSynonymSet parameters: - name: synonymSetName + required: true in: path description: The name of the synonym set to delete - required: true schema: type: string responses: @@ -958,9 +958,9 @@ paths: operationId: retrieveSynonymSetItems parameters: - name: synonymSetName + required: true in: path description: The name of the synonym set to retrieve items for - required: true schema: type: string responses: @@ -987,15 +987,15 @@ paths: operationId: retrieveSynonymSetItem parameters: - name: synonymSetName + required: true in: path description: The name of the synonym set - required: true schema: type: string - name: itemId + required: true in: path description: The id of the synonym item to retrieve - required: true schema: type: string responses: @@ -1019,20 +1019,20 @@ paths: operationId: upsertSynonymSetItem parameters: - name: synonymSetName + required: true in: path description: The name of the synonym set - required: true schema: type: string - name: itemId + required: true in: path description: The id of the synonym item to upsert - required: true schema: type: string requestBody: - description: The synonym item to be created/updated required: true + description: The synonym item to be created/updated content: application/json: schema: @@ -1058,15 +1058,15 @@ paths: operationId: deleteSynonymSetItem parameters: - name: synonymSetName + required: true in: path description: The name of the synonym set - required: true schema: type: string - name: itemId + required: true in: path description: The id of the synonym item to delete - required: true schema: type: string responses: @@ -1107,9 +1107,9 @@ paths: operationId: retrieveCurationSet parameters: - name: curationSetName + required: true in: path description: The name of the curation set to retrieve - required: true schema: type: string responses: @@ -1133,14 +1133,14 @@ paths: operationId: upsertCurationSet parameters: - name: curationSetName + required: true in: path description: The name of the curation set to create/update - required: true schema: type: string requestBody: - description: The curation set to be created/updated required: true + description: The curation set to be created/updated content: application/json: schema: @@ -1166,9 +1166,9 @@ paths: operationId: deleteCurationSet parameters: - name: curationSetName + required: true in: path description: The name of the curation set to delete - required: true schema: type: string responses: @@ -1193,9 +1193,9 @@ paths: operationId: retrieveCurationSetItems parameters: - name: curationSetName + required: true in: path description: The name of the curation set to retrieve items for - required: true schema: type: string responses: @@ -1222,15 +1222,15 @@ paths: operationId: retrieveCurationSetItem parameters: - name: curationSetName + required: true in: path description: The name of the curation set - required: true schema: type: string - name: itemId + required: true in: path description: The id of the curation item to retrieve - required: true schema: type: string responses: @@ -1254,20 +1254,20 @@ paths: operationId: upsertCurationSetItem parameters: - name: curationSetName + required: true in: path description: The name of the curation set - required: true schema: type: string - name: itemId + required: true in: path description: The id of the curation item to upsert - required: true schema: type: string requestBody: - description: The curation item to be created/updated required: true + description: The curation item to be created/updated content: application/json: schema: @@ -1293,15 +1293,15 @@ paths: operationId: deleteCurationSetItem parameters: - name: curationSetName + required: true in: path description: The name of the curation set - required: true schema: type: string - name: itemId + required: true in: path description: The id of the curation item to delete - required: true schema: type: string responses: @@ -1326,26 +1326,26 @@ paths: operationId: exportDocuments parameters: - name: collectionName + required: true in: path description: The name of the collection - required: true schema: type: string - name: filter_by in: query schema: - description: Filter conditions for refining your search results. Separate multiple conditions with &&. type: string + description: Filter conditions for refining your search results. Separate multiple conditions with &&. - name: include_fields in: query schema: - description: List of fields from the document to include in the search result type: string + description: List of fields from the document to include in the search result - name: exclude_fields in: query schema: - description: List of fields from the document to exclude in the search result type: string + description: List of fields from the document to exclude in the search result responses: '200': description: Exports all the documents in a given collection. @@ -1373,9 +1373,9 @@ paths: operationId: importDocuments parameters: - name: collectionName + required: true in: path description: The name of the collection - required: true schema: type: string - name: batch_size @@ -1385,8 +1385,8 @@ paths: - name: return_id in: query schema: - description: Returning the id of the imported documents. If you want the import response to return the ingested document's id in the response, you can use the return_id parameter. type: boolean + description: Returning the id of the imported documents. If you want the import response to return the ingested document's id in the response, you can use the return_id parameter. - name: remote_embedding_batch_size in: query schema: @@ -1404,13 +1404,13 @@ paths: schema: $ref: '#/components/schemas/DirtyValues' requestBody: - description: The json array of documents or the JSONL file to import required: true + description: The json array of documents or the JSONL file to import content: application/octet-stream: schema: - description: The JSONL file to import type: string + description: The JSONL file to import responses: '200': description: Result of the import operation. Each line of the response indicates the result of each document present in the request body (in the same order). If the import of a single document fails, it does not affect the other documents. If there is a failure, the response line will include a corresponding error message and as well as the actual document content. @@ -1444,15 +1444,15 @@ paths: operationId: getDocument parameters: - name: collectionName + required: true in: path description: The name of the collection to search for the document under - required: true schema: type: string - name: documentId + required: true in: path description: The Document ID - required: true schema: type: string responses: @@ -1461,8 +1461,8 @@ paths: content: application/json: schema: - description: Can be any key-value pair type: object + description: Can be any key-value pair '404': description: The document or collection was not found content: @@ -1477,15 +1477,15 @@ paths: operationId: updateDocument parameters: - name: collectionName + required: true in: path description: The name of the collection to search for the document under - required: true schema: type: string - name: documentId + required: true in: path description: The Document ID - required: true schema: type: string - name: dirty_values @@ -1494,13 +1494,13 @@ paths: schema: $ref: '#/components/schemas/DirtyValues' requestBody: - description: The document object with fields to be updated required: true + description: The document object with fields to be updated content: application/json: schema: - description: Can be any key-value pair type: object + description: Can be any key-value pair x-go-type: interface{} x-rust-is-used-as-input: true x-rust-params-generic-parameter: B @@ -1511,8 +1511,8 @@ paths: content: application/json: schema: - description: Can be any key-value pair type: object + description: Can be any key-value pair '404': description: The document or collection was not found content: @@ -1528,15 +1528,15 @@ paths: operationId: deleteDocument parameters: - name: collectionName + required: true in: path description: The name of the collection to search for the document under - required: true schema: type: string - name: documentId + required: true in: path description: The Document ID - required: true schema: type: string responses: @@ -1545,8 +1545,8 @@ paths: content: application/json: schema: - description: Can be any key-value pair type: object + description: Can be any key-value pair '404': description: The document or collection was not found content: @@ -1604,9 +1604,9 @@ paths: operationId: retrieveConversationModel parameters: - name: modelId + required: true in: path description: The id of the conversation model to retrieve - required: true schema: type: string responses: @@ -1624,9 +1624,9 @@ paths: operationId: updateConversationModel parameters: - name: modelId + required: true in: path description: The id of the conversation model to update - required: true schema: type: string requestBody: @@ -1650,9 +1650,9 @@ paths: operationId: deleteConversationModel parameters: - name: modelId + required: true in: path description: The id of the conversation model to delete - required: true schema: type: string responses: @@ -1715,9 +1715,9 @@ paths: operationId: getKey parameters: - name: keyId + required: true in: path description: The ID of the key to retrieve - required: true schema: type: integer format: int64 @@ -1741,9 +1741,9 @@ paths: operationId: deleteKey parameters: - name: keyId + required: true in: path description: The ID of the key to delete - required: true schema: type: integer format: int64 @@ -1789,9 +1789,9 @@ paths: operationId: upsertAlias parameters: - name: aliasName + required: true in: path description: The name of the alias to create/update - required: true schema: type: string requestBody: @@ -1827,9 +1827,9 @@ paths: operationId: getAlias parameters: - name: aliasName + required: true in: path description: The name of the alias to retrieve - required: true schema: type: string responses: @@ -1852,9 +1852,9 @@ paths: operationId: deleteAlias parameters: - name: aliasName + required: true in: path description: The name of the alias to delete - required: true schema: type: string responses: @@ -1927,9 +1927,9 @@ paths: operationId: takeSnapshot parameters: - name: snapshot_path + required: true in: query description: The directory on the server where the snapshot should be saved. - required: true schema: type: string responses: @@ -2019,158 +2019,158 @@ paths: - name: q in: query schema: - description: The query text to search for in the collection. Use * as the search string to return all documents. This is typically useful when used in conjunction with filter_by. type: string + description: The query text to search for in the collection. Use * as the search string to return all documents. This is typically useful when used in conjunction with filter_by. - name: query_by in: query schema: - description: A list of `string` fields that should be queried against. Multiple fields are separated with a comma. type: string + description: A list of `string` fields that should be queried against. Multiple fields are separated with a comma. - name: query_by_weights in: query schema: - description: The relative weight to give each `query_by` field when ranking results. This can be used to boost fields in priority, when looking for matches. Multiple fields are separated with a comma. type: string + description: The relative weight to give each `query_by` field when ranking results. This can be used to boost fields in priority, when looking for matches. Multiple fields are separated with a comma. - name: text_match_type in: query schema: - description: In a multi-field matching context, this parameter determines how the representative text match score of a record is calculated. Possible values are max_score (default) or max_weight. type: string + description: In a multi-field matching context, this parameter determines how the representative text match score of a record is calculated. Possible values are max_score (default) or max_weight. - name: prefix in: query schema: - description: Boolean field to indicate that the last word in the query should be treated as a prefix, and not as a whole word. This is used for building autocomplete and instant search interfaces. Defaults to true. type: string + description: Boolean field to indicate that the last word in the query should be treated as a prefix, and not as a whole word. This is used for building autocomplete and instant search interfaces. Defaults to true. - name: infix in: query schema: - description: If infix index is enabled for this field, infix searching can be done on a per-field basis by sending a comma separated string parameter called infix to the search query. This parameter can have 3 values; `off` infix search is disabled, which is default `always` infix search is performed along with regular search `fallback` infix search is performed if regular search does not produce results type: string + description: If infix index is enabled for this field, infix searching can be done on a per-field basis by sending a comma separated string parameter called infix to the search query. This parameter can have 3 values; `off` infix search is disabled, which is default `always` infix search is performed along with regular search `fallback` infix search is performed if regular search does not produce results - name: max_extra_prefix in: query schema: - description: There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query "K2100" has 2 extra symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. type: integer + description: There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query "K2100" has 2 extra symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. - name: max_extra_suffix in: query schema: - description: There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query "K2100" has 2 extra symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. type: integer + description: There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query "K2100" has 2 extra symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. - name: filter_by in: query schema: - description: Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. type: string + description: Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. example: 'num_employees:>100 && country: [USA, UK]' - name: sort_by in: query schema: - description: A list of numerical fields and their corresponding sort orders that will be used for ordering your results. Up to 3 sort fields can be specified. The text similarity score is exposed as a special `_text_match` field that you can use in the list of sorting fields. If no `sort_by` parameter is specified, results are sorted by `_text_match:desc,default_sorting_field:desc` type: string + description: A list of numerical fields and their corresponding sort orders that will be used for ordering your results. Up to 3 sort fields can be specified. The text similarity score is exposed as a special `_text_match` field that you can use in the list of sorting fields. If no `sort_by` parameter is specified, results are sorted by `_text_match:desc,default_sorting_field:desc` - name: facet_by in: query schema: - description: A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. type: string + description: A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. - name: max_facet_values in: query schema: - description: Maximum number of facet values to be returned. type: integer + description: Maximum number of facet values to be returned. - name: facet_query in: query schema: - description: Facet values that are returned can now be filtered via this parameter. The matching facet text is also highlighted. For example, when faceting by `category`, you can set `facet_query=category:shoe` to return only facet values that contain the prefix "shoe". type: string + description: Facet values that are returned can now be filtered via this parameter. The matching facet text is also highlighted. For example, when faceting by `category`, you can set `facet_query=category:shoe` to return only facet values that contain the prefix "shoe". - name: num_typos in: query schema: + type: string description: | The number of typographical errors (1 or 2) that would be tolerated. Default: 2 - type: string - name: page in: query schema: - description: Results from this specific page number would be fetched. type: integer + description: Results from this specific page number would be fetched. - name: per_page in: query schema: - description: 'Number of results to fetch per page. Default: 10' type: integer + description: 'Number of results to fetch per page. Default: 10' - name: limit in: query schema: + type: integer description: | Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10. - type: integer - name: offset in: query schema: - description: Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. type: integer + description: Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. - name: group_by in: query schema: - description: You can aggregate search results into groups or buckets by specify one or more `group_by` fields. Separate multiple fields with a comma. To group on a particular field, it must be a faceted field. type: string + description: You can aggregate search results into groups or buckets by specify one or more `group_by` fields. Separate multiple fields with a comma. To group on a particular field, it must be a faceted field. - name: group_limit in: query schema: + type: integer description: | Maximum number of hits to be returned for every group. If the `group_limit` is set as `K` then only the top K hits in each group are returned in the response. Default: 3 - type: integer - name: group_missing_values in: query schema: + type: boolean description: | Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true - type: boolean - name: include_fields in: query schema: - description: List of fields from the document to include in the search result type: string + description: List of fields from the document to include in the search result - name: exclude_fields in: query schema: - description: List of fields from the document to exclude in the search result type: string + description: List of fields from the document to exclude in the search result - name: highlight_full_fields in: query schema: - description: List of fields which should be highlighted fully without snippeting type: string + description: List of fields which should be highlighted fully without snippeting - name: highlight_affix_num_tokens in: query schema: + type: integer description: | The number of tokens that should surround the highlighted text on each side. Default: 4 - type: integer - name: highlight_start_tag in: query schema: + type: string description: | The start tag used for the highlighted snippets. Default: `` - type: string - name: highlight_end_tag in: query schema: + type: string description: | The end tag used for the highlighted snippets. Default: `` - type: string - name: snippet_threshold in: query schema: + type: integer description: | Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 - type: integer - name: drop_tokens_threshold in: query schema: + type: integer description: | If the number of results found for a specific query is less than this number, Typesense will attempt to drop the tokens in the query until enough results are found. Tokens that have the least individual hits are dropped first. Set to 0 to disable. Default: 10 - type: integer - name: drop_tokens_mode in: query schema: @@ -2178,216 +2178,216 @@ paths: - name: typo_tokens_threshold in: query schema: + type: integer description: | If the number of results found for a specific query is less than this number, Typesense will attempt to look for tokens with more typos until enough results are found. Default: 100 - type: integer - name: enable_typos_for_alpha_numerical_tokens in: query schema: + type: boolean description: | Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. - type: boolean - name: filter_curated_hits in: query schema: + type: boolean description: | Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false - type: boolean - name: enable_synonyms in: query schema: + type: boolean description: | If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true - type: boolean - name: enable_analytics in: query schema: - description: | - Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). type: boolean default: true + description: | + Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). - name: synonym_prefix in: query schema: + type: boolean description: | Allow synonym resolution on word prefixes in the query. Default: false - type: boolean - name: synonym_num_typos in: query schema: + type: integer description: | Allow synonym resolution on typo-corrected words in the query. Default: 0 - type: integer - name: pinned_hits in: query schema: + type: string description: | A list of records to unconditionally include in the search results at specific positions. An example use case would be to feature or promote certain items on the top of search results. A list of `record_id:hit_position`. Eg: to include a record with ID 123 at Position 1 and another record with ID 456 at Position 5, you'd specify `123:1,456:5`. You could also use the Overrides feature to override search results based on rules. Overrides are applied first, followed by `pinned_hits` and finally `hidden_hits`. - type: string - name: hidden_hits in: query schema: + type: string description: | A list of records to unconditionally hide from search results. A list of `record_id`s to hide. Eg: to hide records with IDs 123 and 456, you'd specify `123,456`. You could also use the Overrides feature to override search results based on rules. Overrides are applied first, followed by `pinned_hits` and finally `hidden_hits`. - type: string - name: override_tags in: query schema: - description: Comma separated list of tags to trigger the curations rules that match the tags. type: string + description: Comma separated list of tags to trigger the curations rules that match the tags. - name: highlight_fields in: query schema: + type: string description: | A list of custom fields that must be highlighted even if you don't query for them - type: string - name: pre_segmented_query in: query schema: + type: boolean + default: false description: | You can index content from any logographic language into Typesense if you are able to segment / split the text into space-separated words yourself before indexing and querying. Set this parameter to true to do the same - type: boolean - default: false - name: preset in: query schema: + type: string description: | Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. - type: string - name: enable_overrides in: query schema: - description: | - If you have some overrides defined but want to disable all of them during query time, you can do that by setting this parameter to false type: boolean default: false + description: | + If you have some overrides defined but want to disable all of them during query time, you can do that by setting this parameter to false - name: prioritize_exact_match in: query schema: - description: | - Set this parameter to true to ensure that an exact match is ranked above the others type: boolean default: true + description: | + Set this parameter to true to ensure that an exact match is ranked above the others - name: prioritize_token_position in: query schema: - description: | - Make Typesense prioritize documents where the query words appear earlier in the text. type: boolean default: false + description: | + Make Typesense prioritize documents where the query words appear earlier in the text. - name: prioritize_num_matching_fields in: query schema: - description: | - Make Typesense prioritize documents where the query words appear in more number of fields. type: boolean default: true + description: | + Make Typesense prioritize documents where the query words appear in more number of fields. - name: enable_typos_for_numerical_tokens in: query schema: - description: | - Make Typesense disable typos for numerical tokens. type: boolean default: true + description: | + Make Typesense disable typos for numerical tokens. - name: exhaustive_search in: query schema: + type: boolean description: | Setting this to true will make Typesense consider all prefixes and typo corrections of the words in the query without stopping early when enough results are found (drop_tokens_threshold and typo_tokens_threshold configurations are ignored). - type: boolean - name: search_cutoff_ms in: query schema: + type: integer description: | Typesense will attempt to return results early if the cutoff time has elapsed. This is not a strict guarantee and facet computation is not bound by this parameter. - type: integer - name: use_cache in: query schema: + type: boolean description: | Enable server side caching of search query results. By default, caching is disabled. - type: boolean - name: cache_ttl in: query schema: + type: integer description: | The duration (in seconds) that determines how long the search query is cached. This value can be set on a per-query basis. Default: 60. - type: integer - name: min_len_1typo in: query schema: + type: integer description: | Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos. - type: integer - name: min_len_2typo in: query schema: + type: integer description: | Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos. - type: integer - name: vector_query in: query schema: + type: string description: | Vector query expression for fetching documents "closest" to a given query/document vector. - type: string - name: remote_embedding_timeout_ms in: query schema: + type: integer description: | Timeout (in milliseconds) for fetching remote embeddings. - type: integer - name: remote_embedding_num_tries in: query schema: + type: integer description: | Number of times to retry fetching remote embeddings. - type: integer - name: facet_strategy in: query schema: + type: string description: | Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). - type: string - name: stopwords in: query schema: + type: string description: | Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query. - type: string - name: facet_return_parent in: query schema: + type: string description: | Comma separated string of nested facet fields whose parent object should be returned in facet response. - type: string - name: voice_query in: query schema: + type: string description: | The base64 encoded audio file in 16 khz 16-bit WAV format. - type: string - name: conversation in: query schema: + type: boolean description: | Enable conversational search. - type: boolean - name: conversation_model_id in: query schema: + type: string description: | The Id of Conversation Model to be used. - type: string - name: conversation_id in: query schema: + type: string description: | The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. - type: string requestBody: content: application/json: @@ -2415,8 +2415,8 @@ paths: description: Submit a single analytics event. The event must correspond to an existing analytics rule by name. operationId: createAnalyticsEvent requestBody: - description: The analytics event to be created required: true + description: The analytics event to be created content: application/json: schema: @@ -2442,20 +2442,20 @@ paths: operationId: getAnalyticsEvents parameters: - name: user_id - in: query required: true + in: query schema: type: string - name: name + required: true in: query description: Analytics rule name - required: true schema: type: string - name: n + required: true in: query description: Number of events to return (max 1000) - required: true schema: type: integer responses: @@ -2507,8 +2507,8 @@ paths: description: Create one or more analytics rules. You can send a single rule object or an array of rule objects. operationId: createAnalyticsRule requestBody: - description: The analytics rule(s) to be created required: true + description: The analytics rule(s) to be created content: application/json: schema: @@ -2548,9 +2548,9 @@ paths: operationId: retrieveAnalyticsRules parameters: - name: rule_tag + required: false in: query description: Filter rules by rule_tag - required: false schema: type: string responses: @@ -2571,14 +2571,14 @@ paths: operationId: upsertAnalyticsRule parameters: - name: ruleName + required: true in: path description: The name of the analytics rule to upsert - required: true schema: type: string requestBody: - description: The Analytics rule to be upserted required: true + description: The Analytics rule to be upserted content: application/json: schema: @@ -2604,9 +2604,9 @@ paths: operationId: retrieveAnalyticsRule parameters: - name: ruleName + required: true in: path description: The name of the analytics rule to retrieve - required: true schema: type: string responses: @@ -2630,9 +2630,9 @@ paths: operationId: deleteAnalyticsRule parameters: - name: ruleName + required: true in: path description: The name of the analytics rule to delete - required: true schema: type: string responses: @@ -2699,15 +2699,15 @@ paths: operationId: upsertStopwordsSet parameters: - name: setId + required: true in: path description: The ID of the stopwords set to upsert. - required: true schema: type: string example: countries requestBody: - description: The stopwords set to upsert. required: true + description: The stopwords set to upsert. content: application/json: schema: @@ -2733,9 +2733,9 @@ paths: operationId: retrieveStopwordsSet parameters: - name: setId + required: true in: path description: The ID of the stopwords set to retrieve. - required: true schema: type: string example: countries @@ -2760,9 +2760,9 @@ paths: operationId: deleteStopwordsSet parameters: - name: setId + required: true in: path description: The ID of the stopwords set to delete. - required: true schema: type: string example: countries @@ -2809,9 +2809,9 @@ paths: operationId: retrievePreset parameters: - name: presetId + required: true in: path description: The ID of the preset to retrieve. - required: true schema: type: string example: listing_view @@ -2836,15 +2836,15 @@ paths: operationId: upsertPreset parameters: - name: presetId + required: true in: path description: The name of the preset set to upsert. - required: true schema: type: string example: listing_view requestBody: - description: The stopwords set to upsert. required: true + description: The stopwords set to upsert. content: application/json: schema: @@ -2870,9 +2870,9 @@ paths: operationId: deletePreset parameters: - name: presetId + required: true in: path description: The ID of the preset to delete. - required: true schema: type: string example: listing_view @@ -2920,9 +2920,9 @@ paths: operationId: getStemmingDictionary parameters: - name: dictionaryId + required: true in: path description: The ID of the dictionary to retrieve - required: true schema: type: string example: irregular-plurals @@ -2948,15 +2948,15 @@ paths: operationId: importStemmingDictionary parameters: - name: id + required: true in: query description: The ID to assign to the dictionary - required: true schema: type: string example: irregular-plurals requestBody: - description: The JSONL file containing word mappings required: true + description: The JSONL file containing word mappings content: application/json: schema: @@ -3004,8 +3004,8 @@ paths: description: Create a new NL search model. operationId: createNLSearchModel requestBody: - description: The NL search model to be created required: true + description: The NL search model to be created content: application/json: schema: @@ -3032,9 +3032,9 @@ paths: operationId: retrieveNLSearchModel parameters: - name: modelId + required: true in: path description: The ID of the NL search model to retrieve - required: true schema: type: string responses: @@ -3058,14 +3058,14 @@ paths: operationId: updateNLSearchModel parameters: - name: modelId + required: true in: path description: The ID of the NL search model to update - required: true schema: type: string requestBody: - description: The NL search model fields to update required: true + description: The NL search model fields to update content: application/json: schema: @@ -3097,9 +3097,9 @@ paths: operationId: deleteNLSearchModel parameters: - name: modelId + required: true in: path description: The ID of the NL search model to delete - required: true schema: type: string responses: @@ -3124,12 +3124,12 @@ components: - fields properties: name: - description: Name of the collection type: string + description: Name of the collection example: companies fields: - description: A list of fields for querying, filtering and faceting type: array + description: A list of fields for querying, filtering and faceting example: - name: num_employees type: int32 @@ -3143,45 +3143,45 @@ components: items: $ref: '#/components/schemas/Field' default_sorting_field: - description: The name of an int32 / float field that determines the order in which the search results are ranked when a sort_by clause is not provided during searching. This field must indicate some kind of popularity. type: string - example: num_employees default: '' + description: The name of an int32 / float field that determines the order in which the search results are ranked when a sort_by clause is not provided during searching. This field must indicate some kind of popularity. + example: num_employees token_separators: + type: array + default: [] description: | List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters. - type: array items: type: string minLength: 1 maxLength: 1 - default: [] synonym_sets: - description: List of synonym set names to associate with this collection type: array + description: List of synonym set names to associate with this collection items: type: string example: synonym_set_1 enable_nested_fields: - description: Enables experimental support at a collection level for nested object or object array fields. This field is only available if the Typesense server is version `0.24.0.rcn34` or later. type: boolean - example: true default: false + description: Enables experimental support at a collection level for nested object or object array fields. This field is only available if the Typesense server is version `0.24.0.rcn34` or later. + example: true symbols_to_index: + type: array + default: [] description: | List of symbols or special characters to be indexed. - type: array items: type: string minLength: 1 maxLength: 1 - default: [] voice_query_model: $ref: '#/components/schemas/VoiceQueryModelCollectionConfig' metadata: + type: object description: | Optional details about the collection, e.g., when it was created, who created it etc. - type: object x-rust-is-used-as-input: true x-rust-builder: true x-rust-is-used-as-input: true @@ -3191,8 +3191,8 @@ components: - fields properties: fields: - description: A list of fields for querying, filtering and faceting type: array + description: A list of fields for querying, filtering and faceting example: - name: company_name type: string @@ -3206,15 +3206,15 @@ components: items: $ref: '#/components/schemas/Field' synonym_sets: - description: List of synonym set names to associate with this collection type: array + description: List of synonym set names to associate with this collection items: type: string example: synonym_set_1 metadata: + type: object description: | Optional details about the collection, e.g., when it was created, who created it etc. - type: object x-rust-is-used-as-input: true x-rust-is-used-as-input: true CollectionResponse: @@ -3255,8 +3255,8 @@ components: example: false index: type: boolean - example: true default: true + example: true locale: type: string example: el @@ -3265,12 +3265,12 @@ components: example: true infix: type: boolean - example: true default: false + example: true reference: + type: string description: | Name of a field in another collection that should be linked to this collection so that it can be joined during query. - type: string num_dim: type: integer example: 256 @@ -3278,43 +3278,43 @@ components: type: boolean example: true store: + type: boolean description: | When set to false, the field value will not be stored on disk. Default: true. - type: boolean vec_dist: + type: string description: | The distance metric to be used for vector search. Default: `cosine`. You can also use `ip` for inner product. - type: string range_index: + type: boolean description: | Enables an index optimized for range filtering on numerical fields (e.g. rating:>3.5). Default: false. - type: boolean stem: + type: boolean description: | Values are stemmed before indexing in-memory. Default: false. - type: boolean stem_dictionary: - description: Name of the stemming dictionary to use for this field type: string + description: Name of the stemming dictionary to use for this field example: irregular-plurals token_separators: + type: array + default: [] description: | List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters. - type: array items: type: string minLength: 1 maxLength: 1 - default: [] symbols_to_index: + type: array + default: [] description: | List of symbols or special characters to be indexed. - type: array items: type: string minLength: 1 maxLength: 1 - default: [] embed: type: object required: @@ -3352,9 +3352,9 @@ components: type: string x-rust-builder: true VoiceQueryModelCollectionConfig: + type: object description: | Configuration for the voice query model - type: object properties: model_name: type: string @@ -3365,8 +3365,8 @@ components: - collection_name properties: collection_name: - description: Name of the collection you wish to map the alias to type: string + description: Name of the collection you wish to map the alias to x-rust-is-used-as-input: true CollectionAlias: type: object @@ -3375,12 +3375,12 @@ components: - name properties: name: - description: Name of the collection alias type: string + description: Name of the collection alias readOnly: true collection_name: - description: Name of the collection the alias mapped to type: string + description: Name of the collection the alias mapped to CollectionAliasesResponse: type: object required: @@ -3399,30 +3399,30 @@ components: items: $ref: '#/components/schemas/FacetCounts' found: - description: The number of documents found type: integer + description: The number of documents found found_docs: type: integer search_time_ms: - description: The number of milliseconds the search took type: integer + description: The number of milliseconds the search took out_of: - description: The total number of documents in the collection type: integer + description: The total number of documents in the collection search_cutoff: - description: Whether the search was cut off type: boolean + description: Whether the search was cut off page: - description: The search result page number type: integer + description: The search result page number grouped_hits: type: array items: $ref: '#/components/schemas/SearchGroupedHit' x-rust-type: Option>> hits: - description: The documents that matched the search query type: array + description: The documents that matched the search query items: $ref: '#/components/schemas/SearchResultHit' x-rust-type: Option>> @@ -3431,13 +3431,13 @@ components: conversation: $ref: '#/components/schemas/SearchResultConversation' union_request_params: - description: Returned only for union query response. type: array + description: Returned only for union query response. items: $ref: '#/components/schemas/SearchRequestParams' metadata: - description: Custom JSON object that can be returned in the search response type: object + description: Custom JSON object that can be returned in the search response additionalProperties: true x-rust-generic-parameter: D SearchRequestParams: @@ -3488,8 +3488,8 @@ components: type: array items: {} hits: - description: The documents that matched the search query type: array + description: The documents that matched the search query items: $ref: '#/components/schemas/SearchResultHit' x-rust-type: Vec> @@ -3509,17 +3509,17 @@ components: text_match: 1234556 properties: highlights: - description: (Deprecated) Contains highlighted portions of the search fields type: array + description: (Deprecated) Contains highlighted portions of the search fields items: $ref: '#/components/schemas/SearchHighlight' highlight: - description: Highlighted version of the matching document type: object + description: Highlighted version of the matching document additionalProperties: true document: - description: Can be any key-value pair type: object + description: Can be any key-value pair additionalProperties: type: object x-rust-type: Option @@ -3546,25 +3546,25 @@ components: typo_prefix_score: type: integer geo_distance_meters: - description: Can be any key-value pair type: object + description: Can be any key-value pair additionalProperties: type: integer vector_distance: - description: Distance between the query vector and matching document's vector value type: number + description: Distance between the query vector and matching document's vector value format: float hybrid_search_info: - description: Information about hybrid search scoring type: object + description: Information about hybrid search scoring properties: rank_fusion_score: - description: Combined score from rank fusion of text and vector search type: number + description: Combined score from rank fusion of text and vector search format: float search_index: - description: Returned only for union query response. Indicates the index of the query which this document matched to. type: integer + description: Returned only for union query response. Indicates the index of the query which this document matched to. x-rust-generic-parameter: D SearchHighlight: type: object @@ -3573,32 +3573,32 @@ components: type: string example: company_name snippet: - description: Present only for (non-array) string fields type: string + description: Present only for (non-array) string fields example: Stark Industries snippets: - description: Present only for (array) string[] fields type: array + description: Present only for (array) string[] fields example: - Stark Industries - Stark Corp items: type: string value: - description: Full field value with highlighting, present only for (non-array) string fields type: string + description: Full field value with highlighting, present only for (non-array) string fields example: Stark Industries is a major supplier of space equipment. values: - description: Full field value with highlighting, present only for (array) string[] fields type: array + description: Full field value with highlighting, present only for (array) string[] fields example: - Stark Industries - Stark Corp items: type: string indices: - description: The indices property will be present only for string[] fields and will contain the corresponding indices of the snippets in the search field type: array + description: The indices property will be present only for string[] fields and will contain the corresponding indices of the snippets in the search field example: 1 items: type: integer @@ -3613,19 +3613,19 @@ components: - synonyms properties: root: - description: For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. type: string + description: For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. synonyms: - description: Array of words that should be considered as synonyms. type: array + description: Array of words that should be considered as synonyms. items: type: string locale: - description: Locale for the synonym, leave blank to use the standard tokenizer. type: string + description: Locale for the synonym, leave blank to use the standard tokenizer. symbols_to_index: - description: By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is. type: array + description: By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is. items: type: string SearchSynonym: @@ -3644,8 +3644,8 @@ components: - id properties: id: - description: The id of the synonym that was deleted type: string + description: The id of the synonym that was deleted SearchSynonymsResponse: type: object required: @@ -3667,14 +3667,14 @@ components: type: object properties: collection: - description: Name of the collection being modified type: string + description: Name of the collection being modified validated_docs: - description: Number of documents that have been validated type: integer + description: Number of documents that have been validated altered_docs: - description: Number of documents that have been altered type: integer + description: Number of documents that have been altered SuccessStatus: type: object required: @@ -3730,8 +3730,8 @@ components: - id properties: id: - description: The id of the API key that was deleted type: integer + description: The id of the API key that was deleted format: int64 ApiKeysResponse: type: object @@ -3773,526 +3773,526 @@ components: type: object properties: q: - description: The query text to search for in the collection. Use * as the search string to return all documents. This is typically useful when used in conjunction with filter_by. type: string + description: The query text to search for in the collection. Use * as the search string to return all documents. This is typically useful when used in conjunction with filter_by. query_by: - description: A list of `string` fields that should be queried against. Multiple fields are separated with a comma. type: string + description: A list of `string` fields that should be queried against. Multiple fields are separated with a comma. nl_query: - description: Whether to use natural language processing to parse the query. type: boolean + description: Whether to use natural language processing to parse the query. nl_model_id: - description: The ID of the natural language model to use. type: string + description: The ID of the natural language model to use. query_by_weights: - description: The relative weight to give each `query_by` field when ranking results. This can be used to boost fields in priority, when looking for matches. Multiple fields are separated with a comma. type: string + description: The relative weight to give each `query_by` field when ranking results. This can be used to boost fields in priority, when looking for matches. Multiple fields are separated with a comma. text_match_type: - description: In a multi-field matching context, this parameter determines how the representative text match score of a record is calculated. Possible values are max_score (default) or max_weight. type: string + description: In a multi-field matching context, this parameter determines how the representative text match score of a record is calculated. Possible values are max_score (default) or max_weight. prefix: - description: Boolean field to indicate that the last word in the query should be treated as a prefix, and not as a whole word. This is used for building autocomplete and instant search interfaces. Defaults to true. type: string + description: Boolean field to indicate that the last word in the query should be treated as a prefix, and not as a whole word. This is used for building autocomplete and instant search interfaces. Defaults to true. infix: - description: If infix index is enabled for this field, infix searching can be done on a per-field basis by sending a comma separated string parameter called infix to the search query. This parameter can have 3 values; `off` infix search is disabled, which is default `always` infix search is performed along with regular search `fallback` infix search is performed if regular search does not produce results type: string + description: If infix index is enabled for this field, infix searching can be done on a per-field basis by sending a comma separated string parameter called infix to the search query. This parameter can have 3 values; `off` infix search is disabled, which is default `always` infix search is performed along with regular search `fallback` infix search is performed if regular search does not produce results max_extra_prefix: - description: There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query "K2100" has 2 extra symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. type: integer - max_extra_suffix: description: There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query "K2100" has 2 extra symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. + max_extra_suffix: type: integer + description: There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query "K2100" has 2 extra symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. filter_by: - description: Filter conditions for refining your open api validator search results. Separate multiple conditions with &&. type: string + description: Filter conditions for refining your open api validator search results. Separate multiple conditions with &&. example: 'num_employees:>100 && country: [USA, UK]' max_filter_by_candidates: - description: Controls the number of similar words that Typesense considers during fuzzy search on filter_by values. Useful for controlling prefix matches like company_name:Acm*. type: integer + description: Controls the number of similar words that Typesense considers during fuzzy search on filter_by values. Useful for controlling prefix matches like company_name:Acm*. sort_by: - description: A list of numerical fields and their corresponding sort orders that will be used for ordering your results. Up to 3 sort fields can be specified. The text similarity score is exposed as a special `_text_match` field that you can use in the list of sorting fields. If no `sort_by` parameter is specified, results are sorted by `_text_match:desc,default_sorting_field:desc` type: string + description: A list of numerical fields and their corresponding sort orders that will be used for ordering your results. Up to 3 sort fields can be specified. The text similarity score is exposed as a special `_text_match` field that you can use in the list of sorting fields. If no `sort_by` parameter is specified, results are sorted by `_text_match:desc,default_sorting_field:desc` example: num_employees:desc facet_by: - description: A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. type: string + description: A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. max_facet_values: - description: Maximum number of facet values to be returned. type: integer + description: Maximum number of facet values to be returned. facet_query: - description: Facet values that are returned can now be filtered via this parameter. The matching facet text is also highlighted. For example, when faceting by `category`, you can set `facet_query=category:shoe` to return only facet values that contain the prefix "shoe". type: string + description: Facet values that are returned can now be filtered via this parameter. The matching facet text is also highlighted. For example, when faceting by `category`, you can set `facet_query=category:shoe` to return only facet values that contain the prefix "shoe". num_typos: + type: string description: | The number of typographical errors (1 or 2) that would be tolerated. Default: 2 - type: string page: - description: Results from this specific page number would be fetched. type: integer + description: Results from this specific page number would be fetched. per_page: - description: 'Number of results to fetch per page. Default: 10' type: integer + description: 'Number of results to fetch per page. Default: 10' limit: + type: integer description: | Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10. - type: integer offset: - description: Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. type: integer + description: Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. group_by: - description: You can aggregate search results into groups or buckets by specify one or more `group_by` fields. Separate multiple fields with a comma. To group on a particular field, it must be a faceted field. type: string + description: You can aggregate search results into groups or buckets by specify one or more `group_by` fields. Separate multiple fields with a comma. To group on a particular field, it must be a faceted field. group_limit: + type: integer description: | Maximum number of hits to be returned for every group. If the `group_limit` is set as `K` then only the top K hits in each group are returned in the response. Default: 3 - type: integer group_missing_values: + type: boolean description: | Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true - type: boolean include_fields: - description: List of fields from the document to include in the search result type: string + description: List of fields from the document to include in the search result exclude_fields: - description: List of fields from the document to exclude in the search result type: string + description: List of fields from the document to exclude in the search result highlight_full_fields: - description: List of fields which should be highlighted fully without snippeting type: string + description: List of fields which should be highlighted fully without snippeting highlight_affix_num_tokens: + type: integer description: | The number of tokens that should surround the highlighted text on each side. Default: 4 - type: integer highlight_start_tag: + type: string description: | The start tag used for the highlighted snippets. Default: `` - type: string highlight_end_tag: + type: string description: | The end tag used for the highlighted snippets. Default: `` - type: string enable_highlight_v1: + type: boolean + default: true description: | Flag for enabling/disabling the deprecated, old highlight structure in the response. Default: true + enable_analytics: type: boolean default: true - enable_analytics: description: | Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). - type: boolean - default: true snippet_threshold: + type: integer description: | Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 - type: integer synonym_sets: - description: List of synonym set names to associate with this search query type: string + description: List of synonym set names to associate with this search query example: synonym_set_1,synonym_set_2 drop_tokens_threshold: + type: integer description: | If the number of results found for a specific query is less than this number, Typesense will attempt to drop the tokens in the query until enough results are found. Tokens that have the least individual hits are dropped first. Set to 0 to disable. Default: 10 - type: integer drop_tokens_mode: $ref: '#/components/schemas/DropTokensMode' typo_tokens_threshold: + type: integer description: | If the number of results found for a specific query is less than this number, Typesense will attempt to look for tokens with more typos until enough results are found. Default: 100 - type: integer enable_typos_for_alpha_numerical_tokens: + type: boolean description: | Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. - type: boolean filter_curated_hits: + type: boolean description: | Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false - type: boolean enable_synonyms: + type: boolean description: | If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true - type: boolean synonym_prefix: + type: boolean description: | Allow synonym resolution on word prefixes in the query. Default: false - type: boolean synonym_num_typos: + type: integer description: | Allow synonym resolution on typo-corrected words in the query. Default: 0 - type: integer pinned_hits: + type: string description: | A list of records to unconditionally include in the search results at specific positions. An example use case would be to feature or promote certain items on the top of search results. A list of `record_id:hit_position`. Eg: to include a record with ID 123 at Position 1 and another record with ID 456 at Position 5, you'd specify `123:1,456:5`. You could also use the Overrides feature to override search results based on rules. Overrides are applied first, followed by `pinned_hits` and finally `hidden_hits`. - type: string hidden_hits: + type: string description: | A list of records to unconditionally hide from search results. A list of `record_id`s to hide. Eg: to hide records with IDs 123 and 456, you'd specify `123,456`. You could also use the Overrides feature to override search results based on rules. Overrides are applied first, followed by `pinned_hits` and finally `hidden_hits`. - type: string override_tags: - description: Comma separated list of tags to trigger the curations rules that match the tags. type: string + description: Comma separated list of tags to trigger the curations rules that match the tags. highlight_fields: + type: string description: | A list of custom fields that must be highlighted even if you don't query for them - type: string split_join_tokens: + type: string description: | Treat space as typo: search for q=basket ball if q=basketball is not found or vice-versa. Splitting/joining of tokens will only be attempted if the original query produces no results. To always trigger this behavior, set value to `always``. To disable, set value to `off`. Default is `fallback`. - type: string pre_segmented_query: + type: boolean description: | You can index content from any logographic language into Typesense if you are able to segment / split the text into space-separated words yourself before indexing and querying. Set this parameter to true to do the same - type: boolean preset: + type: string description: | Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. - type: string enable_overrides: - description: | - If you have some overrides defined but want to disable all of them during query time, you can do that by setting this parameter to false type: boolean default: false - prioritize_exact_match: description: | - Set this parameter to true to ensure that an exact match is ranked above the others + If you have some overrides defined but want to disable all of them during query time, you can do that by setting this parameter to false + prioritize_exact_match: type: boolean default: true + description: | + Set this parameter to true to ensure that an exact match is ranked above the others max_candidates: + type: integer description: | Control the number of words that Typesense considers for typo and prefix searching. - type: integer prioritize_token_position: - description: | - Make Typesense prioritize documents where the query words appear earlier in the text. type: boolean default: false + description: | + Make Typesense prioritize documents where the query words appear earlier in the text. prioritize_num_matching_fields: + type: boolean + default: true description: | Make Typesense prioritize documents where the query words appear in more number of fields. + enable_typos_for_numerical_tokens: type: boolean default: true - enable_typos_for_numerical_tokens: description: | Make Typesense disable typos for numerical tokens. - type: boolean - default: true exhaustive_search: + type: boolean description: | Setting this to true will make Typesense consider all prefixes and typo corrections of the words in the query without stopping early when enough results are found (drop_tokens_threshold and typo_tokens_threshold configurations are ignored). - type: boolean search_cutoff_ms: + type: integer description: | Typesense will attempt to return results early if the cutoff time has elapsed. This is not a strict guarantee and facet computation is not bound by this parameter. - type: integer use_cache: + type: boolean description: | Enable server side caching of search query results. By default, caching is disabled. - type: boolean cache_ttl: + type: integer description: | The duration (in seconds) that determines how long the search query is cached. This value can be set on a per-query basis. Default: 60. - type: integer min_len_1typo: + type: integer description: | Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos. - type: integer min_len_2typo: + type: integer description: | Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos. - type: integer vector_query: + type: string description: | Vector query expression for fetching documents "closest" to a given query/document vector. - type: string remote_embedding_timeout_ms: + type: integer description: | Timeout (in milliseconds) for fetching remote embeddings. - type: integer remote_embedding_num_tries: + type: integer description: | Number of times to retry fetching remote embeddings. - type: integer facet_strategy: + type: string description: | Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). - type: string stopwords: + type: string description: | Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query. - type: string facet_return_parent: + type: string description: | Comma separated string of nested facet fields whose parent object should be returned in facet response. - type: string voice_query: + type: string description: | The base64 encoded audio file in 16 khz 16-bit WAV format. - type: string conversation: + type: boolean description: | Enable conversational search. - type: boolean conversation_model_id: + type: string description: | The Id of Conversation Model to be used. - type: string conversation_id: + type: string description: | The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. - type: string x-rust-builder: true x-rust-is-used-as-input: true MultiSearchParameters: + type: object description: | Parameters for the multi search API. - type: object properties: q: - description: The query text to search for in the collection. Use * as the search string to return all documents. This is typically useful when used in conjunction with filter_by. type: string + description: The query text to search for in the collection. Use * as the search string to return all documents. This is typically useful when used in conjunction with filter_by. query_by: - description: A list of `string` fields that should be queried against. Multiple fields are separated with a comma. type: string + description: A list of `string` fields that should be queried against. Multiple fields are separated with a comma. query_by_weights: - description: The relative weight to give each `query_by` field when ranking results. This can be used to boost fields in priority, when looking for matches. Multiple fields are separated with a comma. type: string + description: The relative weight to give each `query_by` field when ranking results. This can be used to boost fields in priority, when looking for matches. Multiple fields are separated with a comma. text_match_type: - description: In a multi-field matching context, this parameter determines how the representative text match score of a record is calculated. Possible values are max_score (default) or max_weight. type: string + description: In a multi-field matching context, this parameter determines how the representative text match score of a record is calculated. Possible values are max_score (default) or max_weight. prefix: - description: Boolean field to indicate that the last word in the query should be treated as a prefix, and not as a whole word. This is used for building autocomplete and instant search interfaces. Defaults to true. type: string + description: Boolean field to indicate that the last word in the query should be treated as a prefix, and not as a whole word. This is used for building autocomplete and instant search interfaces. Defaults to true. infix: - description: If infix index is enabled for this field, infix searching can be done on a per-field basis by sending a comma separated string parameter called infix to the search query. This parameter can have 3 values; `off` infix search is disabled, which is default `always` infix search is performed along with regular search `fallback` infix search is performed if regular search does not produce results type: string + description: If infix index is enabled for this field, infix searching can be done on a per-field basis by sending a comma separated string parameter called infix to the search query. This parameter can have 3 values; `off` infix search is disabled, which is default `always` infix search is performed along with regular search `fallback` infix search is performed if regular search does not produce results max_extra_prefix: - description: There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query "K2100" has 2 extra symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. type: integer - max_extra_suffix: description: There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query "K2100" has 2 extra symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. + max_extra_suffix: type: integer + description: There are also 2 parameters that allow you to control the extent of infix searching max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before or after the query that can be present in the token. For example query "K2100" has 2 extra symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. filter_by: - description: Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. type: string + description: Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. example: 'num_employees:>100 && country: [USA, UK]' sort_by: - description: A list of numerical fields and their corresponding sort orders that will be used for ordering your results. Up to 3 sort fields can be specified. The text similarity score is exposed as a special `_text_match` field that you can use in the list of sorting fields. If no `sort_by` parameter is specified, results are sorted by `_text_match:desc,default_sorting_field:desc` type: string + description: A list of numerical fields and their corresponding sort orders that will be used for ordering your results. Up to 3 sort fields can be specified. The text similarity score is exposed as a special `_text_match` field that you can use in the list of sorting fields. If no `sort_by` parameter is specified, results are sorted by `_text_match:desc,default_sorting_field:desc` facet_by: - description: A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. type: string + description: A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. max_facet_values: - description: Maximum number of facet values to be returned. type: integer + description: Maximum number of facet values to be returned. facet_query: - description: Facet values that are returned can now be filtered via this parameter. The matching facet text is also highlighted. For example, when faceting by `category`, you can set `facet_query=category:shoe` to return only facet values that contain the prefix "shoe". type: string + description: Facet values that are returned can now be filtered via this parameter. The matching facet text is also highlighted. For example, when faceting by `category`, you can set `facet_query=category:shoe` to return only facet values that contain the prefix "shoe". num_typos: + type: string description: | The number of typographical errors (1 or 2) that would be tolerated. Default: 2 - type: string page: - description: Results from this specific page number would be fetched. type: integer + description: Results from this specific page number would be fetched. per_page: - description: 'Number of results to fetch per page. Default: 10' type: integer + description: 'Number of results to fetch per page. Default: 10' limit: + type: integer description: | Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10. - type: integer offset: - description: Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. type: integer + description: Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. group_by: - description: You can aggregate search results into groups or buckets by specify one or more `group_by` fields. Separate multiple fields with a comma. To group on a particular field, it must be a faceted field. type: string + description: You can aggregate search results into groups or buckets by specify one or more `group_by` fields. Separate multiple fields with a comma. To group on a particular field, it must be a faceted field. group_limit: + type: integer description: | Maximum number of hits to be returned for every group. If the `group_limit` is set as `K` then only the top K hits in each group are returned in the response. Default: 3 - type: integer group_missing_values: + type: boolean description: | Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true - type: boolean include_fields: - description: List of fields from the document to include in the search result type: string + description: List of fields from the document to include in the search result exclude_fields: - description: List of fields from the document to exclude in the search result type: string + description: List of fields from the document to exclude in the search result highlight_full_fields: - description: List of fields which should be highlighted fully without snippeting type: string + description: List of fields which should be highlighted fully without snippeting highlight_affix_num_tokens: + type: integer description: | The number of tokens that should surround the highlighted text on each side. Default: 4 - type: integer highlight_start_tag: + type: string description: | The start tag used for the highlighted snippets. Default: `` - type: string highlight_end_tag: + type: string description: | The end tag used for the highlighted snippets. Default: `` - type: string snippet_threshold: + type: integer description: | Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 - type: integer drop_tokens_threshold: + type: integer description: | If the number of results found for a specific query is less than this number, Typesense will attempt to drop the tokens in the query until enough results are found. Tokens that have the least individual hits are dropped first. Set to 0 to disable. Default: 10 - type: integer drop_tokens_mode: $ref: '#/components/schemas/DropTokensMode' typo_tokens_threshold: + type: integer description: | If the number of results found for a specific query is less than this number, Typesense will attempt to look for tokens with more typos until enough results are found. Default: 100 - type: integer enable_typos_for_alpha_numerical_tokens: + type: boolean description: | Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. - type: boolean filter_curated_hits: + type: boolean description: | Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false - type: boolean enable_synonyms: + type: boolean description: | If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true - type: boolean enable_analytics: - description: | - Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). type: boolean default: true + description: | + Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). synonym_prefix: + type: boolean description: | Allow synonym resolution on word prefixes in the query. Default: false - type: boolean synonym_num_typos: + type: integer description: | Allow synonym resolution on typo-corrected words in the query. Default: 0 - type: integer pinned_hits: + type: string description: | A list of records to unconditionally include in the search results at specific positions. An example use case would be to feature or promote certain items on the top of search results. A list of `record_id:hit_position`. Eg: to include a record with ID 123 at Position 1 and another record with ID 456 at Position 5, you'd specify `123:1,456:5`. You could also use the Overrides feature to override search results based on rules. Overrides are applied first, followed by `pinned_hits` and finally `hidden_hits`. - type: string hidden_hits: + type: string description: | A list of records to unconditionally hide from search results. A list of `record_id`s to hide. Eg: to hide records with IDs 123 and 456, you'd specify `123,456`. You could also use the Overrides feature to override search results based on rules. Overrides are applied first, followed by `pinned_hits` and finally `hidden_hits`. - type: string override_tags: - description: Comma separated list of tags to trigger the curations rules that match the tags. type: string + description: Comma separated list of tags to trigger the curations rules that match the tags. highlight_fields: + type: string description: | A list of custom fields that must be highlighted even if you don't query for them - type: string pre_segmented_query: + type: boolean + default: false description: | You can index content from any logographic language into Typesense if you are able to segment / split the text into space-separated words yourself before indexing and querying. Set this parameter to true to do the same - type: boolean - default: false preset: + type: string description: | Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. - type: string enable_overrides: - description: | - If you have some overrides defined but want to disable all of them during query time, you can do that by setting this parameter to false type: boolean default: false - prioritize_exact_match: description: | - Set this parameter to true to ensure that an exact match is ranked above the others + If you have some overrides defined but want to disable all of them during query time, you can do that by setting this parameter to false + prioritize_exact_match: type: boolean default: true - prioritize_token_position: description: | - Make Typesense prioritize documents where the query words appear earlier in the text. + Set this parameter to true to ensure that an exact match is ranked above the others + prioritize_token_position: type: boolean default: false + description: | + Make Typesense prioritize documents where the query words appear earlier in the text. prioritize_num_matching_fields: + type: boolean + default: true description: | Make Typesense prioritize documents where the query words appear in more number of fields. + enable_typos_for_numerical_tokens: type: boolean default: true - enable_typos_for_numerical_tokens: description: | Make Typesense disable typos for numerical tokens. - type: boolean - default: true exhaustive_search: + type: boolean description: | Setting this to true will make Typesense consider all prefixes and typo corrections of the words in the query without stopping early when enough results are found (drop_tokens_threshold and typo_tokens_threshold configurations are ignored). - type: boolean search_cutoff_ms: + type: integer description: | Typesense will attempt to return results early if the cutoff time has elapsed. This is not a strict guarantee and facet computation is not bound by this parameter. - type: integer use_cache: + type: boolean description: | Enable server side caching of search query results. By default, caching is disabled. - type: boolean cache_ttl: + type: integer description: | The duration (in seconds) that determines how long the search query is cached. This value can be set on a per-query basis. Default: 60. - type: integer min_len_1typo: + type: integer description: | Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos. - type: integer min_len_2typo: + type: integer description: | Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos. - type: integer vector_query: + type: string description: | Vector query expression for fetching documents "closest" to a given query/document vector. - type: string remote_embedding_timeout_ms: + type: integer description: | Timeout (in milliseconds) for fetching remote embeddings. - type: integer remote_embedding_num_tries: + type: integer description: | Number of times to retry fetching remote embeddings. - type: integer facet_strategy: + type: string description: | Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). - type: string stopwords: + type: string description: | Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query. - type: string facet_return_parent: + type: string description: | Comma separated string of nested facet fields whose parent object should be returned in facet response. - type: string voice_query: + type: string description: | The base64 encoded audio file in 16 khz 16-bit WAV format. - type: string conversation: + type: boolean description: | Enable conversational search. - type: boolean conversation_model_id: + type: string description: | The Id of Conversation Model to be used. - type: string conversation_id: + type: string description: | The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. - type: string x-rust-builder: true x-rust-is-used-as-input: true MultiSearchSearchesParameter: @@ -4301,9 +4301,9 @@ components: - searches properties: union: - description: When true, merges the search results from each search query into a single ordered set of hits. type: boolean default: false + description: When true, merges the search results from each search query into a single ordered set of hits. searches: type: array items: @@ -4378,14 +4378,14 @@ components: - data properties: name: - description: Name of the analytics rule this event corresponds to type: string + description: Name of the analytics rule this event corresponds to event_type: - description: Type of event (e.g., click, conversion, query, visit) type: string + description: Type of event (e.g., click, conversion, query, visit) data: - description: Event payload type: object + description: Event payload properties: user_id: type: string @@ -4475,8 +4475,8 @@ components: x-rust-is-used-as-input: true x-rust-is-used-as-input: true AnalyticsRuleUpdate: - description: Fields allowed to update on an analytics rule type: object + description: Fields allowed to update on an analytics rule properties: name: type: string @@ -4669,9 +4669,9 @@ components: - emplace x-rust-is-used-as-input: true DropTokensMode: + type: string description: | Dictates the direction in which the words in the query must be dropped when the original words in the query do not appear in any document. Values: right_to_left (default), left_to_right, both_sides:3 A note on both_sides:3 - for queries up to 3 tokens (words) in length, this mode will drop tokens from both sides and exhaustively rank all matching results. If query length is greater than 3 words, Typesense will just fallback to default behavior of right_to_left - type: string enum: - right_to_left - left_to_right @@ -4704,34 +4704,34 @@ components: type: object properties: id: - description: An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. type: string + description: An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. model_name: - description: Name of the LLM model offered by OpenAI, Cloudflare or vLLM type: string + description: Name of the LLM model offered by OpenAI, Cloudflare or vLLM api_key: - description: The LLM service's API Key type: string + description: The LLM service's API Key history_collection: - description: Typesense collection that stores the historical conversations type: string + description: Typesense collection that stores the historical conversations account_id: - description: LLM service's account ID (only applicable for Cloudflare) type: string + description: LLM service's account ID (only applicable for Cloudflare) system_prompt: - description: The system prompt that contains special instructions to the LLM type: string + description: The system prompt that contains special instructions to the LLM ttl: + type: integer description: | Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) - type: integer max_bytes: + type: integer description: | The maximum number of bytes to send to the LLM in every API call. Consult the LLM's documentation on the number of bytes supported in the context window. - type: integer vllm_url: - description: URL of vLLM service type: string + description: URL of vLLM service x-rust-is-used-as-input: true ConversationModelSchema: allOf: @@ -4750,12 +4750,12 @@ components: - words properties: id: - description: Unique identifier for the dictionary type: string + description: Unique identifier for the dictionary example: irregular-plurals words: - description: List of word mappings in the dictionary type: array + description: List of word mappings in the dictionary items: type: object required: @@ -4763,72 +4763,72 @@ components: - root properties: word: - description: The word form to be stemmed type: string + description: The word form to be stemmed example: people root: - description: The root form of the word type: string + description: The root form of the word example: person NLSearchModelBase: type: object properties: model_name: - description: Name of the NL model to use type: string + description: Name of the NL model to use api_key: - description: API key for the NL model service type: string + description: API key for the NL model service api_url: - description: Custom API URL for the NL model service type: string + description: Custom API URL for the NL model service max_bytes: - description: Maximum number of bytes to process type: integer + description: Maximum number of bytes to process temperature: - description: Temperature parameter for the NL model type: number + description: Temperature parameter for the NL model system_prompt: - description: System prompt for the NL model type: string + description: System prompt for the NL model top_p: - description: Top-p parameter for the NL model (Google-specific) type: number + description: Top-p parameter for the NL model (Google-specific) top_k: - description: Top-k parameter for the NL model (Google-specific) type: integer + description: Top-k parameter for the NL model (Google-specific) stop_sequences: - description: Stop sequences for the NL model (Google-specific) type: array + description: Stop sequences for the NL model (Google-specific) items: type: string api_version: - description: API version for the NL model service type: string + description: API version for the NL model service project_id: - description: Project ID for GCP Vertex AI type: string + description: Project ID for GCP Vertex AI access_token: - description: Access token for GCP Vertex AI type: string + description: Access token for GCP Vertex AI refresh_token: - description: Refresh token for GCP Vertex AI type: string + description: Refresh token for GCP Vertex AI client_id: - description: Client ID for GCP Vertex AI type: string + description: Client ID for GCP Vertex AI client_secret: - description: Client secret for GCP Vertex AI type: string + description: Client secret for GCP Vertex AI region: - description: Region for GCP Vertex AI type: string + description: Region for GCP Vertex AI max_output_tokens: - description: Maximum output tokens for GCP Vertex AI type: integer + description: Maximum output tokens for GCP Vertex AI account_id: - description: Account ID for Cloudflare-specific models type: string + description: Account ID for Cloudflare-specific models NLSearchModelCreateSchema: allOf: - $ref: '#/components/schemas/NLSearchModelBase' @@ -4857,8 +4857,8 @@ components: - id properties: id: - description: ID of the deleted NL search model type: string + description: ID of the deleted NL search model SynonymItemSchema: type: object required: @@ -4866,22 +4866,22 @@ components: - synonyms properties: id: - description: Unique identifier for the synonym item type: string + description: Unique identifier for the synonym item synonyms: - description: Array of words that should be considered as synonyms type: array + description: Array of words that should be considered as synonyms items: type: string root: - description: For 1-way synonyms, indicates the root word that words in the synonyms parameter map to type: string + description: For 1-way synonyms, indicates the root word that words in the synonyms parameter map to locale: - description: Locale for the synonym, leave blank to use the standard tokenizer type: string + description: Locale for the synonym, leave blank to use the standard tokenizer symbols_to_index: - description: By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is type: array + description: By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is items: type: string x-rust-is-used-as-input: true @@ -4891,8 +4891,8 @@ components: - items properties: items: - description: Array of synonym items type: array + description: Array of synonym items items: $ref: '#/components/schemas/SynonymItemSchema' x-rust-is-used-as-input: true @@ -4912,8 +4912,8 @@ components: - synonym_sets properties: synonym_sets: - description: Array of synonym sets type: array + description: Array of synonym sets items: $ref: '#/components/schemas/SynonymSetSchema' SynonymSetRetrieveSchema: @@ -4924,16 +4924,16 @@ components: - name properties: name: - description: Name of the deleted synonym set type: string + description: Name of the deleted synonym set SynonymItemDeleteSchema: type: object required: - id properties: id: - description: ID of the deleted synonym item type: string + description: ID of the deleted synonym item CurationItemCreateSchema: type: object required: @@ -4942,55 +4942,55 @@ components: rule: $ref: '#/components/schemas/CurationRule' includes: - description: List of document `id`s that should be included in the search results with their corresponding `position`s. type: array + description: List of document `id`s that should be included in the search results with their corresponding `position`s. items: $ref: '#/components/schemas/CurationInclude' excludes: - description: List of document `id`s that should be excluded from the search results. type: array + description: List of document `id`s that should be excluded from the search results. items: $ref: '#/components/schemas/CurationExclude' filter_by: + type: string description: | A filter by clause that is applied to any search query that matches the curation rule. - type: string remove_matched_tokens: + type: boolean description: | Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. - type: boolean metadata: + type: object description: | Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered. - type: object x-rust-is-used-as-input: true sort_by: + type: string description: | A sort by clause that is applied to any search query that matches the curation rule. - type: string replace_query: + type: string description: | Replaces the current search query with this value, when the search query matches the curation rule. - type: string filter_curated_hits: + type: boolean description: | When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. - type: boolean effective_from_ts: + type: integer description: | A Unix timestamp that indicates the date/time from which the curation will be active. You can use this to create rules that start applying from a future point in time. - type: integer effective_to_ts: + type: integer description: | A Unix timestamp that indicates the date/time until which the curation will be active. You can use this to create rules that stop applying after a period of time. - type: integer stop_processing: + type: boolean description: | When set to true, curation processing will stop at the first matching rule. When set to false curation processing will continue and multiple curation actions will be triggered in sequence. Curations are processed in the lexical sort order of their id field. - type: boolean id: - description: ID of the curation item type: string + description: ID of the curation item x-rust-is-used-as-input: true CurationItemSchema: allOf: @@ -5007,13 +5007,13 @@ components: - items properties: items: - description: Array of curation items type: array + description: Array of curation items items: $ref: '#/components/schemas/CurationItemCreateSchema' description: - description: Optional description for the curation set type: string + description: Optional description for the curation set x-rust-is-used-as-input: true CurationSetSchema: allOf: @@ -5028,24 +5028,24 @@ components: type: object properties: tags: - description: List of tag values to associate with this curation rule. type: array + description: List of tag values to associate with this curation rule. items: type: string query: - description: Indicates what search queries should be curated type: string + description: Indicates what search queries should be curated match: + type: string description: | Indicates whether the match on the query term should be `exact` or `contains`. If we want to match all queries that contained the word `apple`, we will use the `contains` match instead. - type: string enum: - exact - contains filter_by: + type: string description: | Indicates that the curation should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc). - type: string CurationInclude: type: object required: @@ -5053,19 +5053,19 @@ components: - position properties: id: - description: document id that should be included type: string + description: document id that should be included position: - description: position number where document should be included in the search results type: integer + description: position number where document should be included in the search results CurationExclude: type: object required: - id properties: id: - description: document id that should be excluded from the search results. type: string + description: document id that should be excluded from the search results. CurationSetRetrieveSchema: $ref: '#/components/schemas/CurationSetCreateSchema' CurationSetDeleteSchema: @@ -5074,24 +5074,24 @@ components: - name properties: name: - description: Name of the deleted curation set type: string + description: Name of the deleted curation set CurationItemDeleteSchema: type: object required: - id properties: id: - description: ID of the deleted curation item type: string + description: ID of the deleted curation item ImportDocumentsParameters: type: object properties: batch_size: type: integer return_id: - description: Returning the id of the imported documents. If you want the import response to return the ingested document's id in the response, you can use the return_id parameter. type: boolean + description: Returning the id of the imported documents. If you want the import response to return the ingested document's id in the response, you can use the return_id parameter. remote_embedding_batch_size: type: integer return_doc: @@ -5105,14 +5105,14 @@ components: type: object properties: filter_by: - description: Filter conditions for refining your search results. Separate multiple conditions with &&. type: string + description: Filter conditions for refining your search results. Separate multiple conditions with &&. include_fields: - description: List of fields from the document to include in the search result type: string + description: List of fields from the document to include in the search result exclude_fields: - description: List of fields from the document to exclude in the search result type: string + description: List of fields from the document to exclude in the search result x-rust-is-used-as-input: true UpdateDocumentsParameters: type: object @@ -5130,27 +5130,27 @@ components: type: string example: 'num_employees:>100 && country: [USA, UK]' batch_size: - description: Batch size parameter controls the number of documents that should be deleted at a time. A larger value will speed up deletions, but will impact performance of other operations running on the server. type: integer + description: Batch size parameter controls the number of documents that should be deleted at a time. A larger value will speed up deletions, but will impact performance of other operations running on the server. ignore_not_found: type: boolean truncate: - description: When true, removes all documents from the collection while preserving the collection and its schema. type: boolean + description: When true, removes all documents from the collection while preserving the collection and its schema. x-rust-is-used-as-input: true GetCollectionsParameters: type: object properties: exclude_fields: - description: Comma-separated list of fields from the collection to exclude from the response type: string + description: Comma-separated list of fields from the collection to exclude from the response limit: + type: integer description: | Number of collections to fetch. Default: returns all collections. - type: integer offset: - description: Identifies the starting point to return collections when paginating. type: integer + description: Identifies the starting point to return collections when paginating. x-rust-is-used-as-input: true securitySchemes: api_key_header: diff --git a/xtask/src/preprocess_openapi.rs b/xtask/src/preprocess_openapi.rs index 318c79e7..2fb8990a 100644 --- a/xtask/src/preprocess_openapi.rs +++ b/xtask/src/preprocess_openapi.rs @@ -57,11 +57,11 @@ pub(crate) struct OpenAPIMethod { #[derive(Clone, Debug, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub(crate) struct OpenAPIBody { - #[serde(skip_serializing_if = "Option::is_none")] - pub(crate) description: Option, #[serde(skip_serializing_if = "Option::is_none")] pub(crate) required: Option, #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) description: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub(crate) content: Option>, // Everything else not explicitly listed above @@ -86,12 +86,12 @@ pub(crate) struct OpenAPIParameter { #[serde(skip_serializing_if = "Option::is_none")] pub(crate) name: Option, #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) required: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub(crate) r#in: Option, #[serde(skip_serializing_if = "Option::is_none")] pub(crate) description: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub(crate) required: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub(crate) schema: Option, // Everything else not explicitly listed above @@ -113,13 +113,15 @@ pub(crate) struct OpenAPIComponents { #[derive(Clone, Debug, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub(crate) struct OpenAPIProperty { - #[serde(skip_serializing_if = "Option::is_none")] - pub(crate) description: Option, #[serde(skip_serializing_if = "Option::is_none")] pub(crate) r#type: Option, #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) default: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub(crate) required: Option, #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) description: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub(crate) example: Option, #[serde(rename = "$ref", skip_serializing_if = "Option::is_none")] pub(crate) r#ref: Option, From dd004421ea99234d1ca30661e797bd08d62e2387 Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Thu, 13 Nov 2025 11:30:13 +0000 Subject: [PATCH 15/17] Rm PhantomData --- openapi-generator-template/model.mustache | 9 --------- openapi-generator-template/reqwest/api.mustache | 2 -- typesense/src/client/alias.rs | 2 -- typesense/src/client/aliases.rs | 1 - typesense/src/client/collection/document.rs | 3 --- typesense/src/client/collection/documents.rs | 8 +------- typesense/src/client/collection/mod.rs | 10 ++-------- typesense/src/client/collections.rs | 2 -- typesense/src/client/conversations/model.rs | 3 --- typesense/src/client/conversations/models.rs | 1 - typesense/src/client/key.rs | 2 -- typesense/src/client/keys.rs | 1 - typesense/src/client/multi_search.rs | 2 -- typesense/src/client/operations.rs | 2 -- typesense/src/client/preset.rs | 2 -- typesense/src/client/presets.rs | 1 - typesense/src/client/stemming/dictionaries.rs | 1 - typesense/src/client/stemming/dictionary.rs | 1 - typesense/src/client/stopword.rs | 2 -- typesense/src/client/stopwords.rs | 1 - typesense/tests/client/aliases_test.rs | 1 - typesense/tests/client/documents_test.rs | 1 - typesense/tests/client/operations_test.rs | 1 - typesense/tests/client/presets_test.rs | 1 - typesense_codegen/src/apis/analytics_api.rs | 9 +-------- typesense_codegen/src/apis/collections_api.rs | 14 +++----------- typesense_codegen/src/apis/conversations_api.rs | 6 +----- typesense_codegen/src/apis/curation_sets_api.rs | 9 +-------- typesense_codegen/src/apis/debug_api.rs | 2 +- typesense_codegen/src/apis/documents_api.rs | 12 +----------- typesense_codegen/src/apis/health_api.rs | 2 +- typesense_codegen/src/apis/keys_api.rs | 13 +++++-------- typesense_codegen/src/apis/nl_search_models_api.rs | 6 +----- typesense_codegen/src/apis/operations_api.rs | 10 ++++------ typesense_codegen/src/apis/presets_api.rs | 5 +---- typesense_codegen/src/apis/stemming_api.rs | 4 +--- typesense_codegen/src/apis/stopwords_api.rs | 5 +---- typesense_codegen/src/apis/synonyms_api.rs | 9 +-------- typesense_codegen/src/models/analytics_event.rs | 5 +---- .../src/models/analytics_event_create_response.rs | 2 +- .../src/models/analytics_event_data.rs | 5 +---- .../src/models/analytics_events_response.rs | 2 +- .../analytics_events_response_events_inner.rs | 2 +- typesense_codegen/src/models/analytics_rule.rs | 2 +- .../src/models/analytics_rule_create.rs | 5 +---- .../src/models/analytics_rule_create_params.rs | 5 +---- .../src/models/analytics_rule_update.rs | 5 +---- typesense_codegen/src/models/analytics_status.rs | 2 +- typesense_codegen/src/models/api_key.rs | 2 +- .../src/models/api_key_delete_response.rs | 2 +- typesense_codegen/src/models/api_key_schema.rs | 5 +---- typesense_codegen/src/models/api_keys_response.rs | 2 +- typesense_codegen/src/models/api_response.rs | 2 +- typesense_codegen/src/models/api_stats_response.rs | 2 +- typesense_codegen/src/models/collection_alias.rs | 2 +- .../src/models/collection_alias_schema.rs | 9 ++------- .../src/models/collection_aliases_response.rs | 2 +- .../src/models/collection_response.rs | 2 +- typesense_codegen/src/models/collection_schema.rs | 6 +----- .../src/models/collection_update_schema.rs | 9 +++------ .../src/models/conversation_model_create_schema.rs | 5 +---- .../src/models/conversation_model_schema.rs | 2 +- .../src/models/conversation_model_update_schema.rs | 5 +---- .../models/create_analytics_rule_200_response.rs | 2 +- ...ate_analytics_rule_200_response_one_of_inner.rs | 2 +- ...lytics_rule_200_response_one_of_inner_any_of.rs | 2 +- .../src/models/create_analytics_rule_request.rs | 2 +- typesense_codegen/src/models/curation_exclude.rs | 2 +- typesense_codegen/src/models/curation_include.rs | 2 +- .../src/models/curation_item_create_schema.rs | 5 +---- .../src/models/curation_item_delete_schema.rs | 2 +- .../src/models/curation_item_schema.rs | 2 +- typesense_codegen/src/models/curation_rule.rs | 2 +- .../src/models/curation_set_create_schema.rs | 5 +---- .../src/models/curation_set_delete_schema.rs | 2 +- .../src/models/curation_set_schema.rs | 2 +- typesense_codegen/src/models/debug_200_response.rs | 2 +- .../src/models/delete_documents_200_response.rs | 2 +- .../src/models/delete_documents_parameters.rs | 5 +---- .../models/delete_stopwords_set_200_response.rs | 2 +- typesense_codegen/src/models/dirty_values.rs | 2 +- typesense_codegen/src/models/drop_tokens_mode.rs | 2 +- .../src/models/export_documents_parameters.rs | 5 +---- typesense_codegen/src/models/facet_counts.rs | 2 +- .../src/models/facet_counts_counts_inner.rs | 2 +- typesense_codegen/src/models/facet_counts_stats.rs | 2 +- typesense_codegen/src/models/field.rs | 2 +- typesense_codegen/src/models/field_embed.rs | 2 +- .../src/models/field_embed_model_config.rs | 2 +- .../src/models/get_collections_parameters.rs | 5 +---- typesense_codegen/src/models/health_status.rs | 2 +- .../src/models/import_documents_parameters.rs | 9 +++------ typesense_codegen/src/models/index_action.rs | 2 +- .../list_stemming_dictionaries_200_response.rs | 2 +- .../models/multi_search_collection_parameters.rs | 6 +----- .../src/models/multi_search_parameters.rs | 6 +----- .../src/models/multi_search_result.rs | 2 +- .../src/models/multi_search_result_item.rs | 2 +- .../src/models/multi_search_searches_parameter.rs | 5 +---- .../src/models/nl_search_model_base.rs | 2 +- .../src/models/nl_search_model_create_schema.rs | 5 +---- .../src/models/nl_search_model_delete_schema.rs | 2 +- .../src/models/nl_search_model_schema.rs | 2 +- .../src/models/preset_delete_schema.rs | 2 +- typesense_codegen/src/models/preset_schema.rs | 2 +- .../src/models/preset_upsert_schema.rs | 5 +---- .../src/models/preset_upsert_schema_value.rs | 2 +- .../src/models/presets_retrieve_schema.rs | 2 +- .../src/models/schema_change_status.rs | 2 +- typesense_codegen/src/models/search_grouped_hit.rs | 2 +- typesense_codegen/src/models/search_highlight.rs | 2 +- typesense_codegen/src/models/search_parameters.rs | 6 +----- .../src/models/search_request_params.rs | 2 +- .../models/search_request_params_voice_query.rs | 2 +- typesense_codegen/src/models/search_result.rs | 2 +- .../src/models/search_result_conversation.rs | 2 +- typesense_codegen/src/models/search_result_hit.rs | 2 +- .../models/search_result_hit_hybrid_search_info.rs | 2 +- .../models/search_result_hit_text_match_info.rs | 2 +- typesense_codegen/src/models/search_synonym.rs | 2 +- .../src/models/search_synonym_delete_response.rs | 2 +- .../src/models/search_synonym_schema.rs | 2 +- .../src/models/search_synonyms_response.rs | 2 +- .../src/models/stemming_dictionary.rs | 2 +- .../src/models/stemming_dictionary_words_inner.rs | 2 +- .../src/models/stopwords_set_retrieve_schema.rs | 2 +- .../src/models/stopwords_set_schema.rs | 2 +- .../src/models/stopwords_set_upsert_schema.rs | 5 +---- .../models/stopwords_sets_retrieve_all_schema.rs | 2 +- typesense_codegen/src/models/success_status.rs | 2 +- .../src/models/synonym_item_delete_schema.rs | 2 +- .../src/models/synonym_item_schema.rs | 5 +---- .../src/models/synonym_set_create_schema.rs | 9 ++------- .../src/models/synonym_set_delete_schema.rs | 2 +- typesense_codegen/src/models/synonym_set_schema.rs | 2 +- .../src/models/synonym_sets_retrieve_schema.rs | 2 +- .../src/models/toggle_slow_request_log_request.rs | 9 +++------ .../src/models/update_documents_200_response.rs | 2 +- .../src/models/update_documents_parameters.rs | 9 ++------- .../models/voice_query_model_collection_config.rs | 2 +- 140 files changed, 137 insertions(+), 345 deletions(-) diff --git a/openapi-generator-template/model.mustache b/openapi-generator-template/model.mustache index 1ff1d53c..9bed530e 100644 --- a/openapi-generator-template/model.mustache +++ b/openapi-generator-template/model.mustache @@ -1,7 +1,6 @@ {{>partial_header}} use crate::models; use ::std::borrow::Cow; -use ::std::marker::PhantomData; use serde::{Deserialize, Serialize}; {{#models}} {{#model}} @@ -170,11 +169,6 @@ pub struct {{{classname}}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a{{#ven }}{{#isNullable}}>{{/isNullable}}{{^required}}>{{/required}}, {{/vendorExtensions.x-rust-type}} {{/vars}} - {{#vendorExtensions.x-rust-is-used-as-input}} - #[serde(skip)] - {{#vendorExtensions.x-rust-builder}}#[builder(default)]{{/vendorExtensions.x-rust-builder}} - pub _phantom: PhantomData<&'a ()>, - {{/vendorExtensions.x-rust-is-used-as-input}} } impl{{#vendorExtensions.x-rust-is-used-as-input}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}{{#vendorExtensions.x-rust-generic-parameter}}<{{{.}}}>{{/vendorExtensions.x-rust-generic-parameter}}{{/vendorExtensions.x-rust-is-used-as-input}} {{! @@ -213,9 +207,6 @@ impl{{#vendorExtensions.x-rust-is-used-as-input}}<'a{{#vendorExtensions.x-rust-g {{{name}}}{{^required}}: None{{/required}}{{#required}}{{#isModel}}{{^avoidBoxedModels}}: {{^isNullable}}Box::new({{{name}}}){{/isNullable}}{{#isNullable}}if let Some(x) = {{{name}}} {Some(Box::new(x))} else {None}{{/isNullable}}{{/avoidBoxedModels}}{{/isModel}}{{/required}}, {{/vendorExtensions.x-rust-type}} {{/vars}} - {{#vendorExtensions.x-rust-is-used-as-input}} - _phantom: PhantomData, - {{/vendorExtensions.x-rust-is-used-as-input}} } } } diff --git a/openapi-generator-template/reqwest/api.mustache b/openapi-generator-template/reqwest/api.mustache index 406f8901..c6dbc9a4 100644 --- a/openapi-generator-template/reqwest/api.mustache +++ b/openapi-generator-template/reqwest/api.mustache @@ -3,7 +3,6 @@ use super::{Error, configuration, ContentType}; use crate::{apis::ResponseContent, models}; use ::std::borrow::Cow; -use ::std::marker::PhantomData; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; @@ -46,7 +45,6 @@ pub struct {{{operationIdCamelCase}}}Params<'p{{! }}, {{/vendorExtensions.x-rust-type}} {{#-last}} - pub _phantom: PhantomData<&'p ()>, } {{/-last}} diff --git a/typesense/src/client/alias.rs b/typesense/src/client/alias.rs index 864143d4..840bd234 100644 --- a/typesense/src/client/alias.rs +++ b/typesense/src/client/alias.rs @@ -26,7 +26,6 @@ impl<'a> Alias<'a> { ) -> Result> { let params = collections_api::GetAliasParams { alias_name: self.alias_name.into(), - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::get_alias, params) @@ -38,7 +37,6 @@ impl<'a> Alias<'a> { ) -> Result> { let params = collections_api::DeleteAliasParams { alias_name: self.alias_name.into(), - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::delete_alias, params) } diff --git a/typesense/src/client/aliases.rs b/typesense/src/client/aliases.rs index e50e0283..ec5b8849 100644 --- a/typesense/src/client/aliases.rs +++ b/typesense/src/client/aliases.rs @@ -37,7 +37,6 @@ impl<'a> Aliases<'a> { let params = collections_api::UpsertAliasParams { alias_name: alias_name.into(), collection_alias_schema: Some(schema), - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::upsert_alias, params) } diff --git a/typesense/src/client/collection/document.rs b/typesense/src/client/collection/document.rs index afddd392..03fe09fe 100644 --- a/typesense/src/client/collection/document.rs +++ b/typesense/src/client/collection/document.rs @@ -52,7 +52,6 @@ where let params = documents_api::GetDocumentParams { collection_name: self.collection_name.into(), document_id: self.document_id.as_ref().into(), - _phantom: core::marker::PhantomData, }; let result_value = execute_wrapper!(self, documents_api::get_document, params)?; @@ -70,7 +69,6 @@ where let params = documents_api::DeleteDocumentParams { collection_name: self.collection_name.into(), document_id: self.document_id.as_ref().into(), - _phantom: core::marker::PhantomData, }; let result_value = execute_wrapper!(self, documents_api::delete_document, params)?; @@ -136,7 +134,6 @@ where document_id: self.document_id.as_ref().into(), body: partial_document, dirty_values: params.and_then(|d| d.dirty_values), - _phantom: core::marker::PhantomData, }; let result_value = execute_wrapper!(self, documents_api::update_document, params)?; diff --git a/typesense/src/client/collection/documents.rs b/typesense/src/client/collection/documents.rs index 91a41f55..9010d2ee 100644 --- a/typesense/src/client/collection/documents.rs +++ b/typesense/src/client/collection/documents.rs @@ -61,7 +61,6 @@ where body: document, action: Some(action.into()), dirty_values: params.and_then(|d| d.dirty_values), // Or expose this as an argument if needed - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, documents_api::index_document, params) } @@ -78,7 +77,7 @@ where pub async fn import_jsonl( &self, documents_jsonl: impl Into>, - params: ImportDocumentsParameters<'_>, + params: ImportDocumentsParameters, ) -> Result> { let params = documents_api::ImportDocumentsParams { body: documents_jsonl.into(), @@ -90,7 +89,6 @@ where remote_embedding_batch_size: params.remote_embedding_batch_size, return_doc: params.return_doc, return_id: params.return_id, - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, documents_api::import_documents, params) } @@ -108,7 +106,6 @@ where exclude_fields: params.exclude_fields, filter_by: params.filter_by, include_fields: params.include_fields, - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, documents_api::export_documents, params) } @@ -128,7 +125,6 @@ where batch_size: params.batch_size, ignore_not_found: params.ignore_not_found, truncate: params.truncate, - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, documents_api::delete_documents, params) } @@ -217,7 +213,6 @@ where nl_query: params.nl_query, enable_analytics: params.enable_analytics, synonym_sets: params.synonym_sets, - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, documents_api::search_collection, search_params) } @@ -279,7 +274,6 @@ where collection_name: self.collection_name.into(), filter_by: params.filter_by, body: document, - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, documents_api::update_documents, params) } diff --git a/typesense/src/client/collection/mod.rs b/typesense/src/client/collection/mod.rs index b8067f7f..a7a9cef0 100644 --- a/typesense/src/client/collection/mod.rs +++ b/typesense/src/client/collection/mod.rs @@ -58,7 +58,6 @@ where ) -> Result> { let params = collections_api::GetCollectionParams { collection_name: self.collection_name.as_ref().into(), - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::get_collection, params) } @@ -70,7 +69,6 @@ where ) -> Result> { let params = collections_api::DeleteCollectionParams { collection_name: self.collection_name.as_ref().into(), - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::delete_collection, params) } @@ -82,15 +80,11 @@ where #[inline] pub async fn update( &self, - update_schema: models::CollectionUpdateSchema<'_>, - ) -> Result< - models::CollectionUpdateSchema<'static>, - Error, - > { + update_schema: models::CollectionUpdateSchema, + ) -> Result> { let params = collections_api::UpdateCollectionParams { collection_name: self.collection_name.as_ref().into(), collection_update_schema: update_schema, - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::update_collection, params) } diff --git a/typesense/src/client/collections.rs b/typesense/src/client/collections.rs index 723a2853..2c0d19bb 100644 --- a/typesense/src/client/collections.rs +++ b/typesense/src/client/collections.rs @@ -32,7 +32,6 @@ impl<'c> Collections<'c> { ) -> Result> { let params = collections_api::CreateCollectionParams { collection_schema: schema, - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::create_collection, params) } @@ -46,7 +45,6 @@ impl<'c> Collections<'c> { exclude_fields: params.exclude_fields, limit: params.limit, offset: params.offset, - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, collections_api::get_collections, params) } diff --git a/typesense/src/client/conversations/model.rs b/typesense/src/client/conversations/model.rs index 78be6265..1192f090 100644 --- a/typesense/src/client/conversations/model.rs +++ b/typesense/src/client/conversations/model.rs @@ -29,7 +29,6 @@ impl<'a> Model<'a> { > { let params = conversations_api::RetrieveConversationModelParams { model_id: self.model_id.into(), - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, conversations_api::retrieve_conversation_model, params) } @@ -48,7 +47,6 @@ impl<'a> Model<'a> { let params = conversations_api::UpdateConversationModelParams { model_id: self.model_id.into(), conversation_model_update_schema: schema, - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, conversations_api::update_conversation_model, params) } @@ -62,7 +60,6 @@ impl<'a> Model<'a> { > { let params = conversations_api::DeleteConversationModelParams { model_id: self.model_id.into(), - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, conversations_api::delete_conversation_model, params) } diff --git a/typesense/src/client/conversations/models.rs b/typesense/src/client/conversations/models.rs index b178b959..1cf566a5 100644 --- a/typesense/src/client/conversations/models.rs +++ b/typesense/src/client/conversations/models.rs @@ -32,7 +32,6 @@ impl<'a> Models<'a> { > { let params = conversations_api::CreateConversationModelParams { conversation_model_create_schema: schema, - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, conversations_api::create_conversation_model, params) } diff --git a/typesense/src/client/key.rs b/typesense/src/client/key.rs index a1ceb9b1..03e95360 100644 --- a/typesense/src/client/key.rs +++ b/typesense/src/client/key.rs @@ -28,7 +28,6 @@ impl<'c> Key<'c> { pub async fn retrieve(&self) -> Result> { let params = keys_api::GetKeyParams { key_id: self.key_id, - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, keys_api::get_key, params) } @@ -40,7 +39,6 @@ impl<'c> Key<'c> { ) -> Result> { let params = keys_api::DeleteKeyParams { key_id: self.key_id, - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, keys_api::delete_key, params) } diff --git a/typesense/src/client/keys.rs b/typesense/src/client/keys.rs index f0a05098..5949832d 100644 --- a/typesense/src/client/keys.rs +++ b/typesense/src/client/keys.rs @@ -39,7 +39,6 @@ impl<'c> Keys<'c> { ) -> Result> { let params = keys_api::CreateKeyParams { api_key_schema: Some(schema), - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, keys_api::create_key, params) } diff --git a/typesense/src/client/multi_search.rs b/typesense/src/client/multi_search.rs index f66680ec..e26778da 100644 --- a/typesense/src/client/multi_search.rs +++ b/typesense/src/client/multi_search.rs @@ -258,7 +258,6 @@ impl<'c> MultiSearch<'c> { let request_body = raw_models::MultiSearchSearchesParameter { union: Some(true), searches: search_requests.searches, - _phantom: core::marker::PhantomData, }; let multi_search_params = build_multi_search_params(request_body, common_search_params); @@ -345,7 +344,6 @@ fn build_multi_search_params<'a>( vector_query: params.vector_query, voice_query: params.voice_query, enable_analytics: params.enable_analytics, - _phantom: core::marker::PhantomData, // enable_highlight_v1: None, // max_candidates: None, // max_filter_by_candidates: None, diff --git a/typesense/src/client/operations.rs b/typesense/src/client/operations.rs index 2d48255b..29798184 100644 --- a/typesense/src/client/operations.rs +++ b/typesense/src/client/operations.rs @@ -158,9 +158,7 @@ impl<'a> Operations<'a> { let params = operations_api::ToggleSlowRequestLogParams { toggle_slow_request_log_request: Some(models::ToggleSlowRequestLogRequest { log_slow_requests_time_ms: slow_requests_threshold_ms, - _phantom: core::marker::PhantomData, }), - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, operations_api::toggle_slow_request_log, params) } diff --git a/typesense/src/client/preset.rs b/typesense/src/client/preset.rs index f19f36f5..0ba4c879 100644 --- a/typesense/src/client/preset.rs +++ b/typesense/src/client/preset.rs @@ -26,7 +26,6 @@ impl<'a> Preset<'a> { ) -> Result> { let params = presets_api::RetrievePresetParams { preset_id: self.preset_id.into(), - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, presets_api::retrieve_preset, params) } @@ -37,7 +36,6 @@ impl<'a> Preset<'a> { ) -> Result> { let params = presets_api::DeletePresetParams { preset_id: self.preset_id.into(), - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, presets_api::delete_preset, params) } diff --git a/typesense/src/client/presets.rs b/typesense/src/client/presets.rs index bd2a3c2d..dd8fd4a1 100644 --- a/typesense/src/client/presets.rs +++ b/typesense/src/client/presets.rs @@ -42,7 +42,6 @@ impl<'a> Presets<'a> { let params = presets_api::UpsertPresetParams { preset_id: preset_id.into(), preset_upsert_schema: schema, - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, presets_api::upsert_preset, params) } diff --git a/typesense/src/client/stemming/dictionaries.rs b/typesense/src/client/stemming/dictionaries.rs index 26715997..8eb944f7 100644 --- a/typesense/src/client/stemming/dictionaries.rs +++ b/typesense/src/client/stemming/dictionaries.rs @@ -38,7 +38,6 @@ impl<'a> Dictionaries<'a> { let params = stemming_api::ImportStemmingDictionaryParams { id: dictionary_id.into(), body: dictionary_jsonl.into(), - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, stemming_api::import_stemming_dictionary, params) } diff --git a/typesense/src/client/stemming/dictionary.rs b/typesense/src/client/stemming/dictionary.rs index 6bc40258..d93d64c1 100644 --- a/typesense/src/client/stemming/dictionary.rs +++ b/typesense/src/client/stemming/dictionary.rs @@ -32,7 +32,6 @@ impl<'a> Dictionary<'a> { ) -> Result> { let params = stemming_api::GetStemmingDictionaryParams { dictionary_id: self.dictionary_id.into(), - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, stemming_api::get_stemming_dictionary, params) } diff --git a/typesense/src/client/stopword.rs b/typesense/src/client/stopword.rs index fdaa99a1..41f58f1c 100644 --- a/typesense/src/client/stopword.rs +++ b/typesense/src/client/stopword.rs @@ -27,7 +27,6 @@ impl<'a> Stopword<'a> { { let params = stopwords_api::RetrieveStopwordsSetParams { set_id: self.set_id.into(), - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, stopwords_api::retrieve_stopwords_set, params) } @@ -39,7 +38,6 @@ impl<'a> Stopword<'a> { { let params = stopwords_api::DeleteStopwordsSetParams { set_id: self.set_id.into(), - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, stopwords_api::delete_stopwords_set, params) } diff --git a/typesense/src/client/stopwords.rs b/typesense/src/client/stopwords.rs index b896a133..98bf9a75 100644 --- a/typesense/src/client/stopwords.rs +++ b/typesense/src/client/stopwords.rs @@ -33,7 +33,6 @@ impl<'a> Stopwords<'a> { let params = stopwords_api::UpsertStopwordsSetParams { set_id: set_id.into(), stopwords_set_upsert_schema: schema, - _phantom: core::marker::PhantomData, }; execute_wrapper!(self, stopwords_api::upsert_stopwords_set, params) } diff --git a/typesense/tests/client/aliases_test.rs b/typesense/tests/client/aliases_test.rs index ad2ab600..c094a38d 100644 --- a/typesense/tests/client/aliases_test.rs +++ b/typesense/tests/client/aliases_test.rs @@ -27,7 +27,6 @@ async fn logic_test_aliases_and_alias_lifecycle() { // --- 2. Create (Upsert) an alias --- let alias_schema = CollectionAliasSchema { collection_name: collection_name.as_str().into(), - _phantom: core::marker::PhantomData, }; let upsert_result = client.aliases().upsert(&alias_name, alias_schema).await; diff --git a/typesense/tests/client/documents_test.rs b/typesense/tests/client/documents_test.rs index f5d34bdb..8469ca33 100644 --- a/typesense/tests/client/documents_test.rs +++ b/typesense/tests/client/documents_test.rs @@ -278,7 +278,6 @@ async fn run_test_generic_document_lifecycle() { // --- 7. Bulk Update (via `documents().update()`) --- let bulk_update_params = UpdateDocumentsParameters { filter_by: Some("publication_year:>1965".into()), - _phantom: core::marker::PhantomData, }; let bulk_update_response = typed_collection .documents() diff --git a/typesense/tests/client/operations_test.rs b/typesense/tests/client/operations_test.rs index 5f790a84..f9a5c109 100644 --- a/typesense/tests/client/operations_test.rs +++ b/typesense/tests/client/operations_test.rs @@ -67,7 +67,6 @@ async fn run_test_take_snapshot() { // In a typical Docker setup, `/tmp` is a safe choice. let params = typesense::models::TakeSnapshotParams { snapshot_path: "/tmp/typesense-snapshots-rust-test".into(), - _phantom: core::marker::PhantomData, }; let snapshot_result = client.operations().take_snapshot(params).await; diff --git a/typesense/tests/client/presets_test.rs b/typesense/tests/client/presets_test.rs index 854b467b..1f028633 100644 --- a/typesense/tests/client/presets_test.rs +++ b/typesense/tests/client/presets_test.rs @@ -18,7 +18,6 @@ async fn run_test_presets_lifecycle() { // This is the schema to be sent in the request body. let upsert_schema = PresetUpsertSchema { value: Box::new(expected_preset_value.clone()), - _phantom: core::marker::PhantomData, }; // --- 2. Create (Upsert) a Preset (via `presets`) --- diff --git a/typesense_codegen/src/apis/analytics_api.rs b/typesense_codegen/src/apis/analytics_api.rs index 733a8781..eed196b9 100644 --- a/typesense_codegen/src/apis/analytics_api.rs +++ b/typesense_codegen/src/apis/analytics_api.rs @@ -10,7 +10,7 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; @@ -19,7 +19,6 @@ use serde::{Deserialize, Serialize, de::Error as _}; pub struct CreateAnalyticsEventParams<'p> { /// The analytics event to be created pub analytics_event: models::AnalyticsEvent<'p>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`create_analytics_rule`] @@ -27,7 +26,6 @@ pub struct CreateAnalyticsEventParams<'p> { pub struct CreateAnalyticsRuleParams<'p> { /// The analytics rule(s) to be created pub create_analytics_rule_request: models::CreateAnalyticsRuleRequest<'p>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_analytics_rule`] @@ -35,7 +33,6 @@ pub struct CreateAnalyticsRuleParams<'p> { pub struct DeleteAnalyticsRuleParams<'p> { /// The name of the analytics rule to delete pub rule_name: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`get_analytics_events`] @@ -46,7 +43,6 @@ pub struct GetAnalyticsEventsParams<'p> { pub name: Cow<'p, str>, /// Number of events to return (max 1000) pub n: i32, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_analytics_rule`] @@ -54,7 +50,6 @@ pub struct GetAnalyticsEventsParams<'p> { pub struct RetrieveAnalyticsRuleParams<'p> { /// The name of the analytics rule to retrieve pub rule_name: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_analytics_rules`] @@ -62,7 +57,6 @@ pub struct RetrieveAnalyticsRuleParams<'p> { pub struct RetrieveAnalyticsRulesParams<'p> { /// Filter rules by rule_tag pub rule_tag: Option>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`upsert_analytics_rule`] @@ -72,7 +66,6 @@ pub struct UpsertAnalyticsRuleParams<'p> { pub rule_name: Cow<'p, str>, /// The Analytics rule to be upserted pub analytics_rule_update: models::AnalyticsRuleUpdate<'p>, - pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`create_analytics_event`] diff --git a/typesense_codegen/src/apis/collections_api.rs b/typesense_codegen/src/apis/collections_api.rs index 99a420a4..af842a8d 100644 --- a/typesense_codegen/src/apis/collections_api.rs +++ b/typesense_codegen/src/apis/collections_api.rs @@ -10,7 +10,7 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; @@ -19,7 +19,6 @@ use serde::{Deserialize, Serialize, de::Error as _}; pub struct CreateCollectionParams<'p> { /// The collection object to be created pub collection_schema: models::CollectionSchema<'p>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_alias`] @@ -27,7 +26,6 @@ pub struct CreateCollectionParams<'p> { pub struct DeleteAliasParams<'p> { /// The name of the alias to delete pub alias_name: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_collection`] @@ -35,7 +33,6 @@ pub struct DeleteAliasParams<'p> { pub struct DeleteCollectionParams<'p> { /// The name of the collection to delete pub collection_name: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`get_alias`] @@ -43,7 +40,6 @@ pub struct DeleteCollectionParams<'p> { pub struct GetAliasParams<'p> { /// The name of the alias to retrieve pub alias_name: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`get_collection`] @@ -51,7 +47,6 @@ pub struct GetAliasParams<'p> { pub struct GetCollectionParams<'p> { /// The name of the collection to retrieve pub collection_name: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`get_collections`] @@ -60,7 +55,6 @@ pub struct GetCollectionsParams<'p> { pub exclude_fields: Option>, pub limit: Option, pub offset: Option, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`update_collection`] @@ -69,8 +63,7 @@ pub struct UpdateCollectionParams<'p> { /// The name of the collection to update pub collection_name: Cow<'p, str>, /// The document object with fields to be updated - pub collection_update_schema: models::CollectionUpdateSchema<'p>, - pub _phantom: PhantomData<&'p ()>, + pub collection_update_schema: models::CollectionUpdateSchema, } /// struct for passing parameters to the method [`upsert_alias`] @@ -80,7 +73,6 @@ pub struct UpsertAliasParams<'p> { pub alias_name: Cow<'p, str>, /// Collection alias to be created/updated pub collection_alias_schema: Option>, - pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`create_collection`] @@ -589,7 +581,7 @@ pub async fn get_collections( pub async fn update_collection( configuration: &configuration::Configuration, params: &UpdateCollectionParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/collections/{collectionName}", configuration.base_path, diff --git a/typesense_codegen/src/apis/conversations_api.rs b/typesense_codegen/src/apis/conversations_api.rs index a357be09..3a16d76b 100644 --- a/typesense_codegen/src/apis/conversations_api.rs +++ b/typesense_codegen/src/apis/conversations_api.rs @@ -10,7 +10,7 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; @@ -18,7 +18,6 @@ use serde::{Deserialize, Serialize, de::Error as _}; #[derive(Clone, Debug)] pub struct CreateConversationModelParams<'p> { pub conversation_model_create_schema: models::ConversationModelCreateSchema<'p>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_conversation_model`] @@ -26,7 +25,6 @@ pub struct CreateConversationModelParams<'p> { pub struct DeleteConversationModelParams<'p> { /// The id of the conversation model to delete pub model_id: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_conversation_model`] @@ -34,7 +32,6 @@ pub struct DeleteConversationModelParams<'p> { pub struct RetrieveConversationModelParams<'p> { /// The id of the conversation model to retrieve pub model_id: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`update_conversation_model`] @@ -43,7 +40,6 @@ pub struct UpdateConversationModelParams<'p> { /// The id of the conversation model to update pub model_id: Cow<'p, str>, pub conversation_model_update_schema: models::ConversationModelUpdateSchema<'p>, - pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`create_conversation_model`] diff --git a/typesense_codegen/src/apis/curation_sets_api.rs b/typesense_codegen/src/apis/curation_sets_api.rs index 518eab07..f6a3ee23 100644 --- a/typesense_codegen/src/apis/curation_sets_api.rs +++ b/typesense_codegen/src/apis/curation_sets_api.rs @@ -10,7 +10,7 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; @@ -19,7 +19,6 @@ use serde::{Deserialize, Serialize, de::Error as _}; pub struct DeleteCurationSetParams<'p> { /// The name of the curation set to delete pub curation_set_name: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_curation_set_item`] @@ -29,7 +28,6 @@ pub struct DeleteCurationSetItemParams<'p> { pub curation_set_name: Cow<'p, str>, /// The id of the curation item to delete pub item_id: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_curation_set`] @@ -37,7 +35,6 @@ pub struct DeleteCurationSetItemParams<'p> { pub struct RetrieveCurationSetParams<'p> { /// The name of the curation set to retrieve pub curation_set_name: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_curation_set_item`] @@ -47,7 +44,6 @@ pub struct RetrieveCurationSetItemParams<'p> { pub curation_set_name: Cow<'p, str>, /// The id of the curation item to retrieve pub item_id: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_curation_set_items`] @@ -55,7 +51,6 @@ pub struct RetrieveCurationSetItemParams<'p> { pub struct RetrieveCurationSetItemsParams<'p> { /// The name of the curation set to retrieve items for pub curation_set_name: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`upsert_curation_set`] @@ -65,7 +60,6 @@ pub struct UpsertCurationSetParams<'p> { pub curation_set_name: Cow<'p, str>, /// The curation set to be created/updated pub curation_set_create_schema: models::CurationSetCreateSchema<'p>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`upsert_curation_set_item`] @@ -77,7 +71,6 @@ pub struct UpsertCurationSetItemParams<'p> { pub item_id: Cow<'p, str>, /// The curation item to be created/updated pub curation_item_create_schema: models::CurationItemCreateSchema<'p>, - pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`delete_curation_set`] diff --git a/typesense_codegen/src/apis/debug_api.rs b/typesense_codegen/src/apis/debug_api.rs index eecdf103..6543f64b 100644 --- a/typesense_codegen/src/apis/debug_api.rs +++ b/typesense_codegen/src/apis/debug_api.rs @@ -10,7 +10,7 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; diff --git a/typesense_codegen/src/apis/documents_api.rs b/typesense_codegen/src/apis/documents_api.rs index 77f583db..d13e363c 100644 --- a/typesense_codegen/src/apis/documents_api.rs +++ b/typesense_codegen/src/apis/documents_api.rs @@ -10,7 +10,7 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; @@ -21,7 +21,6 @@ pub struct DeleteDocumentParams<'p> { pub collection_name: Cow<'p, str>, /// The Document ID pub document_id: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_documents`] @@ -33,7 +32,6 @@ pub struct DeleteDocumentsParams<'p> { pub batch_size: Option, pub ignore_not_found: Option, pub truncate: Option, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`export_documents`] @@ -44,7 +42,6 @@ pub struct ExportDocumentsParams<'p> { pub filter_by: Option>, pub include_fields: Option>, pub exclude_fields: Option>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`get_document`] @@ -54,7 +51,6 @@ pub struct GetDocumentParams<'p> { pub collection_name: Cow<'p, str>, /// The Document ID pub document_id: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`import_documents`] @@ -70,7 +66,6 @@ pub struct ImportDocumentsParams<'p> { pub return_doc: Option, pub action: Option, pub dirty_values: Option, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`index_document`] @@ -84,7 +79,6 @@ pub struct IndexDocumentParams<'p> { pub action: Option>, /// Dealing with Dirty Data pub dirty_values: Option, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`multi_search`] @@ -155,7 +149,6 @@ pub struct MultiSearchParams<'p> { pub conversation_model_id: Option>, pub conversation_id: Option>, pub multi_search_searches_parameter: Option>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`search_collection`] @@ -234,7 +227,6 @@ pub struct SearchCollectionParams<'p> { pub conversation: Option, pub conversation_model_id: Option>, pub conversation_id: Option>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`update_document`] @@ -248,7 +240,6 @@ pub struct UpdateDocumentParams<'p, B> { pub body: B, /// Dealing with Dirty Data pub dirty_values: Option, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`update_documents`] @@ -259,7 +250,6 @@ pub struct UpdateDocumentsParams<'p, B> { /// The document fields to be updated pub body: B, pub filter_by: Option>, - pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`delete_document`] diff --git a/typesense_codegen/src/apis/health_api.rs b/typesense_codegen/src/apis/health_api.rs index f8900dde..e667693b 100644 --- a/typesense_codegen/src/apis/health_api.rs +++ b/typesense_codegen/src/apis/health_api.rs @@ -10,7 +10,7 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; diff --git a/typesense_codegen/src/apis/keys_api.rs b/typesense_codegen/src/apis/keys_api.rs index c9b7e6c0..d60ff760 100644 --- a/typesense_codegen/src/apis/keys_api.rs +++ b/typesense_codegen/src/apis/keys_api.rs @@ -10,7 +10,7 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; @@ -19,23 +19,20 @@ use serde::{Deserialize, Serialize, de::Error as _}; pub struct CreateKeyParams<'p> { /// The object that describes API key scope pub api_key_schema: Option>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_key`] #[derive(Clone, Debug)] -pub struct DeleteKeyParams<'p> { +pub struct DeleteKeyParams { /// The ID of the key to delete pub key_id: i64, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`get_key`] #[derive(Clone, Debug)] -pub struct GetKeyParams<'p> { +pub struct GetKeyParams { /// The ID of the key to retrieve pub key_id: i64, - pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`create_key`] @@ -133,7 +130,7 @@ pub async fn create_key( pub async fn delete_key( configuration: &configuration::Configuration, - params: &DeleteKeyParams<'_>, + params: &DeleteKeyParams, ) -> Result> { let uri_str = format!( "{}/keys/{keyId}", @@ -196,7 +193,7 @@ pub async fn delete_key( /// Retrieve (metadata about) a key. Only the key prefix is returned when you retrieve a key. Due to security reasons, only the create endpoint returns the full API key. pub async fn get_key( configuration: &configuration::Configuration, - params: &GetKeyParams<'_>, + params: &GetKeyParams, ) -> Result> { let uri_str = format!( "{}/keys/{keyId}", diff --git a/typesense_codegen/src/apis/nl_search_models_api.rs b/typesense_codegen/src/apis/nl_search_models_api.rs index 9aca2551..eef9fa05 100644 --- a/typesense_codegen/src/apis/nl_search_models_api.rs +++ b/typesense_codegen/src/apis/nl_search_models_api.rs @@ -10,7 +10,7 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; @@ -19,7 +19,6 @@ use serde::{Deserialize, Serialize, de::Error as _}; pub struct CreateNlSearchModelParams<'p> { /// The NL search model to be created pub nl_search_model_create_schema: models::NlSearchModelCreateSchema<'p>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_nl_search_model`] @@ -27,7 +26,6 @@ pub struct CreateNlSearchModelParams<'p> { pub struct DeleteNlSearchModelParams<'p> { /// The ID of the NL search model to delete pub model_id: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_nl_search_model`] @@ -35,7 +33,6 @@ pub struct DeleteNlSearchModelParams<'p> { pub struct RetrieveNlSearchModelParams<'p> { /// The ID of the NL search model to retrieve pub model_id: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`update_nl_search_model`] @@ -45,7 +42,6 @@ pub struct UpdateNlSearchModelParams<'p> { pub model_id: Cow<'p, str>, /// The NL search model fields to update pub body: models::NlSearchModelCreateSchema<'p>, - pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`create_nl_search_model`] diff --git a/typesense_codegen/src/apis/operations_api.rs b/typesense_codegen/src/apis/operations_api.rs index b85c1e8e..54b123e9 100644 --- a/typesense_codegen/src/apis/operations_api.rs +++ b/typesense_codegen/src/apis/operations_api.rs @@ -10,7 +10,7 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; @@ -19,14 +19,12 @@ use serde::{Deserialize, Serialize, de::Error as _}; pub struct TakeSnapshotParams<'p> { /// The directory on the server where the snapshot should be saved. pub snapshot_path: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`toggle_slow_request_log`] #[derive(Clone, Debug)] -pub struct ToggleSlowRequestLogParams<'p> { - pub toggle_slow_request_log_request: Option>, - pub _phantom: PhantomData<&'p ()>, +pub struct ToggleSlowRequestLogParams { + pub toggle_slow_request_log_request: Option, } /// struct for typed errors of method [`clear_cache`] @@ -432,7 +430,7 @@ pub async fn take_snapshot( /// Enable logging of requests that take over a defined threshold of time. Default is `-1` which disables slow request logging. Slow requests are logged to the primary log file, with the prefix SLOW REQUEST. pub async fn toggle_slow_request_log( configuration: &configuration::Configuration, - params: &ToggleSlowRequestLogParams<'_>, + params: &ToggleSlowRequestLogParams, ) -> Result> { let uri_str = format!("{}/config", configuration.base_path); let mut req_builder = configuration diff --git a/typesense_codegen/src/apis/presets_api.rs b/typesense_codegen/src/apis/presets_api.rs index 7edaed09..280bebd5 100644 --- a/typesense_codegen/src/apis/presets_api.rs +++ b/typesense_codegen/src/apis/presets_api.rs @@ -10,7 +10,7 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; @@ -19,7 +19,6 @@ use serde::{Deserialize, Serialize, de::Error as _}; pub struct DeletePresetParams<'p> { /// The ID of the preset to delete. pub preset_id: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_preset`] @@ -27,7 +26,6 @@ pub struct DeletePresetParams<'p> { pub struct RetrievePresetParams<'p> { /// The ID of the preset to retrieve. pub preset_id: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`upsert_preset`] @@ -37,7 +35,6 @@ pub struct UpsertPresetParams<'p> { pub preset_id: Cow<'p, str>, /// The stopwords set to upsert. pub preset_upsert_schema: models::PresetUpsertSchema<'p>, - pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`delete_preset`] diff --git a/typesense_codegen/src/apis/stemming_api.rs b/typesense_codegen/src/apis/stemming_api.rs index 45ce58c1..e685c624 100644 --- a/typesense_codegen/src/apis/stemming_api.rs +++ b/typesense_codegen/src/apis/stemming_api.rs @@ -10,7 +10,7 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; @@ -19,7 +19,6 @@ use serde::{Deserialize, Serialize, de::Error as _}; pub struct GetStemmingDictionaryParams<'p> { /// The ID of the dictionary to retrieve pub dictionary_id: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`import_stemming_dictionary`] @@ -29,7 +28,6 @@ pub struct ImportStemmingDictionaryParams<'p> { pub id: Cow<'p, str>, /// The JSONL file containing word mappings pub body: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`get_stemming_dictionary`] diff --git a/typesense_codegen/src/apis/stopwords_api.rs b/typesense_codegen/src/apis/stopwords_api.rs index 08cdffc8..00cdc58a 100644 --- a/typesense_codegen/src/apis/stopwords_api.rs +++ b/typesense_codegen/src/apis/stopwords_api.rs @@ -10,7 +10,7 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; @@ -19,7 +19,6 @@ use serde::{Deserialize, Serialize, de::Error as _}; pub struct DeleteStopwordsSetParams<'p> { /// The ID of the stopwords set to delete. pub set_id: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_stopwords_set`] @@ -27,7 +26,6 @@ pub struct DeleteStopwordsSetParams<'p> { pub struct RetrieveStopwordsSetParams<'p> { /// The ID of the stopwords set to retrieve. pub set_id: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`upsert_stopwords_set`] @@ -37,7 +35,6 @@ pub struct UpsertStopwordsSetParams<'p> { pub set_id: Cow<'p, str>, /// The stopwords set to upsert. pub stopwords_set_upsert_schema: models::StopwordsSetUpsertSchema<'p>, - pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`delete_stopwords_set`] diff --git a/typesense_codegen/src/apis/synonyms_api.rs b/typesense_codegen/src/apis/synonyms_api.rs index 9dea9d80..2aff93aa 100644 --- a/typesense_codegen/src/apis/synonyms_api.rs +++ b/typesense_codegen/src/apis/synonyms_api.rs @@ -10,7 +10,7 @@ use super::{ContentType, Error, configuration}; use crate::{apis::ResponseContent, models}; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; @@ -19,7 +19,6 @@ use serde::{Deserialize, Serialize, de::Error as _}; pub struct DeleteSynonymSetParams<'p> { /// The name of the synonym set to delete pub synonym_set_name: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`delete_synonym_set_item`] @@ -29,7 +28,6 @@ pub struct DeleteSynonymSetItemParams<'p> { pub synonym_set_name: Cow<'p, str>, /// The id of the synonym item to delete pub item_id: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_synonym_set`] @@ -37,7 +35,6 @@ pub struct DeleteSynonymSetItemParams<'p> { pub struct RetrieveSynonymSetParams<'p> { /// The name of the synonym set to retrieve pub synonym_set_name: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_synonym_set_item`] @@ -47,7 +44,6 @@ pub struct RetrieveSynonymSetItemParams<'p> { pub synonym_set_name: Cow<'p, str>, /// The id of the synonym item to retrieve pub item_id: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`retrieve_synonym_set_items`] @@ -55,7 +51,6 @@ pub struct RetrieveSynonymSetItemParams<'p> { pub struct RetrieveSynonymSetItemsParams<'p> { /// The name of the synonym set to retrieve items for pub synonym_set_name: Cow<'p, str>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`upsert_synonym_set`] @@ -65,7 +60,6 @@ pub struct UpsertSynonymSetParams<'p> { pub synonym_set_name: Cow<'p, str>, /// The synonym set to be created/updated pub synonym_set_create_schema: models::SynonymSetCreateSchema<'p>, - pub _phantom: PhantomData<&'p ()>, } /// struct for passing parameters to the method [`upsert_synonym_set_item`] @@ -77,7 +71,6 @@ pub struct UpsertSynonymSetItemParams<'p> { pub item_id: Cow<'p, str>, /// The synonym item to be created/updated pub synonym_item_schema: models::SynonymItemSchema<'p>, - pub _phantom: PhantomData<&'p ()>, } /// struct for typed errors of method [`delete_synonym_set`] diff --git a/typesense_codegen/src/models/analytics_event.rs b/typesense_codegen/src/models/analytics_event.rs index fe6617a3..ebfed1e1 100644 --- a/typesense_codegen/src/models/analytics_event.rs +++ b/typesense_codegen/src/models/analytics_event.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -22,8 +22,6 @@ pub struct AnalyticsEvent<'a> { pub event_type: Cow<'a, str>, #[serde(rename = "data")] pub data: Box>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> AnalyticsEvent<'a> { @@ -36,7 +34,6 @@ impl<'a> AnalyticsEvent<'a> { name, event_type, data: Box::new(data), - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/analytics_event_create_response.rs b/typesense_codegen/src/models/analytics_event_create_response.rs index f1969509..9a85e917 100644 --- a/typesense_codegen/src/models/analytics_event_create_response.rs +++ b/typesense_codegen/src/models/analytics_event_create_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/analytics_event_data.rs b/typesense_codegen/src/models/analytics_event_data.rs index 75b536e7..93bf4d58 100644 --- a/typesense_codegen/src/models/analytics_event_data.rs +++ b/typesense_codegen/src/models/analytics_event_data.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; /// AnalyticsEventData : Event payload @@ -25,8 +25,6 @@ pub struct AnalyticsEventData<'a> { pub q: Option>, #[serde(rename = "analytics_tag", skip_serializing_if = "Option::is_none")] pub analytics_tag: Option>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> AnalyticsEventData<'a> { @@ -38,7 +36,6 @@ impl<'a> AnalyticsEventData<'a> { doc_ids: None, q: None, analytics_tag: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/analytics_events_response.rs b/typesense_codegen/src/models/analytics_events_response.rs index ff474b63..01814892 100644 --- a/typesense_codegen/src/models/analytics_events_response.rs +++ b/typesense_codegen/src/models/analytics_events_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/analytics_events_response_events_inner.rs b/typesense_codegen/src/models/analytics_events_response_events_inner.rs index 32cd41de..8ba6e056 100644 --- a/typesense_codegen/src/models/analytics_events_response_events_inner.rs +++ b/typesense_codegen/src/models/analytics_events_response_events_inner.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/analytics_rule.rs b/typesense_codegen/src/models/analytics_rule.rs index 33c5ae15..d6445000 100644 --- a/typesense_codegen/src/models/analytics_rule.rs +++ b/typesense_codegen/src/models/analytics_rule.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/analytics_rule_create.rs b/typesense_codegen/src/models/analytics_rule_create.rs index 39cfdc91..3d289e98 100644 --- a/typesense_codegen/src/models/analytics_rule_create.rs +++ b/typesense_codegen/src/models/analytics_rule_create.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -26,8 +26,6 @@ pub struct AnalyticsRuleCreate<'a> { pub rule_tag: Option>, #[serde(rename = "params", skip_serializing_if = "Option::is_none")] pub params: Option>>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> AnalyticsRuleCreate<'a> { @@ -44,7 +42,6 @@ impl<'a> AnalyticsRuleCreate<'a> { event_type, rule_tag: None, params: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/analytics_rule_create_params.rs b/typesense_codegen/src/models/analytics_rule_create_params.rs index 1ead1648..c1bc721c 100644 --- a/typesense_codegen/src/models/analytics_rule_create_params.rs +++ b/typesense_codegen/src/models/analytics_rule_create_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -34,8 +34,6 @@ pub struct AnalyticsRuleCreateParams<'a> { pub counter_field: Option>, #[serde(rename = "weight", skip_serializing_if = "Option::is_none")] pub weight: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> AnalyticsRuleCreateParams<'a> { @@ -48,7 +46,6 @@ impl<'a> AnalyticsRuleCreateParams<'a> { expand_query: None, counter_field: None, weight: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/analytics_rule_update.rs b/typesense_codegen/src/models/analytics_rule_update.rs index 603ec796..9fa0ac5c 100644 --- a/typesense_codegen/src/models/analytics_rule_update.rs +++ b/typesense_codegen/src/models/analytics_rule_update.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; /// AnalyticsRuleUpdate : Fields allowed to update on an analytics rule @@ -21,8 +21,6 @@ pub struct AnalyticsRuleUpdate<'a> { pub rule_tag: Option>, #[serde(rename = "params", skip_serializing_if = "Option::is_none")] pub params: Option>>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> AnalyticsRuleUpdate<'a> { @@ -32,7 +30,6 @@ impl<'a> AnalyticsRuleUpdate<'a> { name: None, rule_tag: None, params: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/analytics_status.rs b/typesense_codegen/src/models/analytics_status.rs index 97c059fb..f3ccc73d 100644 --- a/typesense_codegen/src/models/analytics_status.rs +++ b/typesense_codegen/src/models/analytics_status.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/api_key.rs b/typesense_codegen/src/models/api_key.rs index f74b7dde..1fc92391 100644 --- a/typesense_codegen/src/models/api_key.rs +++ b/typesense_codegen/src/models/api_key.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/api_key_delete_response.rs b/typesense_codegen/src/models/api_key_delete_response.rs index 77b33e7f..2368fa1f 100644 --- a/typesense_codegen/src/models/api_key_delete_response.rs +++ b/typesense_codegen/src/models/api_key_delete_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/api_key_schema.rs b/typesense_codegen/src/models/api_key_schema.rs index a3ff5463..5a7b7c34 100644 --- a/typesense_codegen/src/models/api_key_schema.rs +++ b/typesense_codegen/src/models/api_key_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -24,8 +24,6 @@ pub struct ApiKeySchema<'a> { pub collections: Vec, #[serde(rename = "expires_at", skip_serializing_if = "Option::is_none")] pub expires_at: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> ApiKeySchema<'a> { @@ -36,7 +34,6 @@ impl<'a> ApiKeySchema<'a> { actions, collections, expires_at: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/api_keys_response.rs b/typesense_codegen/src/models/api_keys_response.rs index fd1cce2b..1ccdd55e 100644 --- a/typesense_codegen/src/models/api_keys_response.rs +++ b/typesense_codegen/src/models/api_keys_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/api_response.rs b/typesense_codegen/src/models/api_response.rs index 9820f874..260faed5 100644 --- a/typesense_codegen/src/models/api_response.rs +++ b/typesense_codegen/src/models/api_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/api_stats_response.rs b/typesense_codegen/src/models/api_stats_response.rs index 5273fbc5..95c104b0 100644 --- a/typesense_codegen/src/models/api_stats_response.rs +++ b/typesense_codegen/src/models/api_stats_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/collection_alias.rs b/typesense_codegen/src/models/collection_alias.rs index d014916a..a8e2fb6b 100644 --- a/typesense_codegen/src/models/collection_alias.rs +++ b/typesense_codegen/src/models/collection_alias.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/collection_alias_schema.rs b/typesense_codegen/src/models/collection_alias_schema.rs index 6f441ea4..332356d4 100644 --- a/typesense_codegen/src/models/collection_alias_schema.rs +++ b/typesense_codegen/src/models/collection_alias_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -17,15 +17,10 @@ pub struct CollectionAliasSchema<'a> { /// Name of the collection you wish to map the alias to #[serde(rename = "collection_name")] pub collection_name: Cow<'a, str>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> CollectionAliasSchema<'a> { pub fn new(collection_name: Cow<'a, str>) -> Self { - Self { - collection_name, - _phantom: PhantomData, - } + Self { collection_name } } } diff --git a/typesense_codegen/src/models/collection_aliases_response.rs b/typesense_codegen/src/models/collection_aliases_response.rs index 7ace9da0..14a05f1f 100644 --- a/typesense_codegen/src/models/collection_aliases_response.rs +++ b/typesense_codegen/src/models/collection_aliases_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/collection_response.rs b/typesense_codegen/src/models/collection_response.rs index a15fc833..422373c3 100644 --- a/typesense_codegen/src/models/collection_response.rs +++ b/typesense_codegen/src/models/collection_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/collection_schema.rs b/typesense_codegen/src/models/collection_schema.rs index d6190424..7269b828 100644 --- a/typesense_codegen/src/models/collection_schema.rs +++ b/typesense_codegen/src/models/collection_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(bon::Builder)] @@ -49,9 +49,6 @@ pub struct CollectionSchema<'a> { /// Optional details about the collection, e.g., when it was created, who created it etc. #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] pub metadata: Option, - #[serde(skip)] - #[builder(default)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> CollectionSchema<'a> { @@ -66,7 +63,6 @@ impl<'a> CollectionSchema<'a> { symbols_to_index: None, voice_query_model: None, metadata: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/collection_update_schema.rs b/typesense_codegen/src/models/collection_update_schema.rs index 387deede..c539a7a4 100644 --- a/typesense_codegen/src/models/collection_update_schema.rs +++ b/typesense_codegen/src/models/collection_update_schema.rs @@ -9,11 +9,11 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CollectionUpdateSchema<'a> { +pub struct CollectionUpdateSchema { /// A list of fields for querying, filtering and faceting #[serde(rename = "fields")] pub fields: Vec, @@ -23,17 +23,14 @@ pub struct CollectionUpdateSchema<'a> { /// Optional details about the collection, e.g., when it was created, who created it etc. #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] pub metadata: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> CollectionUpdateSchema<'a> { +impl CollectionUpdateSchema { pub fn new(fields: Vec) -> Self { Self { fields, synonym_sets: None, metadata: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/conversation_model_create_schema.rs b/typesense_codegen/src/models/conversation_model_create_schema.rs index 0ac56ec0..24f91fd5 100644 --- a/typesense_codegen/src/models/conversation_model_create_schema.rs +++ b/typesense_codegen/src/models/conversation_model_create_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -41,8 +41,6 @@ pub struct ConversationModelCreateSchema<'a> { /// URL of vLLM service #[serde(rename = "vllm_url", skip_serializing_if = "Option::is_none")] pub vllm_url: Option>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> ConversationModelCreateSchema<'a> { @@ -57,7 +55,6 @@ impl<'a> ConversationModelCreateSchema<'a> { ttl: None, max_bytes, vllm_url: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/conversation_model_schema.rs b/typesense_codegen/src/models/conversation_model_schema.rs index c7fc5a7f..f98e4afb 100644 --- a/typesense_codegen/src/models/conversation_model_schema.rs +++ b/typesense_codegen/src/models/conversation_model_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/conversation_model_update_schema.rs b/typesense_codegen/src/models/conversation_model_update_schema.rs index 1a75819c..ef2b55eb 100644 --- a/typesense_codegen/src/models/conversation_model_update_schema.rs +++ b/typesense_codegen/src/models/conversation_model_update_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -41,8 +41,6 @@ pub struct ConversationModelUpdateSchema<'a> { /// URL of vLLM service #[serde(rename = "vllm_url", skip_serializing_if = "Option::is_none")] pub vllm_url: Option>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> ConversationModelUpdateSchema<'a> { @@ -57,7 +55,6 @@ impl<'a> ConversationModelUpdateSchema<'a> { ttl: None, max_bytes: None, vllm_url: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/create_analytics_rule_200_response.rs b/typesense_codegen/src/models/create_analytics_rule_200_response.rs index f2fb5d56..4ccc84b0 100644 --- a/typesense_codegen/src/models/create_analytics_rule_200_response.rs +++ b/typesense_codegen/src/models/create_analytics_rule_200_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs index 14cd754a..db477344 100644 --- a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs +++ b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs index 59c3e416..222a16c5 100644 --- a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs +++ b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/create_analytics_rule_request.rs b/typesense_codegen/src/models/create_analytics_rule_request.rs index 21830411..e1da2636 100644 --- a/typesense_codegen/src/models/create_analytics_rule_request.rs +++ b/typesense_codegen/src/models/create_analytics_rule_request.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/curation_exclude.rs b/typesense_codegen/src/models/curation_exclude.rs index b8b392b6..e8b51706 100644 --- a/typesense_codegen/src/models/curation_exclude.rs +++ b/typesense_codegen/src/models/curation_exclude.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/curation_include.rs b/typesense_codegen/src/models/curation_include.rs index ffcf2ed7..daded9d7 100644 --- a/typesense_codegen/src/models/curation_include.rs +++ b/typesense_codegen/src/models/curation_include.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/curation_item_create_schema.rs b/typesense_codegen/src/models/curation_item_create_schema.rs index 7e0fab6a..430d10f8 100644 --- a/typesense_codegen/src/models/curation_item_create_schema.rs +++ b/typesense_codegen/src/models/curation_item_create_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -58,8 +58,6 @@ pub struct CurationItemCreateSchema<'a> { /// ID of the curation item #[serde(rename = "id", skip_serializing_if = "Option::is_none")] pub id: Option>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> CurationItemCreateSchema<'a> { @@ -78,7 +76,6 @@ impl<'a> CurationItemCreateSchema<'a> { effective_to_ts: None, stop_processing: None, id: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/curation_item_delete_schema.rs b/typesense_codegen/src/models/curation_item_delete_schema.rs index 8b090dab..aab7c170 100644 --- a/typesense_codegen/src/models/curation_item_delete_schema.rs +++ b/typesense_codegen/src/models/curation_item_delete_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/curation_item_schema.rs b/typesense_codegen/src/models/curation_item_schema.rs index aad7260f..a65b2e28 100644 --- a/typesense_codegen/src/models/curation_item_schema.rs +++ b/typesense_codegen/src/models/curation_item_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/curation_rule.rs b/typesense_codegen/src/models/curation_rule.rs index 1f43f409..c1b12eb6 100644 --- a/typesense_codegen/src/models/curation_rule.rs +++ b/typesense_codegen/src/models/curation_rule.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/curation_set_create_schema.rs b/typesense_codegen/src/models/curation_set_create_schema.rs index 49d72211..c8b336c7 100644 --- a/typesense_codegen/src/models/curation_set_create_schema.rs +++ b/typesense_codegen/src/models/curation_set_create_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -20,8 +20,6 @@ pub struct CurationSetCreateSchema<'a> { /// Optional description for the curation set #[serde(rename = "description", skip_serializing_if = "Option::is_none")] pub description: Option>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> CurationSetCreateSchema<'a> { @@ -29,7 +27,6 @@ impl<'a> CurationSetCreateSchema<'a> { Self { items, description: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/curation_set_delete_schema.rs b/typesense_codegen/src/models/curation_set_delete_schema.rs index 5f9e5f1b..46173d2c 100644 --- a/typesense_codegen/src/models/curation_set_delete_schema.rs +++ b/typesense_codegen/src/models/curation_set_delete_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/curation_set_schema.rs b/typesense_codegen/src/models/curation_set_schema.rs index a0523915..6f4d2c87 100644 --- a/typesense_codegen/src/models/curation_set_schema.rs +++ b/typesense_codegen/src/models/curation_set_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/debug_200_response.rs b/typesense_codegen/src/models/debug_200_response.rs index 1faf1752..98f5e97b 100644 --- a/typesense_codegen/src/models/debug_200_response.rs +++ b/typesense_codegen/src/models/debug_200_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/delete_documents_200_response.rs b/typesense_codegen/src/models/delete_documents_200_response.rs index b759bd7f..910dd92e 100644 --- a/typesense_codegen/src/models/delete_documents_200_response.rs +++ b/typesense_codegen/src/models/delete_documents_200_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/delete_documents_parameters.rs b/typesense_codegen/src/models/delete_documents_parameters.rs index 5fa32e89..0a5f3bba 100644 --- a/typesense_codegen/src/models/delete_documents_parameters.rs +++ b/typesense_codegen/src/models/delete_documents_parameters.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -24,8 +24,6 @@ pub struct DeleteDocumentsParameters<'a> { /// When true, removes all documents from the collection while preserving the collection and its schema. #[serde(rename = "truncate", skip_serializing_if = "Option::is_none")] pub truncate: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> DeleteDocumentsParameters<'a> { @@ -35,7 +33,6 @@ impl<'a> DeleteDocumentsParameters<'a> { batch_size: None, ignore_not_found: None, truncate: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/delete_stopwords_set_200_response.rs b/typesense_codegen/src/models/delete_stopwords_set_200_response.rs index a1449698..5e6a405b 100644 --- a/typesense_codegen/src/models/delete_stopwords_set_200_response.rs +++ b/typesense_codegen/src/models/delete_stopwords_set_200_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/dirty_values.rs b/typesense_codegen/src/models/dirty_values.rs index 0963b9f6..e52f06f9 100644 --- a/typesense_codegen/src/models/dirty_values.rs +++ b/typesense_codegen/src/models/dirty_values.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; /// diff --git a/typesense_codegen/src/models/drop_tokens_mode.rs b/typesense_codegen/src/models/drop_tokens_mode.rs index 12e14f36..a336ed96 100644 --- a/typesense_codegen/src/models/drop_tokens_mode.rs +++ b/typesense_codegen/src/models/drop_tokens_mode.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; /// DropTokensMode : Dictates the direction in which the words in the query must be dropped when the original words in the query do not appear in any document. Values: right_to_left (default), left_to_right, both_sides:3 A note on both_sides:3 - for queries up to 3 tokens (words) in length, this mode will drop tokens from both sides and exhaustively rank all matching results. If query length is greater than 3 words, Typesense will just fallback to default behavior of right_to_left diff --git a/typesense_codegen/src/models/export_documents_parameters.rs b/typesense_codegen/src/models/export_documents_parameters.rs index db2a08fc..3dfca404 100644 --- a/typesense_codegen/src/models/export_documents_parameters.rs +++ b/typesense_codegen/src/models/export_documents_parameters.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -23,8 +23,6 @@ pub struct ExportDocumentsParameters<'a> { /// List of fields from the document to exclude in the search result #[serde(rename = "exclude_fields", skip_serializing_if = "Option::is_none")] pub exclude_fields: Option>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> ExportDocumentsParameters<'a> { @@ -33,7 +31,6 @@ impl<'a> ExportDocumentsParameters<'a> { filter_by: None, include_fields: None, exclude_fields: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/facet_counts.rs b/typesense_codegen/src/models/facet_counts.rs index 3535edd4..fd3eca82 100644 --- a/typesense_codegen/src/models/facet_counts.rs +++ b/typesense_codegen/src/models/facet_counts.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/facet_counts_counts_inner.rs b/typesense_codegen/src/models/facet_counts_counts_inner.rs index b65feeb2..7f267224 100644 --- a/typesense_codegen/src/models/facet_counts_counts_inner.rs +++ b/typesense_codegen/src/models/facet_counts_counts_inner.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/facet_counts_stats.rs b/typesense_codegen/src/models/facet_counts_stats.rs index cf654ba5..10b7146a 100644 --- a/typesense_codegen/src/models/facet_counts_stats.rs +++ b/typesense_codegen/src/models/facet_counts_stats.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/field.rs b/typesense_codegen/src/models/field.rs index e7220a1e..b923c39c 100644 --- a/typesense_codegen/src/models/field.rs +++ b/typesense_codegen/src/models/field.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(bon::Builder)] diff --git a/typesense_codegen/src/models/field_embed.rs b/typesense_codegen/src/models/field_embed.rs index 025660b2..bc0cb26c 100644 --- a/typesense_codegen/src/models/field_embed.rs +++ b/typesense_codegen/src/models/field_embed.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/field_embed_model_config.rs b/typesense_codegen/src/models/field_embed_model_config.rs index 4afcdac8..bbe8c0af 100644 --- a/typesense_codegen/src/models/field_embed_model_config.rs +++ b/typesense_codegen/src/models/field_embed_model_config.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/get_collections_parameters.rs b/typesense_codegen/src/models/get_collections_parameters.rs index f7b3a5fa..fbd64183 100644 --- a/typesense_codegen/src/models/get_collections_parameters.rs +++ b/typesense_codegen/src/models/get_collections_parameters.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -23,8 +23,6 @@ pub struct GetCollectionsParameters<'a> { /// Identifies the starting point to return collections when paginating. #[serde(rename = "offset", skip_serializing_if = "Option::is_none")] pub offset: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> GetCollectionsParameters<'a> { @@ -33,7 +31,6 @@ impl<'a> GetCollectionsParameters<'a> { exclude_fields: None, limit: None, offset: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/health_status.rs b/typesense_codegen/src/models/health_status.rs index d0cbb42c..f574fe63 100644 --- a/typesense_codegen/src/models/health_status.rs +++ b/typesense_codegen/src/models/health_status.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/import_documents_parameters.rs b/typesense_codegen/src/models/import_documents_parameters.rs index db226911..b3254512 100644 --- a/typesense_codegen/src/models/import_documents_parameters.rs +++ b/typesense_codegen/src/models/import_documents_parameters.rs @@ -9,11 +9,11 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ImportDocumentsParameters<'a> { +pub struct ImportDocumentsParameters { #[serde(rename = "batch_size", skip_serializing_if = "Option::is_none")] pub batch_size: Option, /// Returning the id of the imported documents. If you want the import response to return the ingested document's id in the response, you can use the return_id parameter. @@ -30,11 +30,9 @@ pub struct ImportDocumentsParameters<'a> { pub action: Option, #[serde(rename = "dirty_values", skip_serializing_if = "Option::is_none")] pub dirty_values: Option, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> ImportDocumentsParameters<'a> { +impl ImportDocumentsParameters { pub fn new() -> Self { Self { batch_size: None, @@ -43,7 +41,6 @@ impl<'a> ImportDocumentsParameters<'a> { return_doc: None, action: None, dirty_values: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/index_action.rs b/typesense_codegen/src/models/index_action.rs index ef739239..0666c875 100644 --- a/typesense_codegen/src/models/index_action.rs +++ b/typesense_codegen/src/models/index_action.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; /// diff --git a/typesense_codegen/src/models/list_stemming_dictionaries_200_response.rs b/typesense_codegen/src/models/list_stemming_dictionaries_200_response.rs index 658047f6..46df5f84 100644 --- a/typesense_codegen/src/models/list_stemming_dictionaries_200_response.rs +++ b/typesense_codegen/src/models/list_stemming_dictionaries_200_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/multi_search_collection_parameters.rs b/typesense_codegen/src/models/multi_search_collection_parameters.rs index 5d5a3e3c..01ad2d47 100644 --- a/typesense_codegen/src/models/multi_search_collection_parameters.rs +++ b/typesense_codegen/src/models/multi_search_collection_parameters.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(bon::Builder)] @@ -274,9 +274,6 @@ pub struct MultiSearchCollectionParameters<'a> { skip_serializing_if = "Option::is_none" )] pub rerank_hybrid_matches: Option, - #[serde(skip)] - #[builder(default)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> MultiSearchCollectionParameters<'a> { @@ -349,7 +346,6 @@ impl<'a> MultiSearchCollectionParameters<'a> { collection: None, x_typesense_api_key: None, rerank_hybrid_matches: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/multi_search_parameters.rs b/typesense_codegen/src/models/multi_search_parameters.rs index c4164753..fba11b2f 100644 --- a/typesense_codegen/src/models/multi_search_parameters.rs +++ b/typesense_codegen/src/models/multi_search_parameters.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; /// MultiSearchParameters : Parameters for the multi search API. @@ -260,9 +260,6 @@ pub struct MultiSearchParameters<'a> { /// The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. #[serde(rename = "conversation_id", skip_serializing_if = "Option::is_none")] pub conversation_id: Option>, - #[serde(skip)] - #[builder(default)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> MultiSearchParameters<'a> { @@ -333,7 +330,6 @@ impl<'a> MultiSearchParameters<'a> { conversation: None, conversation_model_id: None, conversation_id: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/multi_search_result.rs b/typesense_codegen/src/models/multi_search_result.rs index 1f6c9ab5..bf38dc22 100644 --- a/typesense_codegen/src/models/multi_search_result.rs +++ b/typesense_codegen/src/models/multi_search_result.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/multi_search_result_item.rs b/typesense_codegen/src/models/multi_search_result_item.rs index a82c4e0a..b737833b 100644 --- a/typesense_codegen/src/models/multi_search_result_item.rs +++ b/typesense_codegen/src/models/multi_search_result_item.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/multi_search_searches_parameter.rs b/typesense_codegen/src/models/multi_search_searches_parameter.rs index 649f5166..fa55c229 100644 --- a/typesense_codegen/src/models/multi_search_searches_parameter.rs +++ b/typesense_codegen/src/models/multi_search_searches_parameter.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -19,8 +19,6 @@ pub struct MultiSearchSearchesParameter<'a> { pub union: Option, #[serde(rename = "searches")] pub searches: Vec>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> MultiSearchSearchesParameter<'a> { @@ -28,7 +26,6 @@ impl<'a> MultiSearchSearchesParameter<'a> { Self { union: None, searches, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/nl_search_model_base.rs b/typesense_codegen/src/models/nl_search_model_base.rs index 5c297b90..a9b4d931 100644 --- a/typesense_codegen/src/models/nl_search_model_base.rs +++ b/typesense_codegen/src/models/nl_search_model_base.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/nl_search_model_create_schema.rs b/typesense_codegen/src/models/nl_search_model_create_schema.rs index 32882a2c..4c8aff0a 100644 --- a/typesense_codegen/src/models/nl_search_model_create_schema.rs +++ b/typesense_codegen/src/models/nl_search_model_create_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -71,8 +71,6 @@ pub struct NlSearchModelCreateSchema<'a> { /// Optional ID for the NL search model #[serde(rename = "id", skip_serializing_if = "Option::is_none")] pub id: Option>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> NlSearchModelCreateSchema<'a> { @@ -97,7 +95,6 @@ impl<'a> NlSearchModelCreateSchema<'a> { max_output_tokens: None, account_id: None, id: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/nl_search_model_delete_schema.rs b/typesense_codegen/src/models/nl_search_model_delete_schema.rs index 6bed2260..f42e5b9d 100644 --- a/typesense_codegen/src/models/nl_search_model_delete_schema.rs +++ b/typesense_codegen/src/models/nl_search_model_delete_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/nl_search_model_schema.rs b/typesense_codegen/src/models/nl_search_model_schema.rs index 61279b74..37e6beec 100644 --- a/typesense_codegen/src/models/nl_search_model_schema.rs +++ b/typesense_codegen/src/models/nl_search_model_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/preset_delete_schema.rs b/typesense_codegen/src/models/preset_delete_schema.rs index b964ab5b..3c42b6ce 100644 --- a/typesense_codegen/src/models/preset_delete_schema.rs +++ b/typesense_codegen/src/models/preset_delete_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/preset_schema.rs b/typesense_codegen/src/models/preset_schema.rs index 6dfee9d8..6aa6ac60 100644 --- a/typesense_codegen/src/models/preset_schema.rs +++ b/typesense_codegen/src/models/preset_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/preset_upsert_schema.rs b/typesense_codegen/src/models/preset_upsert_schema.rs index b9fb8a05..94bb67c2 100644 --- a/typesense_codegen/src/models/preset_upsert_schema.rs +++ b/typesense_codegen/src/models/preset_upsert_schema.rs @@ -9,22 +9,19 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct PresetUpsertSchema<'a> { #[serde(rename = "value")] pub value: Box>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> PresetUpsertSchema<'a> { pub fn new(value: models::PresetUpsertSchemaValue<'a>) -> Self { Self { value: Box::new(value), - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/preset_upsert_schema_value.rs b/typesense_codegen/src/models/preset_upsert_schema_value.rs index b5800d88..e2aa5cd0 100644 --- a/typesense_codegen/src/models/preset_upsert_schema_value.rs +++ b/typesense_codegen/src/models/preset_upsert_schema_value.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/presets_retrieve_schema.rs b/typesense_codegen/src/models/presets_retrieve_schema.rs index 1da3e0b9..c09f177e 100644 --- a/typesense_codegen/src/models/presets_retrieve_schema.rs +++ b/typesense_codegen/src/models/presets_retrieve_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/schema_change_status.rs b/typesense_codegen/src/models/schema_change_status.rs index d5891f4a..316e3c07 100644 --- a/typesense_codegen/src/models/schema_change_status.rs +++ b/typesense_codegen/src/models/schema_change_status.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/search_grouped_hit.rs b/typesense_codegen/src/models/search_grouped_hit.rs index 4f3fbb3b..841b83b4 100644 --- a/typesense_codegen/src/models/search_grouped_hit.rs +++ b/typesense_codegen/src/models/search_grouped_hit.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/search_highlight.rs b/typesense_codegen/src/models/search_highlight.rs index 728551bb..4f2cef93 100644 --- a/typesense_codegen/src/models/search_highlight.rs +++ b/typesense_codegen/src/models/search_highlight.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/search_parameters.rs b/typesense_codegen/src/models/search_parameters.rs index be6c4052..59e82c3d 100644 --- a/typesense_codegen/src/models/search_parameters.rs +++ b/typesense_codegen/src/models/search_parameters.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(bon::Builder)] @@ -286,9 +286,6 @@ pub struct SearchParameters<'a> { /// The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. #[serde(rename = "conversation_id", skip_serializing_if = "Option::is_none")] pub conversation_id: Option>, - #[serde(skip)] - #[builder(default)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> SearchParameters<'a> { @@ -365,7 +362,6 @@ impl<'a> SearchParameters<'a> { conversation: None, conversation_model_id: None, conversation_id: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/search_request_params.rs b/typesense_codegen/src/models/search_request_params.rs index afc81fb6..4fa0b555 100644 --- a/typesense_codegen/src/models/search_request_params.rs +++ b/typesense_codegen/src/models/search_request_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/search_request_params_voice_query.rs b/typesense_codegen/src/models/search_request_params_voice_query.rs index dcce04d9..fdbd32c9 100644 --- a/typesense_codegen/src/models/search_request_params_voice_query.rs +++ b/typesense_codegen/src/models/search_request_params_voice_query.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/search_result.rs b/typesense_codegen/src/models/search_result.rs index ff29324a..c28ca020 100644 --- a/typesense_codegen/src/models/search_result.rs +++ b/typesense_codegen/src/models/search_result.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/search_result_conversation.rs b/typesense_codegen/src/models/search_result_conversation.rs index ba9e8d33..0de0d6d3 100644 --- a/typesense_codegen/src/models/search_result_conversation.rs +++ b/typesense_codegen/src/models/search_result_conversation.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/search_result_hit.rs b/typesense_codegen/src/models/search_result_hit.rs index fad17641..1cffcd40 100644 --- a/typesense_codegen/src/models/search_result_hit.rs +++ b/typesense_codegen/src/models/search_result_hit.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/search_result_hit_hybrid_search_info.rs b/typesense_codegen/src/models/search_result_hit_hybrid_search_info.rs index db8b0546..15752b72 100644 --- a/typesense_codegen/src/models/search_result_hit_hybrid_search_info.rs +++ b/typesense_codegen/src/models/search_result_hit_hybrid_search_info.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; /// SearchResultHitHybridSearchInfo : Information about hybrid search scoring diff --git a/typesense_codegen/src/models/search_result_hit_text_match_info.rs b/typesense_codegen/src/models/search_result_hit_text_match_info.rs index 70824cf7..3a72de2b 100644 --- a/typesense_codegen/src/models/search_result_hit_text_match_info.rs +++ b/typesense_codegen/src/models/search_result_hit_text_match_info.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/search_synonym.rs b/typesense_codegen/src/models/search_synonym.rs index a568e417..1e91a152 100644 --- a/typesense_codegen/src/models/search_synonym.rs +++ b/typesense_codegen/src/models/search_synonym.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/search_synonym_delete_response.rs b/typesense_codegen/src/models/search_synonym_delete_response.rs index e992247b..7a9db0ae 100644 --- a/typesense_codegen/src/models/search_synonym_delete_response.rs +++ b/typesense_codegen/src/models/search_synonym_delete_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/search_synonym_schema.rs b/typesense_codegen/src/models/search_synonym_schema.rs index 88cf3edb..95c8580e 100644 --- a/typesense_codegen/src/models/search_synonym_schema.rs +++ b/typesense_codegen/src/models/search_synonym_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/search_synonyms_response.rs b/typesense_codegen/src/models/search_synonyms_response.rs index 2b6f8f88..cc877a33 100644 --- a/typesense_codegen/src/models/search_synonyms_response.rs +++ b/typesense_codegen/src/models/search_synonyms_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/stemming_dictionary.rs b/typesense_codegen/src/models/stemming_dictionary.rs index 13efd545..abde86cd 100644 --- a/typesense_codegen/src/models/stemming_dictionary.rs +++ b/typesense_codegen/src/models/stemming_dictionary.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/stemming_dictionary_words_inner.rs b/typesense_codegen/src/models/stemming_dictionary_words_inner.rs index 5d17ba6c..b0fb6051 100644 --- a/typesense_codegen/src/models/stemming_dictionary_words_inner.rs +++ b/typesense_codegen/src/models/stemming_dictionary_words_inner.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/stopwords_set_retrieve_schema.rs b/typesense_codegen/src/models/stopwords_set_retrieve_schema.rs index 514bf354..cb1defc8 100644 --- a/typesense_codegen/src/models/stopwords_set_retrieve_schema.rs +++ b/typesense_codegen/src/models/stopwords_set_retrieve_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/stopwords_set_schema.rs b/typesense_codegen/src/models/stopwords_set_schema.rs index 2a400795..dc7b25d6 100644 --- a/typesense_codegen/src/models/stopwords_set_schema.rs +++ b/typesense_codegen/src/models/stopwords_set_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/stopwords_set_upsert_schema.rs b/typesense_codegen/src/models/stopwords_set_upsert_schema.rs index 0d0a1d83..9e587901 100644 --- a/typesense_codegen/src/models/stopwords_set_upsert_schema.rs +++ b/typesense_codegen/src/models/stopwords_set_upsert_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -18,8 +18,6 @@ pub struct StopwordsSetUpsertSchema<'a> { pub stopwords: Vec, #[serde(rename = "locale", skip_serializing_if = "Option::is_none")] pub locale: Option>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> StopwordsSetUpsertSchema<'a> { @@ -27,7 +25,6 @@ impl<'a> StopwordsSetUpsertSchema<'a> { Self { stopwords, locale: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/stopwords_sets_retrieve_all_schema.rs b/typesense_codegen/src/models/stopwords_sets_retrieve_all_schema.rs index dc4a2f04..9feaf43f 100644 --- a/typesense_codegen/src/models/stopwords_sets_retrieve_all_schema.rs +++ b/typesense_codegen/src/models/stopwords_sets_retrieve_all_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/success_status.rs b/typesense_codegen/src/models/success_status.rs index d671cd28..1472e0eb 100644 --- a/typesense_codegen/src/models/success_status.rs +++ b/typesense_codegen/src/models/success_status.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/synonym_item_delete_schema.rs b/typesense_codegen/src/models/synonym_item_delete_schema.rs index 9cc3360f..70f534aa 100644 --- a/typesense_codegen/src/models/synonym_item_delete_schema.rs +++ b/typesense_codegen/src/models/synonym_item_delete_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/synonym_item_schema.rs b/typesense_codegen/src/models/synonym_item_schema.rs index 03693113..e09ac8b8 100644 --- a/typesense_codegen/src/models/synonym_item_schema.rs +++ b/typesense_codegen/src/models/synonym_item_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -29,8 +29,6 @@ pub struct SynonymItemSchema<'a> { /// By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] pub symbols_to_index: Option>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> SynonymItemSchema<'a> { @@ -41,7 +39,6 @@ impl<'a> SynonymItemSchema<'a> { root: None, locale: None, symbols_to_index: None, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/synonym_set_create_schema.rs b/typesense_codegen/src/models/synonym_set_create_schema.rs index 16539737..7a2b5375 100644 --- a/typesense_codegen/src/models/synonym_set_create_schema.rs +++ b/typesense_codegen/src/models/synonym_set_create_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -17,15 +17,10 @@ pub struct SynonymSetCreateSchema<'a> { /// Array of synonym items #[serde(rename = "items")] pub items: Vec>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> SynonymSetCreateSchema<'a> { pub fn new(items: Vec>) -> Self { - Self { - items, - _phantom: PhantomData, - } + Self { items } } } diff --git a/typesense_codegen/src/models/synonym_set_delete_schema.rs b/typesense_codegen/src/models/synonym_set_delete_schema.rs index b7aa2d96..dc234d21 100644 --- a/typesense_codegen/src/models/synonym_set_delete_schema.rs +++ b/typesense_codegen/src/models/synonym_set_delete_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/synonym_set_schema.rs b/typesense_codegen/src/models/synonym_set_schema.rs index e035355b..b7616d7d 100644 --- a/typesense_codegen/src/models/synonym_set_schema.rs +++ b/typesense_codegen/src/models/synonym_set_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/synonym_sets_retrieve_schema.rs b/typesense_codegen/src/models/synonym_sets_retrieve_schema.rs index d18f21ea..1ca6e04f 100644 --- a/typesense_codegen/src/models/synonym_sets_retrieve_schema.rs +++ b/typesense_codegen/src/models/synonym_sets_retrieve_schema.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/toggle_slow_request_log_request.rs b/typesense_codegen/src/models/toggle_slow_request_log_request.rs index a6fb4956..1507ee4f 100644 --- a/typesense_codegen/src/models/toggle_slow_request_log_request.rs +++ b/typesense_codegen/src/models/toggle_slow_request_log_request.rs @@ -9,22 +9,19 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ToggleSlowRequestLogRequest<'a> { +pub struct ToggleSlowRequestLogRequest { #[serde(rename = "log-slow-requests-time-ms")] pub log_slow_requests_time_ms: i32, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } -impl<'a> ToggleSlowRequestLogRequest<'a> { +impl ToggleSlowRequestLogRequest { pub fn new(log_slow_requests_time_ms: i32) -> Self { Self { log_slow_requests_time_ms, - _phantom: PhantomData, } } } diff --git a/typesense_codegen/src/models/update_documents_200_response.rs b/typesense_codegen/src/models/update_documents_200_response.rs index fd887fc8..0adeb08e 100644 --- a/typesense_codegen/src/models/update_documents_200_response.rs +++ b/typesense_codegen/src/models/update_documents_200_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/typesense_codegen/src/models/update_documents_parameters.rs b/typesense_codegen/src/models/update_documents_parameters.rs index 106aa0d6..f7f7b90f 100644 --- a/typesense_codegen/src/models/update_documents_parameters.rs +++ b/typesense_codegen/src/models/update_documents_parameters.rs @@ -9,22 +9,17 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateDocumentsParameters<'a> { #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] pub filter_by: Option>, - #[serde(skip)] - pub _phantom: PhantomData<&'a ()>, } impl<'a> UpdateDocumentsParameters<'a> { pub fn new() -> Self { - Self { - filter_by: None, - _phantom: PhantomData, - } + Self { filter_by: None } } } diff --git a/typesense_codegen/src/models/voice_query_model_collection_config.rs b/typesense_codegen/src/models/voice_query_model_collection_config.rs index 72b2d8ab..4dca0ba8 100644 --- a/typesense_codegen/src/models/voice_query_model_collection_config.rs +++ b/typesense_codegen/src/models/voice_query_model_collection_config.rs @@ -9,7 +9,7 @@ */ use crate::models; -use ::std::{borrow::Cow, marker::PhantomData}; +use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; /// VoiceQueryModelCollectionConfig : Configuration for the voice query model From 47dfbd1ea1a8333c2a783386ac0b1dbce112bda8 Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Thu, 13 Nov 2025 11:53:11 +0000 Subject: [PATCH 16/17] Rename flag to has-borrowed-data --- openapi-generator-template/model.mustache | 24 +++--- .../reqwest/api.mustache | 4 +- preprocessed_openapi.yml | 82 +++++++++---------- xtask/src/add_vendor_attributes.rs | 2 - xtask/src/preprocess_openapi.rs | 22 ++--- xtask/src/vendor_attributes.rs | 10 +-- 6 files changed, 71 insertions(+), 73 deletions(-) diff --git a/openapi-generator-template/model.mustache b/openapi-generator-template/model.mustache index 9bed530e..ab15a350 100644 --- a/openapi-generator-template/model.mustache +++ b/openapi-generator-template/model.mustache @@ -129,7 +129,7 @@ impl Default for {{classname}} { {{/vendorExtensions.x-rust-builder}}{{! }}{{#vendorExtensions.x-rust-has-byte-array}}#[serde_as]{{/vendorExtensions.x-rust-has-byte-array}}{{! }}{{#oneOf.isEmpty}}#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct {{{classname}}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}{{#vendorExtensions.x-rust-generic-parameter}}<{{{.}}}>{{/vendorExtensions.x-rust-generic-parameter}}{{/vendorExtensions.x-rust-is-used-as-input}} { +pub struct {{{classname}}}{{#vendorExtensions.x-rust-has-borrowed-data}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}>{{/vendorExtensions.x-rust-has-borrowed-data}}{{^vendorExtensions.x-rust-has-borrowed-data}}{{#vendorExtensions.x-rust-generic-parameter}}<{{{.}}}>{{/vendorExtensions.x-rust-generic-parameter}}{{/vendorExtensions.x-rust-has-borrowed-data}} { {{#vars}} {{#description}} /// {{{.}}} @@ -148,15 +148,15 @@ pub struct {{{classname}}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a{{#ven ### Enums }}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{! ### Models - }}{{^isEnum}}{{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{{dataType}}}{{#vendorExtensions.x-rust-is-used-as-input}}{{#model}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}<'static>{{/vendorExtensions.x-rust-is-used-as-input}}{{/model}}{{/vendorExtensions.x-rust-is-used-as-input}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}{{! + }}{{^isEnum}}{{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{{dataType}}}{{#vendorExtensions.x-rust-has-borrowed-data}}{{#model}}{{#vendorExtensions.x-rust-has-borrowed-data}}<'a>{{/vendorExtensions.x-rust-has-borrowed-data}}{{^vendorExtensions.x-rust-has-borrowed-data}}<'static>{{/vendorExtensions.x-rust-has-borrowed-data}}{{/model}}{{/vendorExtensions.x-rust-has-borrowed-data}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}{{! ### ByteArray }}{{^isModel}}{{#isByteArray}}Vec{{/isByteArray}}{{! ### String - }}{{^isByteArray}}{{#isString}}{{#model}}{{#vendorExtensions.x-rust-is-used-as-input}}Cow<'a, str>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}String{{/vendorExtensions.x-rust-is-used-as-input}}{{/model}}{{/isString}}{{! + }}{{^isByteArray}}{{#isString}}{{#model}}{{#vendorExtensions.x-rust-has-borrowed-data}}Cow<'a, str>{{/vendorExtensions.x-rust-has-borrowed-data}}{{^vendorExtensions.x-rust-has-borrowed-data}}String{{/vendorExtensions.x-rust-has-borrowed-data}}{{/model}}{{/isString}}{{! ### Arrays }}{{^isString}}{{#isArray}}Vec<{{#items}}{{! ### Array Models - }}{{#isModel}}{{{dataType}}}{{#vendorExtensions.x-rust-is-used-as-input}}{{#model}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}<'static>{{/vendorExtensions.x-rust-is-used-as-input}}{{/model}}{{/vendorExtensions.x-rust-is-used-as-input}}{{/isModel}}{{! + }}{{#isModel}}{{{dataType}}}{{#vendorExtensions.x-rust-has-borrowed-data}}{{#model}}{{#vendorExtensions.x-rust-has-borrowed-data}}<'a>{{/vendorExtensions.x-rust-has-borrowed-data}}{{^vendorExtensions.x-rust-has-borrowed-data}}<'static>{{/vendorExtensions.x-rust-has-borrowed-data}}{{/model}}{{/vendorExtensions.x-rust-has-borrowed-data}}{{/isModel}}{{! ### Array other datatypes }}{{^isModel}}{{{dataType}}}{{/isModel}}{{/items}}>{{/isArray}}{{! ### Primitive datatypes @@ -171,8 +171,8 @@ pub struct {{{classname}}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a{{#ven {{/vars}} } -impl{{#vendorExtensions.x-rust-is-used-as-input}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}{{#vendorExtensions.x-rust-generic-parameter}}<{{{.}}}>{{/vendorExtensions.x-rust-generic-parameter}}{{/vendorExtensions.x-rust-is-used-as-input}} {{! - }}{{{classname}}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}{{#vendorExtensions.x-rust-generic-parameter}}<{{{.}}}>{{/vendorExtensions.x-rust-generic-parameter}}{{/vendorExtensions.x-rust-is-used-as-input}} { +impl{{#vendorExtensions.x-rust-has-borrowed-data}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}>{{/vendorExtensions.x-rust-has-borrowed-data}}{{^vendorExtensions.x-rust-has-borrowed-data}}{{#vendorExtensions.x-rust-generic-parameter}}<{{{.}}}>{{/vendorExtensions.x-rust-generic-parameter}}{{/vendorExtensions.x-rust-has-borrowed-data}} {{! + }}{{{classname}}}{{#vendorExtensions.x-rust-has-borrowed-data}}<'a{{#vendorExtensions.x-rust-generic-parameter}}, {{{.}}}{{/vendorExtensions.x-rust-generic-parameter}}>{{/vendorExtensions.x-rust-has-borrowed-data}}{{^vendorExtensions.x-rust-has-borrowed-data}}{{#vendorExtensions.x-rust-generic-parameter}}<{{{.}}}>{{/vendorExtensions.x-rust-generic-parameter}}{{/vendorExtensions.x-rust-has-borrowed-data}} { {{#description}} /// {{{.}}} {{/description}} @@ -183,11 +183,11 @@ impl{{#vendorExtensions.x-rust-is-used-as-input}}<'a{{#vendorExtensions.x-rust-g }}{{^vendorExtensions.x-rust-type}}{{#isNullable}}Option<{{/isNullable}}{{! }}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{! }}{{^isEnum}}{{#isByteArray}}Vec{{/isByteArray}}{{! - }}{{^isByteArray}}{{#isString}}{{#model}}{{#vendorExtensions.x-rust-is-used-as-input}}Cow<'a, str>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}String{{/vendorExtensions.x-rust-is-used-as-input}}{{/model}}{{/isString}}{{! + }}{{^isByteArray}}{{#isString}}{{#model}}{{#vendorExtensions.x-rust-has-borrowed-data}}Cow<'a, str>{{/vendorExtensions.x-rust-has-borrowed-data}}{{^vendorExtensions.x-rust-has-borrowed-data}}String{{/vendorExtensions.x-rust-has-borrowed-data}}{{/model}}{{/isString}}{{! }}{{^isString}}{{#isArray}}Vec<{{#items}}{{! - }}{{#isModel}}{{{dataType}}}{{#vendorExtensions.x-rust-is-used-as-input}}{{#model}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}<'static>{{/vendorExtensions.x-rust-is-used-as-input}}{{/model}}{{/vendorExtensions.x-rust-is-used-as-input}}{{/isModel}}{{! + }}{{#isModel}}{{{dataType}}}{{#vendorExtensions.x-rust-has-borrowed-data}}{{#model}}{{#vendorExtensions.x-rust-has-borrowed-data}}<'a>{{/vendorExtensions.x-rust-has-borrowed-data}}{{^vendorExtensions.x-rust-has-borrowed-data}}<'static>{{/vendorExtensions.x-rust-has-borrowed-data}}{{/model}}{{/vendorExtensions.x-rust-has-borrowed-data}}{{/isModel}}{{! }}{{^isModel}}{{{dataType}}}{{/isModel}}{{/items}}>{{/isArray}}{{! - }}{{^isArray}}{{{dataType}}}{{#isModel}}{{#vendorExtensions.x-rust-is-used-as-input}}{{#model}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a>{{/vendorExtensions.x-rust-is-used-as-input}}{{^vendorExtensions.x-rust-is-used-as-input}}<'static>{{/vendorExtensions.x-rust-is-used-as-input}}{{/model}}{{/vendorExtensions.x-rust-is-used-as-input}}{{/isModel}}{{! + }}{{^isArray}}{{{dataType}}}{{#isModel}}{{#vendorExtensions.x-rust-has-borrowed-data}}{{#model}}{{#vendorExtensions.x-rust-has-borrowed-data}}<'a>{{/vendorExtensions.x-rust-has-borrowed-data}}{{^vendorExtensions.x-rust-has-borrowed-data}}<'static>{{/vendorExtensions.x-rust-has-borrowed-data}}{{/model}}{{/vendorExtensions.x-rust-has-borrowed-data}}{{/isModel}}{{! }}{{/isArray}}{{/isString}}{{/isByteArray}}{{/isEnum}}{{! }}{{#isNullable}}>{{/isNullable}}{{/vendorExtensions.x-rust-type}}{{! ### Comma for next arguement @@ -218,16 +218,16 @@ impl{{#vendorExtensions.x-rust-is-used-as-input}}<'a{{#vendorExtensions.x-rust-g {{/description}} #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum {{classname}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a>{{/vendorExtensions.x-rust-is-used-as-input}} { +pub enum {{classname}}{{#vendorExtensions.x-rust-has-borrowed-data}}<'a>{{/vendorExtensions.x-rust-has-borrowed-data}} { {{#composedSchemas.oneOf}} {{#description}} /// {{{.}}} {{/description}} - {{{name}}}({{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{/isModel}}{{#isArray}}Vec<{{{items.dataType}}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a>{{/vendorExtensions.x-rust-is-used-as-input}}>{{/isArray}}{{^isArray}}{{{dataType}}}{{#vendorExtensions.x-rust-is-used-as-input}}<'a>{{/vendorExtensions.x-rust-is-used-as-input}}{{/isArray}}{{#isModel}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}), + {{{name}}}({{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{/isModel}}{{#isArray}}Vec<{{{items.dataType}}}{{#vendorExtensions.x-rust-has-borrowed-data}}<'a>{{/vendorExtensions.x-rust-has-borrowed-data}}>{{/isArray}}{{^isArray}}{{{dataType}}}{{#vendorExtensions.x-rust-has-borrowed-data}}<'a>{{/vendorExtensions.x-rust-has-borrowed-data}}{{/isArray}}{{#isModel}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}), {{/composedSchemas.oneOf}} } -impl Default for {{classname}}{{#vendorExtensions.x-rust-is-used-as-input}}<'_>{{/vendorExtensions.x-rust-is-used-as-input}} { +impl Default for {{classname}}{{#vendorExtensions.x-rust-has-borrowed-data}}<'_>{{/vendorExtensions.x-rust-has-borrowed-data}} { fn default() -> Self { {{#composedSchemas.oneOf}}{{#-first}}Self::{{{name}}}(Default::default()){{/-first}}{{/composedSchemas.oneOf}} } diff --git a/openapi-generator-template/reqwest/api.mustache b/openapi-generator-template/reqwest/api.mustache index c6dbc9a4..038480e2 100644 --- a/openapi-generator-template/reqwest/api.mustache +++ b/openapi-generator-template/reqwest/api.mustache @@ -114,8 +114,8 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}{{#vendorExtensi }}{{#isResponseFile}}{{#supportAsync}}reqwest::Response{{/supportAsync}}{{^supportAsync}}reqwest::blocking::Response{{/supportAsync}}{{/isResponseFile}}{{! }}{{^isResponseFile}}{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{^supportMultipleResponses}}{{! }}{{^returnType}}(){{/returnType}}{{! -}}{{#isArray}}Vec<{{#returnProperty.items}}{{{dataType}}}{{#isModel}}{{#vendorExtensions.x-rust-is-used-as-input}}<'static>{{/vendorExtensions.x-rust-is-used-as-input}}{{/isModel}}{{/returnProperty.items}}>{{/isArray}}{{! -}}{{^isArray}}{{#returnProperty}}{{{dataType}}}{{#isModel}}{{#vendorExtensions.x-rust-is-used-as-input}}<'static>{{/vendorExtensions.x-rust-is-used-as-input}}{{/isModel}}{{/returnProperty}}{{! +}}{{#isArray}}Vec<{{#returnProperty.items}}{{{dataType}}}{{#isModel}}{{#vendorExtensions.x-rust-has-borrowed-data}}<'static>{{/vendorExtensions.x-rust-has-borrowed-data}}{{/isModel}}{{/returnProperty.items}}>{{/isArray}}{{! +}}{{^isArray}}{{#returnProperty}}{{{dataType}}}{{#isModel}}{{#vendorExtensions.x-rust-has-borrowed-data}}<'static>{{/vendorExtensions.x-rust-has-borrowed-data}}{{/isModel}}{{/returnProperty}}{{! }}{{/isArray}}{{/supportMultipleResponses}}{{/isResponseFile}}{{/vendorExtensions.x-rust-return-type}}, Error<{{{operationIdCamelCase}}}Error>> { {{/vendorExtensions.x-group-parameters}} let uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode(&{{/isString}}{{{vendorExtensions.x-rust-param-identifier}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isArray}}.join(",").as_ref(){{/isArray}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}.to_string(){{/isContainer}}{{/isPrimitiveType}}{{/isUuid}}{{/isString}}{{#isString}}){{/isString}}{{/pathParams}}); diff --git a/preprocessed_openapi.yml b/preprocessed_openapi.yml index 627f7daf..fad52d63 100644 --- a/preprocessed_openapi.yml +++ b/preprocessed_openapi.yml @@ -278,7 +278,7 @@ paths: type: object description: Can be any key-value pair x-go-type: interface{} - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true responses: '201': description: Document successfully created/indexed @@ -320,7 +320,7 @@ paths: type: object description: Can be any key-value pair x-go-type: interface{} - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true x-rust-params-generic-parameter: B x-rust-type: B responses: @@ -1502,7 +1502,7 @@ paths: type: object description: Can be any key-value pair x-go-type: interface{} - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true x-rust-params-generic-parameter: B x-rust-type: B responses: @@ -2000,7 +2000,7 @@ paths: properties: log-slow-requests-time-ms: type: integer - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true responses: '200': description: Compacting the on-disk database succeeded. @@ -2517,7 +2517,7 @@ paths: - type: array items: $ref: '#/components/schemas/AnalyticsRuleCreate' - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true responses: '200': description: Analytics rule(s) successfully created @@ -3182,9 +3182,9 @@ components: type: object description: | Optional details about the collection, e.g., when it was created, who created it etc. - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true x-rust-builder: true - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true CollectionUpdateSchema: type: object required: @@ -3215,8 +3215,8 @@ components: type: object description: | Optional details about the collection, e.g., when it was created, who created it etc. - x-rust-is-used-as-input: true - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true + x-rust-has-borrowed-data: true CollectionResponse: allOf: - $ref: '#/components/schemas/CollectionSchema' @@ -3367,7 +3367,7 @@ components: collection_name: type: string description: Name of the collection you wish to map the alias to - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true CollectionAlias: type: object required: @@ -3711,7 +3711,7 @@ components: expires_at: type: integer format: int64 - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true ApiKey: allOf: - $ref: '#/components/schemas/ApiKeySchema' @@ -4043,7 +4043,7 @@ components: description: | The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. x-rust-builder: true - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true MultiSearchParameters: type: object description: | @@ -4294,7 +4294,7 @@ components: description: | The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. x-rust-builder: true - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true MultiSearchSearchesParameter: type: object required: @@ -4308,7 +4308,7 @@ components: type: array items: $ref: '#/components/schemas/MultiSearchCollectionParameters' - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true MultiSearchCollectionParameters: allOf: - $ref: '#/components/schemas/MultiSearchParameters' @@ -4327,7 +4327,7 @@ components: When true, computes both text match and vector distance scores for all matches in hybrid search. Documents found only through keyword search will get a vector distance score, and documents found only through vector search will get a text match score. default: false x-rust-builder: true - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true FacetCounts: type: object properties: @@ -4399,8 +4399,8 @@ components: type: string analytics_tag: type: string - x-rust-is-used-as-input: true - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true + x-rust-has-borrowed-data: true AnalyticsEventsResponse: type: object required: @@ -4472,8 +4472,8 @@ components: type: string weight: type: integer - x-rust-is-used-as-input: true - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true + x-rust-has-borrowed-data: true AnalyticsRuleUpdate: type: object description: Fields allowed to update on an analytics rule @@ -4501,8 +4501,8 @@ components: type: string weight: type: integer - x-rust-is-used-as-input: true - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true + x-rust-has-borrowed-data: true AnalyticsRule: allOf: - $ref: '#/components/schemas/AnalyticsRuleCreate' @@ -4579,7 +4579,7 @@ components: type: string locale: type: string - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true StopwordsSetSchema: type: object required: @@ -4624,8 +4624,8 @@ components: oneOf: - $ref: '#/components/schemas/SearchParameters' - $ref: '#/components/schemas/MultiSearchSearchesParameter' - x-rust-is-used-as-input: true - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true + x-rust-has-borrowed-data: true PresetSchema: allOf: - $ref: '#/components/schemas/PresetUpsertSchema' @@ -4659,7 +4659,7 @@ components: - coerce_or_drop - drop - reject - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true IndexAction: type: string enum: @@ -4667,7 +4667,7 @@ components: - update - upsert - emplace - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true DropTokensMode: type: string description: | @@ -4676,7 +4676,7 @@ components: - right_to_left - left_to_right - both_sides:3 - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true ConversationModelCreateSchema: required: - model_name @@ -4699,7 +4699,7 @@ components: history_collection: type: string description: Typesense collection that stores the historical conversations - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true ConversationModelUpdateSchema: type: object properties: @@ -4732,7 +4732,7 @@ components: vllm_url: type: string description: URL of vLLM service - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true ConversationModelSchema: allOf: - $ref: '#/components/schemas/ConversationModelCreateSchema' @@ -4837,7 +4837,7 @@ components: id: type: string description: Optional ID for the NL search model - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true NLSearchModelSchema: allOf: - $ref: '#/components/schemas/NLSearchModelCreateSchema' @@ -4850,7 +4850,7 @@ components: description: ID of the NL search model NLSearchModelUpdateSchema: $ref: '#/components/schemas/NLSearchModelCreateSchema' - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true NLSearchModelDeleteSchema: type: object required: @@ -4884,7 +4884,7 @@ components: description: By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is items: type: string - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true SynonymSetCreateSchema: type: object required: @@ -4895,7 +4895,7 @@ components: description: Array of synonym items items: $ref: '#/components/schemas/SynonymItemSchema' - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true SynonymSetSchema: allOf: - $ref: '#/components/schemas/SynonymSetCreateSchema' @@ -4963,7 +4963,7 @@ components: type: object description: | Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered. - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true sort_by: type: string description: | @@ -4991,7 +4991,7 @@ components: id: type: string description: ID of the curation item - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true CurationItemSchema: allOf: - $ref: '#/components/schemas/CurationItemCreateSchema' @@ -5014,7 +5014,7 @@ components: description: type: string description: Optional description for the curation set - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true CurationSetSchema: allOf: - $ref: '#/components/schemas/CurationSetCreateSchema' @@ -5100,7 +5100,7 @@ components: $ref: '#/components/schemas/IndexAction' dirty_values: $ref: '#/components/schemas/DirtyValues' - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true ExportDocumentsParameters: type: object properties: @@ -5113,14 +5113,14 @@ components: exclude_fields: type: string description: List of fields from the document to exclude in the search result - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true UpdateDocumentsParameters: type: object properties: filter_by: type: string example: 'num_employees:>100 && country: [USA, UK]' - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true DeleteDocumentsParameters: type: object required: @@ -5137,7 +5137,7 @@ components: truncate: type: boolean description: When true, removes all documents from the collection while preserving the collection and its schema. - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true GetCollectionsParameters: type: object properties: @@ -5151,7 +5151,7 @@ components: offset: type: integer description: Identifies the starting point to return collections when paginating. - x-rust-is-used-as-input: true + x-rust-has-borrowed-data: true securitySchemes: api_key_header: type: apiKey diff --git a/xtask/src/add_vendor_attributes.rs b/xtask/src/add_vendor_attributes.rs index 25612080..7a76054e 100644 --- a/xtask/src/add_vendor_attributes.rs +++ b/xtask/src/add_vendor_attributes.rs @@ -84,7 +84,5 @@ pub fn add_vendor_attributes(doc: &mut OpenAPI) -> Result<(), String> { .params_generic_parameter("B")? .request_type("B")?; - // attrs.schemas_mark_owned_data()?; - Ok(()) } diff --git a/xtask/src/preprocess_openapi.rs b/xtask/src/preprocess_openapi.rs index 2fb8990a..0e858d77 100644 --- a/xtask/src/preprocess_openapi.rs +++ b/xtask/src/preprocess_openapi.rs @@ -28,7 +28,6 @@ pub(crate) struct OpenAPI { pub(crate) extra: IndexMap, } -// PATHS pub(crate) type OpenAPIPath = IndexMap; #[derive(Clone, Debug, Default, Serialize, Deserialize)] @@ -99,7 +98,6 @@ pub(crate) struct OpenAPIParameter { pub(crate) extra: IndexMap, } -// COMPONENTS #[derive(Clone, Debug, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub(crate) struct OpenAPIComponents { @@ -195,7 +193,7 @@ pub fn preprocess_openapi_file( "getCollectionsParameters", Some("GetCollectionsParameters"), )?; - schemas_mark_owned_data(&mut doc); + schemas_mark_borrowed_data(&mut doc); println!("Preprocessing complete."); // --- Step 3: Serialize the modified spec and write to the output file --- @@ -229,7 +227,9 @@ fn collect_property(prop: &OpenAPIProperty) -> Vec { data } -fn schemas_mark_owned_data(doc: &mut OpenAPI) { +fn schemas_mark_borrowed_data(doc: &mut OpenAPI) { + println!("Marking borrowed data..."); + let mut request_schemas = HashSet::new(); doc.paths.iter_mut().for_each(|(_, pms)| { pms.iter_mut().for_each(|(_, pm)| { @@ -238,7 +238,7 @@ fn schemas_mark_owned_data(doc: &mut OpenAPI) { if let Some(s) = &mut p.schema { if s.r#type.as_deref() == Some("object") || s.one_of.is_some() { s.extra - .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); + .insert("x-rust-has-borrowed-data".to_owned(), Value::Bool(true)); } request_schemas.extend(collect_property(s)); } @@ -252,7 +252,7 @@ fn schemas_mark_owned_data(doc: &mut OpenAPI) { if let Some(s) = &mut c.schema { if s.r#type.as_deref() == Some("object") || s.one_of.is_some() { s.extra - .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); + .insert("x-rust-has-borrowed-data".to_owned(), Value::Bool(true)); } request_schemas.extend(collect_property(s)); } @@ -277,7 +277,7 @@ fn schemas_mark_owned_data(doc: &mut OpenAPI) { schema .extra - .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); + .insert("x-rust-has-borrowed-data".to_owned(), Value::Bool(true)); for (_, prop) in schema.properties.iter_mut().flat_map(|v| v.iter_mut()) { for inner in prop.one_of.iter_mut().flat_map(|v| v.iter_mut()) { @@ -286,7 +286,7 @@ fn schemas_mark_owned_data(doc: &mut OpenAPI) { } inner .extra - .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); + .insert("x-rust-has-borrowed-data".to_owned(), Value::Bool(true)); } for inner in prop.any_of.iter_mut().flat_map(|v| v.iter_mut()) { if inner.r#type.as_deref() != Some("object") && inner.one_of.is_none() { @@ -294,21 +294,21 @@ fn schemas_mark_owned_data(doc: &mut OpenAPI) { } inner .extra - .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); + .insert("x-rust-has-borrowed-data".to_owned(), Value::Bool(true)); } if let Some(inner) = &mut prop.items && (inner.r#type.as_deref() == Some("object") || inner.one_of.is_some()) { inner .extra - .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); + .insert("x-rust-has-borrowed-data".to_owned(), Value::Bool(true)); } if prop.r#type.as_deref() != Some("object") && prop.one_of.is_none() { continue; } prop.extra - .insert("x-rust-is-used-as-input".to_owned(), Value::Bool(true)); + .insert("x-rust-has-borrowed-data".to_owned(), Value::Bool(true)); } } } diff --git a/xtask/src/vendor_attributes.rs b/xtask/src/vendor_attributes.rs index 132d8183..3c90f814 100644 --- a/xtask/src/vendor_attributes.rs +++ b/xtask/src/vendor_attributes.rs @@ -116,7 +116,7 @@ impl<'a, 'b> OperationContext<'a, 'b> { } fn try_set_request_body(&mut self, attr: &str, val: Value) -> Result<&mut Self, String> { - let method = &mut self + let req = &mut self .vendor .doc .paths @@ -125,14 +125,14 @@ impl<'a, 'b> OperationContext<'a, 'b> { .get_mut(self.method) .ok_or_else(|| format!("operation method not found: {}.{}", self.path, self.method))? .request_body; - let method = match method { + let req = match req { Some(v) => v, None => { - *method = Some(Default::default()); - method.as_mut().unwrap() + *req = Some(Default::default()); + req.as_mut().unwrap() } }; - method.extra.insert(attr.to_owned(), val); + req.extra.insert(attr.to_owned(), val); Ok(self) } From 563e2029ff1b48d7349b540cee2973e99f6b3f8a Mon Sep 17 00:00:00 2001 From: RoDmitry Date: Thu, 13 Nov 2025 12:19:43 +0000 Subject: [PATCH 17/17] Refactor --- typesense/tests/client/collections_test.rs | 2 +- .../tests/client/derive_integration_test.rs | 2 +- typesense/tests/client/documents_test.rs | 2 +- xtask/src/preprocess_openapi.rs | 494 +++++++++--------- 4 files changed, 242 insertions(+), 258 deletions(-) diff --git a/typesense/tests/client/collections_test.rs b/typesense/tests/client/collections_test.rs index 1c7fa33a..7c2ba470 100644 --- a/typesense/tests/client/collections_test.rs +++ b/typesense/tests/client/collections_test.rs @@ -10,7 +10,7 @@ async fn logic_test_collections_and_collection_lifecycle() { // --- 1. Create a Collection (via `collections`) --- let schema = CollectionSchema { - name: collection_name.clone().into(), + name: collection_name.as_str().into(), fields: vec![ Field { name: "name".into(), diff --git a/typesense/tests/client/derive_integration_test.rs b/typesense/tests/client/derive_integration_test.rs index fb07fef1..ef0c14a3 100644 --- a/typesense/tests/client/derive_integration_test.rs +++ b/typesense/tests/client/derive_integration_test.rs @@ -143,7 +143,7 @@ async fn logic_test_derive_macro_with_generic_client_lifecycle() { let actual_fields_map: std::collections::HashMap = retrieved_schema .fields .into_iter() - .map(|f| (f.name.clone().into(), f)) + .map(|f| (f.name.clone(), f)) .collect(); // Iterate through our *expected* fields and assert only the attributes we set. diff --git a/typesense/tests/client/documents_test.rs b/typesense/tests/client/documents_test.rs index 8469ca33..474c1c33 100644 --- a/typesense/tests/client/documents_test.rs +++ b/typesense/tests/client/documents_test.rs @@ -14,7 +14,7 @@ async fn run_test_schemaless_document_lifecycle() { // --- Setup: Create a Collection --- let schema = CollectionSchema { - name: collection_name.clone().into(), + name: collection_name.as_str().into(), fields: vec![ Field { name: "title".into(), diff --git a/xtask/src/preprocess_openapi.rs b/xtask/src/preprocess_openapi.rs index 0e858d77..38be8302 100644 --- a/xtask/src/preprocess_openapi.rs +++ b/xtask/src/preprocess_openapi.rs @@ -156,44 +156,39 @@ pub fn preprocess_openapi_file( add_vendor_attributes(&mut doc)?; println!("Unwrapping parameters..."); - unwrap_search_parameters(&mut doc)?; - unwrap_multi_search_parameters(&mut doc)?; - unwrap_parameters_by_path( - &mut doc, + doc.unwrap_search_parameters()?; + doc.unwrap_multi_search_parameters()?; + doc.unwrap_parameters_by_path( "/collections/{collectionName}/documents/import", "post", "importDocumentsParameters", Some("ImportDocumentsParameters"), // Copy schema to components )?; - unwrap_parameters_by_path( - &mut doc, + doc.unwrap_parameters_by_path( "/collections/{collectionName}/documents/export", "get", "exportDocumentsParameters", Some("ExportDocumentsParameters"), )?; - unwrap_parameters_by_path( - &mut doc, + doc.unwrap_parameters_by_path( "/collections/{collectionName}/documents", "patch", "updateDocumentsParameters", Some("UpdateDocumentsParameters"), )?; - unwrap_parameters_by_path( - &mut doc, + doc.unwrap_parameters_by_path( "/collections/{collectionName}/documents", "delete", "deleteDocumentsParameters", Some("DeleteDocumentsParameters"), )?; - unwrap_parameters_by_path( - &mut doc, + doc.unwrap_parameters_by_path( "/collections", "get", "getCollectionsParameters", Some("GetCollectionsParameters"), )?; - schemas_mark_borrowed_data(&mut doc); + doc.mark_borrowed_data(); println!("Preprocessing complete."); // --- Step 3: Serialize the modified spec and write to the output file --- @@ -206,278 +201,267 @@ pub fn preprocess_openapi_file( Ok(()) } -fn collect_property(prop: &OpenAPIProperty) -> Vec { - let mut data = Vec::new(); - if let Some(schema) = &prop.r#ref { - data.push( - schema - .trim_start_matches("#/components/schemas/") - .to_owned(), - ); - } - if let Some(p) = &prop.items { - data.extend(collect_property(p)); - } - if let Some(v) = &prop.any_of { - v.iter().for_each(|p| data.extend(collect_property(p))); +impl OpenAPIProperty { + fn collect_properties(&self) -> Vec { + let mut data = Vec::new(); + if let Some(schema) = &self.r#ref { + data.push( + schema + .trim_start_matches("#/components/schemas/") + .to_owned(), + ); + } + if let Some(p) = &self.items { + data.extend(p.collect_properties()); + } + if let Some(v) = &self.any_of { + v.iter().for_each(|p| data.extend(p.collect_properties())); + } + if let Some(v) = &self.one_of { + v.iter().for_each(|p| data.extend(p.collect_properties())); + } + data } - if let Some(v) = &prop.one_of { - v.iter().for_each(|p| data.extend(collect_property(p))); + + fn mark_borrowed_property(&mut self) { + if self.r#type.as_deref() == Some("object") || self.one_of.is_some() { + self.extra + .insert("x-rust-has-borrowed-data".to_owned(), Value::Bool(true)); + } } - data } -fn schemas_mark_borrowed_data(doc: &mut OpenAPI) { - println!("Marking borrowed data..."); - - let mut request_schemas = HashSet::new(); - doc.paths.iter_mut().for_each(|(_, pms)| { - pms.iter_mut().for_each(|(_, pm)| { - if let Some(ps) = &mut pm.parameters { - ps.iter_mut().for_each(|p| { - if let Some(s) = &mut p.schema { - if s.r#type.as_deref() == Some("object") || s.one_of.is_some() { - s.extra - .insert("x-rust-has-borrowed-data".to_owned(), Value::Bool(true)); +impl OpenAPI { + fn mark_borrowed_data(&mut self) { + println!("Marking borrowed data..."); + + let mut request_schemas = HashSet::new(); + self.paths.iter_mut().for_each(|(_, pms)| { + pms.iter_mut().for_each(|(_, pm)| { + if let Some(ps) = &mut pm.parameters { + ps.iter_mut().for_each(|p| { + if let Some(s) = &mut p.schema { + s.mark_borrowed_property(); + request_schemas.extend(s.collect_properties()); } - request_schemas.extend(collect_property(s)); - } - }) - } + }) + } - if let Some(reqb) = &mut pm.request_body - && let Some(cs) = &mut reqb.content - { - cs.iter_mut().for_each(|(_, c)| { - if let Some(s) = &mut c.schema { - if s.r#type.as_deref() == Some("object") || s.one_of.is_some() { - s.extra - .insert("x-rust-has-borrowed-data".to_owned(), Value::Bool(true)); + if let Some(reqb) = &mut pm.request_body + && let Some(cs) = &mut reqb.content + { + cs.iter_mut().for_each(|(_, c)| { + if let Some(s) = &mut c.schema { + s.mark_borrowed_property(); + request_schemas.extend(s.collect_properties()); } - request_schemas.extend(collect_property(s)); - } - }) - } - }) - }); - - let schemas = doc - .components - .schemas - .iter() - .filter(|(n, _)| n.ends_with("Parameters") || request_schemas.contains(n.as_str())) - .map(|(n, _)| n.to_owned()) - .collect::>(); - drop(request_schemas); - - for schema_name in schemas { - let Some(schema) = doc.components.schemas.get_mut(&schema_name) else { - continue; - }; - - schema - .extra - .insert("x-rust-has-borrowed-data".to_owned(), Value::Bool(true)); - - for (_, prop) in schema.properties.iter_mut().flat_map(|v| v.iter_mut()) { - for inner in prop.one_of.iter_mut().flat_map(|v| v.iter_mut()) { - if inner.r#type.as_deref() != Some("object") && inner.one_of.is_none() { - continue; - } - inner - .extra - .insert("x-rust-has-borrowed-data".to_owned(), Value::Bool(true)); - } - for inner in prop.any_of.iter_mut().flat_map(|v| v.iter_mut()) { - if inner.r#type.as_deref() != Some("object") && inner.one_of.is_none() { - continue; + }) } - inner - .extra - .insert("x-rust-has-borrowed-data".to_owned(), Value::Bool(true)); - } - if let Some(inner) = &mut prop.items - && (inner.r#type.as_deref() == Some("object") || inner.one_of.is_some()) - { - inner - .extra - .insert("x-rust-has-borrowed-data".to_owned(), Value::Bool(true)); - } + }) + }); - if prop.r#type.as_deref() != Some("object") && prop.one_of.is_none() { + let schemas = self + .components + .schemas + .iter() + .filter(|(n, _)| n.ends_with("Parameters") || request_schemas.contains(n.as_str())) + .map(|(n, _)| n.to_owned()) + .collect::>(); + drop(request_schemas); + + for schema_name in schemas { + let Some(schema) = self.components.schemas.get_mut(&schema_name) else { continue; - } - prop.extra + }; + + schema + .extra .insert("x-rust-has-borrowed-data".to_owned(), Value::Bool(true)); + + for (_, prop) in schema.properties.iter_mut().flat_map(|v| v.iter_mut()) { + for inner in prop.one_of.iter_mut().flat_map(|v| v.iter_mut()) { + inner.mark_borrowed_property(); + } + for inner in prop.any_of.iter_mut().flat_map(|v| v.iter_mut()) { + inner.mark_borrowed_property(); + } + if let Some(inner) = &mut prop.items { + inner.mark_borrowed_property(); + } + + prop.mark_borrowed_property(); + } } } -} -/// A generic function to: -/// 1. (Optional) Copy an inline parameter schema to `components/schemas`. -/// 2. Unwrap that parameter object into individual query parameters within the `paths` definition. -fn unwrap_parameters_by_path( - doc: &mut OpenAPI, - path: &str, - method: &str, - param_name_to_unwrap: &str, - new_component_name: Option<&str>, -) -> Result<(), String> { - // --- Step 1 (Optional): Copy the inline schema to components --- - if let Some(component_name) = new_component_name { + /// A generic function to: + /// 1. (Optional) Copy an inline parameter schema to `components/schemas`. + /// 2. Unwrap that parameter object into individual query parameters within the `paths` definition. + fn unwrap_parameters_by_path( + &mut self, + path: &str, + method: &str, + param_name_to_unwrap: &str, + new_component_name: Option<&str>, + ) -> Result<(), String> { + // --- Step 1 (Optional): Copy the inline schema to components --- + if let Some(component_name) = new_component_name { + println!( + "- Copying inline schema for '{}' to components.schemas.{}...", + param_name_to_unwrap, component_name + ); + + // Find the parameter with the inline schema to copy using a read-only borrow + let params_for_copy = self + .paths + .get(path) + .and_then(|p| p.get(method)) + .and_then(|op| op.parameters.as_ref()) + .ok_or_else(|| format!("Could not find parameters for {} {}", method, path))?; + + let param_to_copy = params_for_copy + .iter() + .find(|p| p.name.as_deref() == Some(param_name_to_unwrap)) + .ok_or_else(|| { + format!("Parameter '{}' not found for copying", param_name_to_unwrap) + })?; + + let inline_schema = param_to_copy + .schema + .clone() + .ok_or_else(|| format!("No schema found for '{}'", param_name_to_unwrap))?; + + // Get a mutable borrow to insert the cloned schema into components + self.components + .schemas + .insert(component_name.into(), inline_schema); + } + + // --- Step 2: Unwrap the parameter object into individual parameters --- println!( - "- Copying inline schema for '{}' to components.schemas.{}...", - param_name_to_unwrap, component_name + "- Unwrapping parameter object '{}'...", + param_name_to_unwrap ); - // Find the parameter with the inline schema to copy using a read-only borrow - let params_for_copy = doc + // Navigate down to the operation's parameters list (mutable) + let params_for_unwrap = self .paths - .get(path) - .and_then(|p| p.get(method)) - .and_then(|op| op.parameters.as_ref()) + .get_mut(path) + .and_then(|p| p.get_mut(method)) + .and_then(|op| op.parameters.as_mut()) .ok_or_else(|| format!("Could not find parameters for {} {}", method, path))?; - let param_to_copy = params_for_copy + let param_index = params_for_unwrap .iter() - .find(|p| p.name.as_deref() == Some(param_name_to_unwrap)) - .ok_or_else(|| format!("Parameter '{}' not found for copying", param_name_to_unwrap))?; + .position(|p| p.name.as_deref() == Some(param_name_to_unwrap)) + .ok_or_else(|| format!("Parameter '{}' not found in {}", param_name_to_unwrap, path))?; - let inline_schema = param_to_copy + let param_object = params_for_unwrap.remove(param_index); + let properties = param_object .schema - .clone() - .ok_or_else(|| format!("No schema found for '{}'", param_name_to_unwrap))?; + .and_then(|s| s.properties) + .ok_or_else(|| { + format!( + "Could not extract properties from '{}'", + param_name_to_unwrap + ) + })?; + + for (key, value) in properties { + let new_param = OpenAPIParameter { + name: Some(key), + r#in: Some("query".to_owned()), + schema: Some(value), + ..Default::default() + }; + params_for_unwrap.push(new_param); + } - // Get a mutable borrow to insert the cloned schema into components - doc.components - .schemas - .insert(component_name.into(), inline_schema); + Ok(()) } - // --- Step 2: Unwrap the parameter object into individual parameters --- - println!( - "- Unwrapping parameter object '{}'...", - param_name_to_unwrap - ); - - // Navigate down to the operation's parameters list (mutable) - let params_for_unwrap = doc - .paths - .get_mut(path) - .and_then(|p| p.get_mut(method)) - .and_then(|op| op.parameters.as_mut()) - .ok_or_else(|| format!("Could not find parameters for {} {}", method, path))?; - - let param_index = params_for_unwrap - .iter() - .position(|p| p.name.as_deref() == Some(param_name_to_unwrap)) - .ok_or_else(|| format!("Parameter '{}' not found in {}", param_name_to_unwrap, path))?; - - let param_object = params_for_unwrap.remove(param_index); - let properties = param_object - .schema - .and_then(|s| s.properties) - .ok_or_else(|| { - format!( - "Could not extract properties from '{}'", - param_name_to_unwrap - ) - })?; - - for (key, value) in properties { - let new_param = OpenAPIParameter { - name: Some(key), - r#in: Some("query".to_owned()), - schema: Some(value), - ..Default::default() - }; - params_for_unwrap.push(new_param); - } + /// Special handler for unwrapping search parameters from `components/schemas`. + fn unwrap_search_parameters(&mut self) -> Result<(), String> { + println!("- Unwrapping searchParameters..."); + // Get the definition of SearchParameters from components + let search_params_props = self + .components + .schemas + .get("SearchParameters") + .and_then(|sp| sp.properties.as_ref()) + .cloned() // Clone to avoid borrowing issues + .ok_or_else(|| "Could not find schema for SearchParameters".to_string())?; - Ok(()) -} + // Navigate to the operation's parameters list + let params = self + .paths + .get_mut("/collections/{collectionName}/documents/search") + .and_then(|p| p.get_mut("get")) + .and_then(|op| op.parameters.as_mut()) + .ok_or_else(|| { + "Could not find parameters for /collections/{collectionName}/documents/search" + .to_string() + })?; + + // Find and remove the old parameter object. + let param_index = params + .iter() + .position(|p| p.name.as_deref() == Some("searchParameters")) + .ok_or_else(|| "searchParameters object not found".to_string())?; + params.remove(param_index); + + // Add the new individual parameters. + for (key, value) in search_params_props { + let new_param = OpenAPIParameter { + name: Some(key), + r#in: Some("query".to_owned()), + schema: Some(value), + ..Default::default() + }; + params.push(new_param); + } -/// Special handler for unwrapping search parameters from `components/schemas`. -fn unwrap_search_parameters(doc: &mut OpenAPI) -> Result<(), String> { - println!("- Unwrapping searchParameters..."); - // Get the definition of SearchParameters from components - let search_params_props = doc - .components - .schemas - .get("SearchParameters") - .and_then(|sp| sp.properties.as_ref()) - .cloned() // Clone to avoid borrowing issues - .ok_or_else(|| "Could not find schema for SearchParameters".to_string())?; - - // Navigate to the operation's parameters list - let params = doc - .paths - .get_mut("/collections/{collectionName}/documents/search") - .and_then(|p| p.get_mut("get")) - .and_then(|op| op.parameters.as_mut()) - .ok_or_else(|| { - "Could not find parameters for /collections/{collectionName}/documents/search" - .to_string() - })?; - - // Find and remove the old parameter object. - let param_index = params - .iter() - .position(|p| p.name.as_deref() == Some("searchParameters")) - .ok_or_else(|| "searchParameters object not found".to_string())?; - params.remove(param_index); - - // Add the new individual parameters. - for (key, value) in search_params_props { - let new_param = OpenAPIParameter { - name: Some(key), - r#in: Some("query".to_owned()), - schema: Some(value), - ..Default::default() - }; - params.push(new_param); + Ok(()) } - Ok(()) -} + /// Special handler for unwrapping multi-search parameters from `components/schemas`. + fn unwrap_multi_search_parameters(&mut self) -> Result<(), String> { + println!("- Unwrapping multiSearchParameters..."); + // Get the definition of MultiSearchParameters from components + let search_params_props = self + .components + .schemas + .get("MultiSearchParameters") + .and_then(|sp| sp.properties.as_ref()) + .cloned() + .ok_or_else(|| "Could not find schema for MultiSearchParameters".to_string())?; -/// Special handler for unwrapping multi-search parameters from `components/schemas`. -fn unwrap_multi_search_parameters(doc: &mut OpenAPI) -> Result<(), String> { - println!("- Unwrapping multiSearchParameters..."); - // Get the definition of MultiSearchParameters from components - let search_params_props = doc - .components - .schemas - .get("MultiSearchParameters") - .and_then(|sp| sp.properties.as_ref()) - .cloned() - .ok_or_else(|| "Could not find schema for MultiSearchParameters".to_string())?; - - // Navigate to the operation's parameters list - let params = doc - .paths - .get_mut("/multi_search") - .and_then(|p| p.get_mut("post")) - .and_then(|op| op.parameters.as_mut()) - .ok_or_else(|| "Could not find parameters for /multi_search".to_string())?; - - // Find and remove the old parameter object. - let param_index = params - .iter() - .position(|p| p.name.as_deref() == Some("multiSearchParameters")) - .ok_or_else(|| "multiSearchParameters object not found".to_string())?; - params.remove(param_index); - - // Add the new individual parameters. - for (key, value) in search_params_props { - let new_param = OpenAPIParameter { - name: Some(key), - r#in: Some("query".to_owned()), - schema: Some(value), - ..Default::default() - }; - params.push(new_param); - } + // Navigate to the operation's parameters list + let params = self + .paths + .get_mut("/multi_search") + .and_then(|p| p.get_mut("post")) + .and_then(|op| op.parameters.as_mut()) + .ok_or_else(|| "Could not find parameters for /multi_search".to_string())?; - Ok(()) + // Find and remove the old parameter object. + let param_index = params + .iter() + .position(|p| p.name.as_deref() == Some("multiSearchParameters")) + .ok_or_else(|| "multiSearchParameters object not found".to_string())?; + params.remove(param_index); + + // Add the new individual parameters. + for (key, value) in search_params_props { + let new_param = OpenAPIParameter { + name: Some(key), + r#in: Some("query".to_owned()), + schema: Some(value), + ..Default::default() + }; + params.push(new_param); + } + + Ok(()) + } }