openapi-gen

Generate and validate Python clients from OpenAPI specs. Use for generation, validation, or troubleshooting.

allowed_tools: Bash, Read, Glob, Grep

$ Instalar

git clone https://github.com/mindhiveoy/pyopenapi_gen /tmp/pyopenapi_gen && cp -r /tmp/pyopenapi_gen/.claude/skills/openapi-gen ~/.claude/skills/pyopenapi_gen

// tip: Run this command in your terminal to install the skill


name: openapi-gen description: Generate and validate Python clients from OpenAPI specs. Use for generation, validation, or troubleshooting. allowed-tools: Bash, Read, Glob, Grep

OpenAPI Client Generation

Workflow

  1. Activate: source .venv/bin/activate
  2. Generate: pyopenapi-gen <spec> --project-root <path> --output-package <pkg> --force --verbose
  3. Validate:
    • Check warnings in output
    • Test: python -c "from <pkg> import *"
    • Type check: mypy <path>/<pkg> --ignore-missing-imports

Options

OptionPurpose
--forceOverwrite existing files
--no-postprocessSkip Black/mypy (faster iteration)
--core-packageShared core for multi-client setups
--verboseShow detailed progress

Common Issues

SymptomFix
Import errorCheck --project-root and --output-package alignment
Missing moduleCheck --verbose for cycle warnings
Type errorReview OpenAPI spec
Empty dataclassEnsure schema has type field

Multi-Client Setup

For shared core module:

# First client with core
pyopenapi-gen api1.yaml --project-root . --output-package clients.api1 --core-package clients.core

# Additional clients sharing core
pyopenapi-gen api2.yaml --project-root . --output-package clients.api2 --core-package clients.core