llama-stack-mirror/docs/openapi_generator/run_openapi_generator.sh
Sébastien Han 44e36ce48d
chore: use JSON instead of YAML for openapi generation
JSON has a few advantages over YAML in this context:

* No extra dependency: Removed ruamel.yaml; using the standard library
  json module.
* Simpler code: No YAML formatting configuration (indent, flow style,
  string presentation, etc.). JSON serialization is straightforward.
* Faster generation: JSON serialization is typically faster and more
  predictable than YAML formatting.
* Native OpenAPI format: JSON is the native OpenAPI format. Many tools
  prefer JSON, reducing potential compatibility issues.
* Better tooling support: JSON is widely supported. Tools like oasdiff,
  OpenAPI validators, and code generators work well with JSON.
* Fewer formatting edge cases: YAML can have edge cases (multiline
  strings, special characters, quoting, scalars etc). JSON avoids these.

All the tools consumming the YAMLs have been updated namely oasdiff for
conformance tests, docusaurus config and the genrator.

Signed-off-by: Sébastien Han <seb@redhat.com>
2025-11-03 18:05:48 +01:00

34 lines
971 B
Bash
Executable file

#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
PYTHONPATH=${PYTHONPATH:-}
THIS_DIR="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)"
set -euo pipefail
missing_packages=()
check_package() {
if ! pip show "$1" &>/dev/null; then
missing_packages+=("$1")
fi
}
if [ ${#missing_packages[@]} -ne 0 ]; then
echo "Error: The following package(s) are not installed:"
printf " - %s\n" "${missing_packages[@]}"
echo "Please install them using:"
echo "pip install ${missing_packages[*]}"
exit 1
fi
stack_dir=$(dirname $(dirname "$THIS_DIR"))
PYTHONPATH=$PYTHONPATH:$stack_dir \
python -m docs.openapi_generator.generate $(dirname "$THIS_DIR")/static
cp "$stack_dir"/docs/static/stainless-llama-stack-spec.json "$stack_dir"/client-sdks/stainless/openapi.json