Metadata-Version: 2.4
Name: lapis-spec
Version: 0.1.0
Summary: Convert OpenAPI 3.0/3.1 specifications to LAPIS format
Author: LAPIS Contributors
License: MIT
License-File: LICENSE
Requires-Python: >=3.12
Requires-Dist: openapi-spec-validator>=0.7
Requires-Dist: pyyaml>=6.0
Description-Content-Type: text/markdown

# lapis-spec

Convert OpenAPI 3.0/3.1 specifications to [LAPIS](../../spec.en.md) format.

LAPIS (Lightweight API Specification for Intelligent Systems) is a compact API description format designed for LLM consumption, achieving 70-80% token reduction compared to OpenAPI YAML.

## Installation

```bash
pip install lapis-spec
```

Or with [uv](https://docs.astral.sh/uv/):

```bash
uv pip install lapis-spec
```

## Usage

```bash
# Convert OpenAPI YAML to LAPIS
lapis -i openapi.yaml -o api.lapis

# Convert OpenAPI JSON to LAPIS
lapis -i openapi.json -o api.lapis

# Skip OpenAPI validation (useful for partial specs)
lapis -i openapi.yaml -o api.lapis --no-validate
```

### CLI Options

| Option | Description |
|---|---|
| `-i`, `--input` | Path to OpenAPI file (.json, .yaml, .yml) |
| `-o`, `--output` | Path to output .lapis file |
| `--no-validate` | Skip OpenAPI schema validation |
| `--version` | Show version and exit |
| `-h`, `--help` | Show help message |

## Supported Features

- OpenAPI 3.0.x and 3.1.x
- JSON and YAML input formats
- Full `$ref` resolution
- `allOf`/`oneOf`/`anyOf` flattening
- All LAPIS sections: `[meta]`, `[types]`, `[ops]`, `[webhooks]`, `[errors]`, `[limits]`, `[flows]`
- Automatic schema deduplication (inline vs named types)
- Security scheme interpretation (bearer, apikey, basic, oauth2)
- Operation modifier detection (`+deprecated`, `+paginated`, `+idempotent`, `+stream`)
- Error response collection and deduplication

## Development

```bash
# Install dependencies
poetry install

# Run tests
poetry run pytest

# Run tests with coverage report
poetry run pytest --cov-report=html

# Lint
poetry run ruff check src/ tests/

# Type check
poetry run mypy
```

## License

MIT
