Files
qdrant/tools/generate_openapi_models.sh
xzfc 5638d1799c Drop RocksDB (#8529)
* Skip broken tests

* Add rocksdb dropper

This is a temporary tool. It will be removed later in this PR.

* [automated] Drop rocksdb

This commit is made by running tools/rocksdb/drop.sh

* Touch-up after ast-grep

The previous automated commit removed items, but not their comments.
Also, some blocks are left with only one item.
Also, ast-grep can't handle macros like `vec![]`.

This commit completes the job.

* Remove RocksDB dropper

* Remove mentions of rocksdb feature in CI

* Fix clippy warnings

These `FIXME` comments added previously in this PR by ast-grep by
"peeling" cfg_attr like this:

    -#[cfg_attr(not(feature = "rocksdb"), expect(...))]
    +#[expect(...)] // FIXME(rocksdb): ...

This commit removes these allow/expect attributes and fixes clippy
lints.

* Remove leftover rocksdb-related code

Removed:
- Cargo.toml: rocksdb cargo feature flag and dependencies.
- code: rocksdb-related items that was not under feature flag.
- flags.rs: rocksdb-related qdrant feature flags.

Disabled:
- Some benchmarks because these do not compile now.

* Print warning if rocksdb leftovers found in snapshots

* Remove Clone from tokenizer

* Regenerate openapi.json
2026-05-08 13:45:44 +02:00

63 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# This script generate model definitions for OpenAPI 3.0 documentation
set -e
# Ensure current path is project root
cd "$(dirname "$0")/../"
# Fallback to dockerized utilities if they are not installed locally
if command -v ytt &>/dev/null; then
sh_with_ytt() { sh -c "$1"; }
else
sh_with_ytt() { docker run --rm -v "${PWD}":/workspace --entrypoint sh gerritk/ytt -c "$1"; }
fi
if ! yq --version 2>&1 | grep -q mikefarah; then
yq() { docker run --rm -v "${PWD}":/workdir mikefarah/yq "$@"; }
fi
# Apply `ytt` template engine to obtain OpenAPI definitions for REST endpoints
sh_with_ytt '
set -e
ytt -f ./openapi/openapi.lib.yml -f ./openapi/openapi-shards.ytt.yaml > ./openapi/openapi-shards.yaml
ytt -f ./openapi/openapi.lib.yml -f ./openapi/openapi-service.ytt.yaml > ./openapi/openapi-service.yaml
ytt -f ./openapi/openapi.lib.yml -f ./openapi/openapi-cluster.ytt.yaml > ./openapi/openapi-cluster.yaml
ytt -f ./openapi/openapi.lib.yml -f ./openapi/openapi-collections.ytt.yaml > ./openapi/openapi-collections.yaml
ytt -f ./openapi/openapi.lib.yml -f ./openapi/openapi-snapshots.ytt.yaml > ./openapi/openapi-snapshots.yaml
ytt -f ./openapi/openapi.lib.yml -f ./openapi/openapi-shard-snapshots.ytt.yaml > ./openapi/openapi-shard-snapshots.yaml
ytt -f ./openapi/openapi.lib.yml -f ./openapi/openapi-points.ytt.yaml > ./openapi/openapi-points.yaml
ytt -f ./openapi/openapi.lib.yml -f ./openapi/openapi-main.ytt.yaml > ./openapi/openapi-main.yaml
'
# Generates models from internal service structures
cargo run --package qdrant --features="service_debug" --bin schema_generator > ./openapi/schemas/AllDefinitions.json
docker build tools/schema2openapi --tag schema2openapi
docker run --rm \
-v "$PWD/openapi/schemas/AllDefinitions.json:/app/schema.json" \
schema2openapi | sed -e 's%#/definitions/%#/components/schemas/%g' >./openapi/models.json
yq eval -o yaml -P ./openapi/models.json > ./openapi/models.yaml
# Merge all *.yaml files together into a single-file OpenAPI definition
yq eval-all '. as $item ireduce ({}; . *+ $item)' \
./openapi/openapi-shards.yaml \
./openapi/openapi-service.yaml \
./openapi/openapi-cluster.yaml \
./openapi/openapi-collections.yaml \
./openapi/openapi-snapshots.yaml \
./openapi/openapi-shard-snapshots.yaml \
./openapi/openapi-points.yaml \
./openapi/openapi-main.yaml \
./openapi/models.yaml > ./openapi/openapi-merged.yaml
docker run --rm -v "${PWD}"/openapi:/spec redocly/openapi-cli:v1.0.0-beta.88 lint openapi-merged.yaml
yq eval -o=json ./openapi/openapi-merged.yaml | jq > ./openapi/openapi-merged.json
cp ./openapi/openapi-merged.json ./docs/redoc/master/openapi.json