Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d67eddd
use custom openapi generator template
haydenhoang Aug 31, 2025
751b471
feat(openapi-template): bon builder derive, generic model and API method
haydenhoang Aug 31, 2025
5dc2593
feat: `x-rust-return-type`to override generated API methods' return type
haydenhoang Sep 1, 2025
54feb11
feat: bon builder string into conversion
haydenhoang Sep 1, 2025
9350735
feat: multi-node client
haydenhoang Sep 1, 2025
bc37f4f
fix: avoid JSON serializing the request body of endpoints that accept…
haydenhoang Sep 2, 2025
bbbb450
feat: multi search
haydenhoang Sep 3, 2025
f4df267
refactor multi search extension
haydenhoang Sep 3, 2025
41ce84f
fix lint
haydenhoang Sep 3, 2025
94e2687
rename folder from `custom-template` to `openapi-generator-template` …
haydenhoang Sep 3, 2025
634ca79
refactor: `to_owned` instead of `to_string`
haydenhoang Sep 3, 2025
e7fe4c5
ci: remove httpmock, ci with real Typesense server
haydenhoang Sep 5, 2025
d9b3a20
ci: use typesense v30.0.rc10
haydenhoang Sep 5, 2025
4b811e2
ignore rust fmt for `typesense_codegen`
haydenhoang Sep 5, 2025
b6fde07
feat: explicit `x-rust-builder: true` to generate builders for open a…
haydenhoang Sep 7, 2025
4d4d38e
rename `x-rust-operation-generic-parameter` to `x-rust-generic-parame…
haydenhoang Sep 7, 2025
d20bdec
make `perform_union` generic and remove `UnionSearchResultExt`
haydenhoang Sep 7, 2025
8609710
use String instead of reqwest::Url for node configuration
haydenhoang Sep 7, 2025
4726f74
don't `pub use models::*` at the root
haydenhoang Sep 7, 2025
a1f0a48
Optimize + fmt
RoDmitry Sep 11, 2025
b83084c
inline
RoDmitry Sep 11, 2025
7d7e1c9
Get next node faster for a single node config
RoDmitry Sep 11, 2025
f16f30f
feat: add openapi vendor attributes directly through xtask
haydenhoang Sep 12, 2025
924e772
Workspace dependencies
RoDmitry Sep 12, 2025
ef8dfc9
run cargo fmt after code-gen task
haydenhoang Sep 12, 2025
6a7a412
Refactor execute_wrapper
RoDmitry Sep 12, 2025
9d85528
collection_name ref str
RoDmitry Sep 12, 2025
cbabbc5
codegen apis ref params
RoDmitry Sep 12, 2025
439f805
README: add instructions to use the xtask
haydenhoang Sep 12, 2025
49af863
Readme tweak
haydenhoang Sep 12, 2025
7f7794f
README: code gen docker command
haydenhoang Sep 13, 2025
1c9d56f
remove unused openapi template files
haydenhoang Sep 13, 2025
ea3a126
modify the open api template instead of ignoring`apis/mod.rs` and `li…
haydenhoang Sep 13, 2025
8b7a077
remove `openapi-generator-template/request.rs`
haydenhoang Sep 14, 2025
605d476
expose pub ResponseContent
RoDmitry Sep 15, 2025
c2bb563
Avoid apikey clone
RoDmitry Sep 15, 2025
0070ab2
Rename generic
RoDmitry Sep 15, 2025
9783c60
Rename: collection() requires trait Document
RoDmitry Sep 15, 2025
245b9a4
Node::set_health
RoDmitry Sep 16, 2025
7347a04
Legacy API
RoDmitry Sep 20, 2025
ab05dcf
Fix test
RoDmitry Sep 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
41 changes: 24 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
name: CI

on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- '**/*.md'
pull_request:
branches:
- main
paths-ignore:
- '**/*.md'

jobs:
tests:
runs-on: "${{ matrix.platform.os }}-latest"
runs-on: '${{ matrix.platform.os }}-latest'
strategy:
matrix:
platform: [
{ os: "ubuntu", target: "x86_64-unknown-linux-gnu" },
{ os: "ubuntu", target: "wasm32-unknown-unknown" },
]
env:
# used to connect to httpmock
URL: "http://localhost:5000"
API_KEY: "VerySecretKey"
platform:
[
{ os: 'ubuntu', target: 'x86_64-unknown-linux-gnu' },
{ os: 'ubuntu', target: 'wasm32-unknown-unknown' },
]
services:
typesense:
image: typesense/typesense:30.0.rc10
ports:
- 8108:8108/tcp
volumes:
- /tmp/typesense-server-data:/data
env:
TYPESENSE_DATA_DIR: '/data'
TYPESENSE_API_KEY: 'xyz'
TYPESENSE_ENABLE_CORS: true
TYPESENSE_URL: 'http://localhost:8108'
steps:
- uses: actions/checkout@v4
- name: Cache .cargo and target
Expand All @@ -38,16 +52,9 @@ jobs:
target: ${{ matrix.platform.target }}
profile: minimal
default: true
- name: Install httpmock
uses: actions-rs/cargo@v1
with:
command: install
args: --features standalone -- httpmock
- name: Run httpmock
run: httpmock --expose --mock-files-dir=./mocks &
- name: Install test runner for wasm
if: matrix.platform.target == 'wasm32-unknown-unknown'
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Stable Build
uses: actions-rs/cargo@v1
with:
Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
name: Lint checks

on:
workflow_dispatch:
push:
branches: [ main ]
branches:
- main
paths-ignore:
- '**/*.md'
pull_request:
branches: [ main ]
branches:
- main
paths-ignore:
- '**/*.md'

jobs:
lint:
runs-on: ubuntu-latest
env:
TZ: "/usr/share/zoneinfo/your/location"
TZ: '/usr/share/zoneinfo/your/location'
steps:
- uses: actions/checkout@v4
- name: Cache .cargo and target
Expand All @@ -28,11 +35,11 @@ jobs:
profile: minimal
default: true
- run: rustup component add rustfmt
- name: Check formt
- name: Check format
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
args: -- --check
- run: rustup component add clippy
- name: Run clippy
uses: actions-rs/cargo@v1
Expand Down
20 changes: 17 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ repository = "https://github.com/typesense/typesense-rust"
authors = ["Typesense <contact@typesense.org>"]

[workspace.dependencies]

typesense_derive = { path = "./typesense_derive", version = "0.3.0" }
typesense_codegen = { path = "./typesense_codegen", version = "0.25.0" }
typesense_codegen = { path = "./typesense_codegen", version = "0.25" }
typesense_derive = { path = "./typesense_derive", version = "0.3" }
anyhow = "1"
base64 = "0.22"
bon = "3"
clap = { version = "4", features = ["derive"] }
debug_unsafe = "0.1"
hmac = "0.12"
reqwest-retry = "0.7"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0"
serde_repr = "0.1"
serde_yaml = "0.9"
sha2 = "0.10"
thiserror = "2"
url = "2"
web-time = "=1.1.0"
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,40 @@

Rust client library for Typesense | Work In Progress &amp; Help Wanted!

OpenAPI codegen folder was generated with:
### Development

When updating or adding new parameters and endpoints, make changes directly in the [Typesense API spec repository](https://github.com/typesense/typesense-api-spec).

Once your changes are merged, you can update this project as follows (you can also run tasks individually):

```bash
cargo xtask fetch code-gen
```

This will:

- Download the latest API spec.
- Write it to our local [`openapi.yml`](./openapi.yml).
- Preprocess it into [`preprocessed_openapi.yml`](./preprocessed_openapi.yml).
- Regenerate the `/typesense_codegen` crate.

The preprocessing step does two things:

- Flatten the URL params defined as objects into individual URL parameters (in [`preprocess_openapi.rs`](xtask/src/preprocess_openapi.rs))
- Inject OpenAPI vendor attributes (e.g., generic parameters, schema builders) into the spec before code generation (in [`add_vendor_attributes.rs`](./xtask/src/add_vendor_attributes.rs))

You can also run `code-gen` directly through Docker:

```
docker run --rm \
-v $PWD:/local openapitools/openapi-generator-cli generate \
-i /local/openapi.yml \
-i /local/preprocessed_openapi.yml \
-g rust \
-o /local/typesense_codegen_new
-o /local/typesense_codegen \
-t /local/openapi-generator-template \
--additional-properties library=reqwest \
--additional-properties supportMiddleware=true \
--additional-properties useSingleRequestParameter=true
```

If you'd like to contribute, please join our [Slack Community](https://join.slack.com/t/typesense-community/shared_invite/zt-mx4nbsbn-AuOL89O7iBtvkz136egSJg) and say hello!
If you'd like to contribute, please join our [Slack Community](https://join.slack.com/t/typesense-community/shared_invite/zt-mx4nbsbn-AuOL89O7iBtvkz136egSJg) and say hello!
2 changes: 1 addition & 1 deletion compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
typesense:
image: typesense/typesense:29.0
image: typesense/typesense:30.0.rc10
restart: on-failure
ports:
- '8108:8108'
Expand Down
24 changes: 0 additions & 24 deletions mocks/create_collection.yaml

This file was deleted.

23 changes: 0 additions & 23 deletions mocks/drop_collection.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions mocks/import_documents.yaml

This file was deleted.

34 changes: 0 additions & 34 deletions mocks/retrieve_all_collections.yaml

This file was deleted.

23 changes: 0 additions & 23 deletions mocks/retrieve_collection.yaml

This file was deleted.

17 changes: 0 additions & 17 deletions mocks/search_collection.yaml

This file was deleted.

54 changes: 54 additions & 0 deletions openapi-generator-template/README.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Rust API client for {{{packageName}}}

{{#appDescriptionWithNewLines}}
{{{.}}}
{{/appDescriptionWithNewLines}}

{{#infoUrl}}
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
{{/infoUrl}}

## Overview

This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.

- API version: {{{appVersion}}}
- Package version: {{{packageVersion}}}
{{^hideGenerationTimestamp}}
- Build date: {{{generatedDate}}}
{{/hideGenerationTimestamp}}
- Generator version: {{generatorVersion}}
- Build package: `{{{generatorClass}}}`

## Installation

Put the package under your project folder in a directory named `{{packageName}}` and add the following to `Cargo.toml` under `[dependencies]`:

```
{{{packageName}}} = { path = "./{{{packageName}}}" }
```

## Documentation for API Endpoints

All URIs are relative to *{{{basePath}}}*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{{classname}}}* | [**{{{operationId}}}**]({{{apiDocPath}}}{{classname}}.md#{{{operationIdLowerCase}}}) | **{{{httpMethod}}}** {{{path}}} | {{{summary}}}
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}

## Documentation For Models

{{#models}}{{#model}} - [{{{classname}}}]({{{modelDocPath}}}{{{classname}}}.md)
{{/model}}{{/models}}

To get access to the crate's generated documentation, use:

```
cargo doc --open
```

## Author

{{#apiInfo}}{{#apis}}{{#-last}}{{{infoEmail}}}
{{/-last}}{{/apis}}{{/apiInfo}}
Loading
Loading