Contributing to Katana OpenAPI Client¶
Thank you for your interest in contributing to the Katana OpenAPI Client! This document provides guidelines and instructions for contributing.
Development Setup¶
- Clone the repository
- Install uv (if not already installed)
- Install dependencies
- Set up environment variables
Development Workflow¶
Code Quality¶
We maintain high code quality standards. Before submitting changes:
# Format code
uv run poe format
# Check formatting
uv run poe format-check
# Run type checking
uv run poe lint
# Run tests
uv run poe test
Running Tests¶
# Run all tests
uv run poe test
# Run with coverage
uv run poe test-coverage
# Run specific test file
uv run poe test tests/test_katana_client.py
# Run integration tests (requires API credentials)
uv run poe test-integration
Code Style¶
- We use Ruff for code formatting and linting
- ty for type checking (Astral's fast Rust-based type checker)
- mdformat for Markdown formatting
All formatting is automated via uv run poe format.
Submitting Changes¶
Pull Request Process¶
- Fork the repository and create a feature branch
-
Make your changes following the code style guidelines
-
Add or update tests for your changes
-
Update documentation if needed
-
Run the full test suite
- Commit your changes with a clear commit message using scopes
# For client changes
git commit -m "feat(client): add new domain helper"
# For MCP server changes
git commit -m "feat(mcp): add inventory tool"
- Push to your fork and create a pull request
Commit Message Format¶
We follow Conventional Commits with scopes for monorepo versioning:
Type + Scope:
feat(client):new features in the client (triggers client release)feat(mcp):new features in MCP server (triggers MCP release)fix(client):bug fixes in the client (triggers client release)fix(mcp):bug fixes in MCP server (triggers MCP release)docs:documentation changes (no release)test:adding or updating tests (no release)chore:maintenance tasks (no release)
Examples:
# Release client package
git commit -m "feat(client): add Products domain helper"
# Release MCP server package
git commit -m "feat(mcp): implement check_inventory tool"
# No release (documentation only)
git commit -m "docs: update README with new examples"
Important: Use the correct scope based on what you're changing:
- Files in
katana_public_api_client/→ use(client)scope - Files in
katana_mcp_server/→ use(mcp)scope - Documentation or CI only → use
docs:orci:(no scope)
See docs/RELEASE.md for complete release documentation
Pull Request Guidelines¶
- Include a clear description of the changes
- Reference any related issues
- Ensure all tests pass
- Update documentation if needed
- Keep the scope focused and atomic
Project Structure¶
katana-openapi-client/
├── katana_public_api_client/ # Main package
│ ├── __init__.py
│ ├── katana_client.py # Main client implementation
│ ├── client.py # Base client classes
│ ├── client_types.py # Type definitions
│ ├── errors.py # Exception classes
│ ├── log_setup.py # Logging configuration
│ ├── api/ # Generated API methods (flattened)
│ └── models/ # Generated models (flattened)
├── tests/ # Test suite
├── docs/ # Documentation
├── scripts/ # Development scripts
└── .github/ # GitHub workflows
Architecture Guidelines¶
Core Principles¶
- Transparency: Features should work automatically without configuration
- Resilience: All API calls should handle errors gracefully
- Type Safety: Use comprehensive type annotations
- Performance: Leverage async/await and efficient HTTP handling
- Compatibility: Maintain compatibility with the generated client
Adding New Features¶
When adding features:
- Transport Layer First: Implement core functionality in
ResilientAsyncTransport - Automatic Behavior: Make features work transparently without user configuration
- Comprehensive Testing: Include unit tests, integration tests, and error scenarios
- Documentation: Update relevant documentation and examples
Testing Guidelines¶
Test Categories¶
- Unit Tests: Test individual components in isolation
- Integration Tests: Test real API interactions (marked with
@pytest.mark.integration) - Transport Tests: Test the transport layer behavior directly
Writing Tests¶
- Use descriptive test names that explain the scenario
- Include both success and error cases
- Mock external dependencies appropriately
- Use fixtures for common test setup
Test Environment¶
Integration tests require valid Katana API credentials. Set these in your .env file:
Documentation¶
Updating Documentation¶
- Update relevant
.mdfiles in thedocs/directory - Keep examples current and working
- Update the README.md if adding user-facing features
- Include docstrings for all public methods
Client Regeneration¶
The OpenAPI client is automatically generated from katana-openapi.yaml using
openapi-python-client.
Regeneration Process¶
What Gets Regenerated¶
Replaced Files (Generated Content):
client.py- Base HTTP client classesclient_types.py- Type definitions (renamed fromtypes.py)errors.py- Exception definitionspy.typed- Type checking markerapi/- All API endpoint modules (137+ files)models/- All data model classes (150+ files)
Preserved Files (Custom Content):
katana_client.py- Our resilient client implementationlog_setup.py- Custom logging configuration__init__.py- Custom exports (gets rewritten but preserves structure)
Regeneration Features¶
- 🔄 Flattened Structure: No more
generated/subdirectory - 🛡️ File Preservation: Custom files are never overwritten
- 🔧 Automatic Fixes: Uses
ruff --unsafe-fixesfor code quality - ✅ Dual Validation: Both openapi-spec-validator and Redocly validation
- 🎯 Source-Level Fixes: Issues resolved in OpenAPI spec when possible
Documentation Style¶
- Use clear, concise language
- Include practical examples
- Follow the existing format and style
- Test any code examples to ensure they work
Release Process¶
Releases are fully automated using python-semantic-release. See RELEASE.md for complete documentation.
Quick summary for contributors:
- Use Conventional Commits format
feat:commits trigger minor version bump (0.x.0)fix:commits trigger patch version bump (0.0.x)- Releases happen automatically when PR is merged to
main
Getting Help¶
- Documentation: Check the
docs/directory - Issues: Search existing issues or create a new one
- Discussions: Use GitHub Discussions for questions
Code of Conduct¶
This project follows the Contributor Covenant Code of Conduct. Please read and follow it in all interactions.
Thank you for contributing! 🎉