| name | yaml_case_generator |
| description | Generate YAML API test case drafts from Swagger/OpenAPI documents, confirmed contract supplements, and optional API change diff outputs from api_contract_checker. |
YAML Case Generator
Use this skill after openapi_api_analyzer and api_contract_checker when the API contract is ready enough to generate YAML test case drafts.
Goal
This skill generates reviewable YAML API test cases. It does not execute requests, create real accounts, generate real passwords or tokens, or enable high-risk operations by default.
Inputs
Supported inputs:
openapi.json
openapi.yaml / openapi.yml
- Optional
confirmed_contract.yaml
- Optional
api_change_diff.json generated by api_contract_checker --base ... --input ...
- Optional module filter, such as
auth, user, projects, or scenes
Recommended full pipeline:
python3 skills/openapi_api_analyzer/scripts/parse_openapi.py openapi.yaml --output-dir output/interfaces
python3 skills/api_contract_checker/scripts/check_contract.py --input openapi.yaml --output-dir output/contract
python3 skills/yaml_case_generator/scripts/generate_yaml_cases.py \
--openapi openapi.yaml \
--contract confirmed_contract.yaml \
--module auth \
--output cases/auth/auth_cases.yaml
Incremental V6 pipeline:
python3 skills/api_contract_checker/scripts/check_contract.py \
--base openapi.base.yaml \
--input openapi.current.yaml \
--output-dir output/contract-diff
python3 skills/yaml_case_generator/scripts/generate_yaml_cases.py \
--openapi openapi.current.yaml \
--contract confirmed_contract.yaml \
--diff output/contract-diff/api_change_diff.json \
--output cases/changed_cases.yaml
Outputs
The main output is a YAML case file, for example:
cases/auth/auth_cases.yaml
When contract gaps are detected, the same output contains disabled cases with:
enabled: false
needs_contract: true
contract_todo
YAML Case Structure
Each generated case contains:
id
name
module
priority
type
enabled
needs_contract
request
asserts
- optional
extract
- optional
cleanup
- optional
contract_todo
- optional
risk
Contract Supplement
OpenAPI often contains empty DTOs. Put confirmed fields in confirmed_contract.yaml:
contracts:
LoginPasswordDto:
fields:
identifier:
type: string
required: true
example: "${accounts.registered_user.identifier}"
password:
type: string
required: true
example: "${accounts.registered_user.password}"
global:
success_code_path: "$.code"
success_code_value: 0
token_header_template: "Bearer ${accessToken}"
Confirmed contract fields override OpenAPI DTO fields. If an operation has a request DTO but neither OpenAPI nor the confirmed contract defines fields, the generated case is disabled and marked needs_contract: true.
Generation Rules
- Generate positive single-interface case drafts for matching operations.
- Add default
status_code assertion.
- Add unified response assertion when
global.success_code_path is configured, defaulting to $.code == 0.
- Add login, refresh-token, user-info, list, and create extracts/asserts when the path or summary matches common patterns.
- Add
Authorization: Bearer ${accessToken} when the operation requires bearer auth.
- Disable high-risk delete/deactivate/account-cancel cases by default.
- Third-party login cases are disabled and marked as needing mock contract confirmation unless supplemented manually.
- If
--diff is provided, only added and changed method + path entries are generated. removed entries are ignored.
Usage
Generate all cases:
python3 skills/yaml_case_generator/scripts/generate_yaml_cases.py \
--openapi openapi.yaml \
--contract confirmed_contract.yaml \
--output cases/api_cases.yaml
Generate one module:
python3 skills/yaml_case_generator/scripts/generate_yaml_cases.py \
--openapi openapi.yaml \
--contract confirmed_contract.yaml \
--module auth \
--output cases/auth/auth_cases.yaml \
--with-auth-flow
Generate only added/changed interfaces:
python3 skills/yaml_case_generator/scripts/generate_yaml_cases.py \
--openapi openapi.current.yaml \
--contract confirmed_contract.yaml \
--diff output/contract-diff/api_change_diff.json \
--output cases/changed_cases.yaml
Dependencies
python3 -m pip install pyyaml
Next Skill
After generating YAML drafts, run yaml_case_linter before committing or executing them:
python3 skills/yaml_case_linter/scripts/lint_yaml_cases.py \
--input cases \
--output-dir output/yaml-lint