This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Python monorepo managed with uv and poethepoet.
Prerequisites: Python 3.11+, Node.js >=20.19.0 and npm.
# Install dependencies
uv sync --all-packages
npm install # Required for Redocly, Spectral, and SpecLynx backends
# Run all tests
uv run poe test
# Run tests for a specific package
uv run --package jentic-openapi-validator pytest packages/jentic-openapi-validator/tests -q
# Run a single test file
uv run pytest packages/jentic-openapi-validator/tests/test_validate_default.py -v
# Run a single test by pattern
uv run pytest packages/**/tests -s -v -k test_name_pattern
# Lint and format
uv run poe lint # Check linting
uv run poe lint:fix # Auto-fix issues
# Type checking
uv run poe typecheck
# Build all packages
uv build --all-packages
# Build specific package
uv build --package jentic-openapi-validator- Ruff with line-length=100, target-version=py311
- Ruff enforces import sorting (isort) with 2 blank lines after imports
- Pyright in
standardtype checking mode
The monorepo contains these namespace packages under jentic.apitools.openapi.*:
| Package | Purpose |
|---|---|
jentic-openapi-common |
Shared utilities: path security, subprocess handling, URI parsing, version detection |
jentic-openapi-datamodels |
OpenAPI data models with source tracking (YAML node locations) |
jentic-openapi-parser |
Document parsing with pluggable backends |
jentic-openapi-traverse |
Document traversal (visitor pattern for datamodels, generic JSON traversal) |
jentic-openapi-transformer |
Document transformation/bundling core |
jentic-openapi-transformer-redocly |
Redocly bundler backend |
jentic-openapi-validator |
Document validation core + CLI (jentic-openapi-tools command) |
jentic-openapi-validator-spectral |
Spectral validation backend |
jentic-openapi-validator-redocly |
Redocly validation backend |
jentic-openapi-validator-speclynx |
SpecLynx ApiDOM validation backend |
common <- datamodels <- parser <- validator <- validator-spectral
^ \ \<- validator-redocly
| \<- validator-speclynx
+-- traverse <- transformer <- transformer-redocly
Core packages (parser, validator, transformer) use Python entry points for backend discovery:
Entry point groups:
jentic.apitools.openapi.parser.backendsjentic.apitools.openapi.validator.backendsjentic.apitools.openapi.transformer.bundler.backends
Pattern:
- Base classes define the interface (e.g.,
BaseValidatorBackendinbackends/base.py) - Backends implement the interface and declare
accepts()for supported input formats:"uri","text","dict" - Backends register via entry points in their package's
pyproject.toml - Core classes discover backends at runtime via
importlib.metadata.entry_points()
Backend execution tiering (validator-specific, used when parallel=True):
"cpu"(default): Fast pure-Python backends. Run sequentially in main thread."io": Backends that release the GIL (subprocess/network). Run inThreadPoolExecutor. Must be thread-safe."cpu-heavy": Long-running pure-Python backends. Run inProcessPoolExecutorwithspawn. Must be picklable.
All three tiers execute simultaneously when parallel mode is enabled.
- All packages use PEP 420 implicit namespace packages (
jentic.apitools.openapi.*) - no__init__.pyfiles in namespace directories - Build system uses
uv_buildwithnamespace = true - Source code lives in
packages/<name>/src/jentic/apitools/openapi/<module>/ - Tests live in
packages/<name>/tests/ - ValidationResult uses LSP diagnostics format (via
lsprotocol)
Commits follow Conventional Commits (enforced by pre-commit hook in --strict mode).
Scopes (from .gitmessage): parser, transformer, validator, validator-spectral, tools (for root package changes).
Branch naming: feature/<description> or fix/<description>. Include issue number after the slash if applicable (e.g., fix/1234-fix-parsing).
PR merging: Squash and merge with conventional commit format.
Configured hooks: conventional-commit validation (strict), ruff check, ruff format, uv lock sync, pyright. Install with uv run pre-commit install.
- Path Security:
validate_path()— defense against path traversal attacks. RaisesPathTraversalError,InvalidExtensionError,SymlinkSecurityError. - URI Utilities:
is_uri_like(),is_http_https_url(),resolve_to_absolute(),file_uri_to_path() - Subprocess Execution:
run_subprocess()— standardized external tool calls with timeout support - Version Detection:
get_version(),is_openapi_30(),is_openapi_31()
| Backend | Return Type | Use Case |
|---|---|---|
pyyaml (default) |
dict |
Simple parsing |
ruamel-safe |
CommentedMap |
Better YAML 1.2 support |
ruamel-roundtrip |
CommentedMap |
Preserves comments/formatting |
ruamel-ast |
MappingNode |
Full YAML AST with source positions |
datamodel-low |
OpenAPI30/OpenAPI31 |
Typed datamodels with source tracking |
| Backend | Type | Accepts | Notes |
|---|---|---|---|
default |
Pure Python | uri, dict | Built-in rule system |
openapi-spec |
Python lib | dict | openapi_spec_validator wrapper |
spectral |
External CLI | uri, dict | Requires Node.js |
redocly |
External CLI | uri, dict | Requires Node.js |
speclynx |
External CLI | uri, dict | Requires Node.js, uses SpecLynx ApiDOM |