Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
452d109
update SDK to 2026-01-23
damaz91 Feb 6, 2026
6d46afb
add init at the base level
damaz91 Feb 6, 2026
9214712
update README
damaz91 Feb 6, 2026
6b84070
add request specific classes
damaz91 Feb 6, 2026
d339a83
fix schema generation
damaz91 Feb 6, 2026
95e1ed5
fix schema generation
damaz91 Feb 6, 2026
c487f98
Update pyproject.toml
damaz91 Feb 6, 2026
87df21e
update pre-processing to correctly handle self-reference
damaz91 Feb 11, 2026
bbad289
fix
damaz91 Feb 11, 2026
16e045b
sync
damaz91 Feb 11, 2026
32d6744
Merge branch 'update-2026-01-23'
damaz91 Feb 11, 2026
bea0f7f
address comments
damaz91 Mar 2, 2026
736c503
add win32 specific check for paths
damaz91 Mar 2, 2026
7a2c080
Merge branch 'main' into update-2026-01-23
damaz91 Mar 2, 2026
8d559b9
remove preprocessing
damaz91 Mar 2, 2026
8ef89ee
update readme
damaz91 Mar 2, 2026
926077a
re-run of generate_models.sh
damaz91 Mar 2, 2026
8818a26
move ruff config
damaz91 Mar 2, 2026
c83b40e
delete temp files
damaz91 Mar 2, 2026
9e47cf1
add LICENSE reference
damaz91 Mar 2, 2026
74aa3bc
add preprocessing to handle request type class generation
damaz91 Mar 2, 2026
dcfadba
change naming convention
damaz91 Mar 2, 2026
c9014f3
update preprocessing to include more request types
damaz91 Mar 2, 2026
f919b25
delete ucp
damaz91 Mar 2, 2026
9a1a921
Update SDK to 2026-01-23 (#5)
damaz91 Mar 2, 2026
881ac12
adjust script to only generate schema from the schemas folder
damaz91 Mar 2, 2026
2853e0c
remove ucp
damaz91 Mar 2, 2026
e511eac
go back to old version numbering
damaz91 Mar 2, 2026
d21c795
remove lock
damaz91 Mar 2, 2026
018f250
add postprocessing for root models
damaz91 Mar 2, 2026
8004202
Merge branch 'main' into fix-2026-01-23
damaz91 Mar 3, 2026
9fb1120
regeneate schema
damaz91 Mar 3, 2026
dc360be
regenerate schema
damaz91 Mar 3, 2026
3940aeb
remove postprocessing in favour of a root model template
damaz91 Mar 3, 2026
249329f
remove postprocessing
damaz91 Mar 3, 2026
3613d4f
remove lock
damaz91 Mar 3, 2026
d4cbaed
fix docstrings
damaz91 Mar 3, 2026
2c78f90
make recursive functions iterative
damaz91 Mar 3, 2026
e3b8248
remove ucp
damaz91 Mar 3, 2026
e6efa90
refactor preprocess
damaz91 Mar 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ For now, you can install the SDK using the following commands:
mkdir sdk

# Clone the repository
git clone https://github.com/Universal-Commerce-Protocol/python-sdk.git sdk/python

# Navigate to the directory
cd sdk/python
git clone https://github.com/Universal-Commerce-Protocol/python-sdk.git

# Install dependencies
uv sync
Expand All @@ -62,9 +59,13 @@ To regenerate the models:

```bash
uv sync
./generate_models.sh
./generate_models.sh <version>
```

Where `<version>` is the version of the UCP specification to use (for example, "2026-01-23").

If no version is specified, the `main` branch of the [UCP repo](https://github.com/Universal-Commerce-Protocol/ucp) will be used.

The generated code is automatically formatted using `ruff`.

## Contributing
Expand Down
42 changes: 38 additions & 4 deletions generate_models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,38 @@
# Ensure we are in the script's directory
cd "$(dirname "$0")" || exit

# Add ~/.local/bin to PATH for uv
export PATH="$HOME/.local/bin:$PATH"

# Check if git is installed
if ! command -v git &> /dev/null; then
echo "Error: git not found. Please install git."
exit 1
fi

# UCP Version to use (if provided, use release/$1 branch; otherwise, use main)
if [ -z "$1" ]; then
BRANCH="main"
echo "No version specified, cloning main branch..."
else
BRANCH="release/$1"
echo "Cloning version $1 (branch: $BRANCH)..."
fi

# Ensure ucp directory is clean before cloning
rm -rf ucp
git clone -b "$BRANCH" --depth 1 https://github.com/Universal-Commerce-Protocol/ucp ucp

# Output directory
OUTPUT_DIR="src/ucp_sdk/models"
OUTPUT_DIR="src/ucp_sdk/models/schemas"

# Schema directory (relative to this script)
SCHEMA_DIR="../../spec/"
SCHEMA_DIR="ucp/source/schemas"

echo "Preprocessing schemas..."
uv run python preprocess_schemas.py

echo "Generating Pydantic models from $SCHEMA_DIR..."
echo "Generating Pydantic models from preprocessed schemas..."

# Check if uv is installed
if ! command -v uv &> /dev/null; then
Expand All @@ -23,9 +48,11 @@ fi
rm -r -f "$OUTPUT_DIR"
mkdir -p "$OUTPUT_DIR"


# Run generation using uv
# We use --use-schema-description to use descriptions from JSON schema as docstrings
# We use --field-constraints to include validation constraints (regex, min/max, etc.)
# Note: Formatting is done as a post-processing step.
uv run \
--link-mode=copy \
--extra-index-url https://pypi.org/simple python \
Expand All @@ -42,6 +69,13 @@ uv run \
--use-double-quotes \
--no-use-annotated \
--allow-extra-fields \
--formatters ruff-format ruff-check
--custom-template-dir templates \
--additional-imports pydantic.ConfigDict


echo "Formatting generated models..."
uv run ruff format
uv run ruff check --fix "$OUTPUT_DIR" 2>&1 | grep -E "^(All checks passed|Fixed|Found)" || echo "Formatting complete"


echo "Done. Models generated in $OUTPUT_DIR"
Loading
Loading