Swagger API Test Case Generator
Paste the following prompt into your AI chat to install this skill:
Follow https://skillhub.cn/install/skillhub.md and install @user_a84e2069/swagger-to-testcases.
About this skill
The problem
API specs are often available as Swagger/OpenAPI, but turning them into testable work still requires manual effort: choosing cases, handling login state, parameterizing requests, asserting responses, and deciding how failures are reported. A spec describes what the API exposes, not which cases are worth running, how to locate a failure, or how to distribute results. In multi-environment services, base_url, tokens, database connections, redaction, retries, and reporting easily scatter across ad hoc scripts.
How it works
swagger-to-testcases generates two artifacts from Swagger/OpenAPI 2.0/3.x files:
- Excel case tables: a 26-column structure for review, planning, and execution tracking.
- pytest framework files: runnable tests with a bundled framework/ directory.
The framework includes five core modules:
- config.py: multi-environment configuration with precedence environment variables > environment YAML > default.yaml.
- logger.py: structured logging with request(), response(), and assertion() methods, plus automatic masking for token, cookie, and password.
- http_client.py: a unified request layer with timeouts, retries, status assertions, JSONPath assertions, variable extraction, and {{variable}} templating.
- fixtures.py: setup and teardown for login, initialization, cleanup tasks, database cleanup, and HTTP cleanup.
- reporter.py: Allure reporting with graceful fallback, plus SMTP email delivery.
Boundaries
This is useful when a stable OpenAPI spec exists and API testing needs to move from manual scripts to a repeatable runner. Complex stateful flows, message queues, WebSocket endpoints, file uploads, and external service dependencies still require manually authored cases. Allure and email reporting depend on local dependencies and SMTP configuration, so CI environments need secret injection and artifact handling.
Use Cases
- Before API integration testing, generate an Excel case table from a Swagger spec for review.
- With an OpenAPI document already available, produce a runnable pytest API test skeleton.
- In multi-environment testing, manage base_url, login state, redacted logs, and assertions through one framework.
- After regression testing, send the Allure report and failure details to stakeholders by email.
Best For
- Test engineers handling API acceptance: need to turn OpenAPI specs into executable pytest cases.
- Backend engineers maintaining BFF gateways: need unified login, assertions, redacted logs, and reporting.
- Test leads planning regression cycles: need Excel case tables for review and execution records.
- Automation engineers integrating CI: need generated runnable tests and Allure reports.
Related Skills
Analyzes code to extract control and data flow, then outputs Markdown with Mermaid source and high-resolution PNG diagrams.
For development and programming scenarios around VSCode and TypeScript IDE.
A TypeScript-oriented Windmill Wrap development reference.
A Python-based Selenium wrapper for engineering browser automation workflows.