Skip to main content

Swagger Opinionated utilities for filtering OpenAPI specifications

Project description

Swagou CLI

PyPI License: MIT Python Version Tests Lint

Swagou ("Swagger Opinionated Utilities") helps you filter OpenAPI specifications to include only what you need. It trims down API documentation so your AI agent can focus on specific endpoints without getting overwhelmed by the entire API surface.

Problem

Large API specifications can be overwhelming when you only need to work with specific endpoints. Swagou lets you extract only the parts you need, making it easier to:

  • Generate targeted code with AI assistants
  • Create focused documentation for specific API features
  • Troubleshoot specific API endpoints

Features

  • Filter OpenAPI specs by endpoint path and HTTP method
  • Support for remote URLs and local YAML files
  • Add authentication headers or cookies for protected specs
  • Filter by tags
  • Output to file or stdout

Installation

Using uv (recommended)

uv pip install swagou-cli

Or install directly from the repository:

uv pip install git+https://github.com/flyudvik/swagou-cli.git

Using pip

pip install swagou-cli

Usage

Basic Filtering

Filter specific GET endpoints and all methods for user endpoints:

swagou filter --input schema.yaml --get /api/posts/ --get /api/posts/{slug}/ --all /api/users/*

Remote Schemas with Authentication

# With token authentication
swagou filter --input https://api.example.com/schema/ --header="Authorization: Token abc123" --get /api/posts/

# With session cookie
swagou filter --input https://api.example.com/schema/ --cookie="sessionid=abc123" --all /api/users/*

Saving Output

By default, output goes to stdout, but you can specify a file:

swagou filter --input schema.yaml --get /api/posts/ --output=filtered_schema.yaml

Available Options

HTTP Methods:

  • -g, --get - Filter GET requests
  • -p, --post - Filter POST requests
  • -u, --patch - Filter PATCH requests
  • -d, --delete - Filter DELETE requests
  • --all - Include all HTTP methods for the specified path

Other Parameters:

  • -i, --input - Input source (URL or file path)
  • -o, --output - Output destination (default: stdout)
  • -t, --tags - Filter by tags

Development

Set up the development environment:

# Clone the repository
git clone https://github.com/flyudvik/swagou-cli.git
cd swagou-cli

# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies with development tools
uv pip install -e ".[dev]"

Running Tests

The project includes a comprehensive test suite. To run the tests:

# Install pytest if not already installed
uv pip install pytest

# Run all tests
python -m pytest tests

# Run specific test files
python -m pytest tests/test_filter.py
python -m pytest tests/test_cli.py

# Run with verbose output
python -m pytest tests -v

The test suite includes:

  • Unit tests for the core filtering functionality
  • Integration tests for the CLI interface
  • Regression tests for specific bug fixes

Continuous Integration

This project uses GitHub Actions for continuous integration and deployment:

  • Tests: Automatically runs the test suite on Python 3.11 and 3.12
  • Lint: Checks code formatting with Black, import sorting with isort, and type checking with mypy
  • Publish: Automatically publishes new releases to PyPI when a GitHub release is created

The workflow configurations can be found in the .github/workflows directory.

License

MIT

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

Happy vibe-coding!~

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swagou_cli-0.1.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swagou_cli-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file swagou_cli-0.1.0.tar.gz.

File metadata

  • Download URL: swagou_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for swagou_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 14fe6ea6af6d647ac6613b96d4c96110d9db2554c87b4895ab0d6c45f4000c49
MD5 dfbd502c86f6fba52db7ddaab97b8794
BLAKE2b-256 490ea30bcd2b0c73354eab2d408888ae5e352b1739ee0eacf1bf1c5a1fbf3924

See more details on using hashes here.

File details

Details for the file swagou_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: swagou_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for swagou_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5d062e738851f23789eba068cf58ccb540d6f8b1e0534c1cbe4c29e6d5240c4
MD5 173505e03b5d4bede30dca3c6ab61b20
BLAKE2b-256 8d807ec9f7c46f19ecf228cd2d28ca7128a58022501f28f5322692764c536b64

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page