Skill: xueyetianya/swagger-generator (version 2.0.1)

--- version: "2.0.0" name: swagger-generator description: "Generate OpenAPI 3.0 specs from endpoint descriptions. Use when validating APIs, generating docs, formatting YAML, checking schemas, linting contracts." author: BytesAgain homepage: https://bytesagain.com source: https://github.com/bytesagain/ai-skills --- # swagger-generator Generate complete OpenAPI 3.0/Swagger specification documents from endpoint descriptions. Supports RESTful API documentation with path definitions, request/response schemas, authentication schemes (Bearer JWT, API Key, OAuth2), error responses, pagination, filtering, and example values. Outputs valid YAML or JSON specs that can be rendered by Swagger UI, Redoc, or imported into Postman. Includes model generation, tag grouping, and server configuration. ## Commands | Command | Description | |---------|-------------| | `spec` | Generate a complete OpenAPI spec from API description | | `endpoint` | Generate a single endpoint definition | | `model` | Generate a schema/model definition | | `crud` | Generate CRUD endpoints for a resource | | `auth` | Generate authentication scheme definitions | | `error` | Generate standardized error response schemas | | `server` | Generate server configuration (dev/staging/prod) | | `tag` | Generate tag definitions for API grouping | | `merge` | Merge multiple endpoint definitions into one spec | ## Usage ``` # Generate complete API spec swagger-generator spec --title "My API" --version "1.0.0" --description "REST API for my app" # Generate CRUD endpoints for a resource swagger-generator crud --resource User --fields "id:integer,name:string,email:string" # Generate single endpoint swagger-generator endpoint --method POST --path "/users" --body "name:string,email:string" --response "User" # Generate model/schema swagger-generator model --name Product --fields "id:integer,name:string,price:number,category:string" # Add authentication swagger-generator auth --scheme bearer --format jwt # Generate error responses swagger-generator error --codes "400,401,403,404,422,500" # Server configuration swagger-generator server --envs "dev,staging,production" --base-url "api.example.com" ``` ## Examples ### E-commerce API ``` swagger-generator spec --title "E-commerce API" --resources "products,orders,users,categories" ``` ### Blog API ``` swagger-generator crud --resource Post --fields "id:integer,title:string,body:string,author_id:integer,status:string" ``` ### Microservice API ``` swagger-generator spec --title "Payment Service" --auth bearer --resources "payments,refunds,webhooks" ``` ## Features - **OpenAPI 3.0** — Generates valid OpenAPI 3.0.3 specifications - **CRUD generation** — Complete REST endpoints for any resource - **Authentication** — Bearer JWT, API Key, OAuth2 schemes - **Models** — JSON Schema-based model definitions - **Error handling** — Standardized error response patterns - **Pagination** — Cursor and offset pagination parameters - **Examples** — Request/response example values - **Tags** — Logical API endpoint grouping ## Keywords swagger, openapi, api documentation, rest api, api spec, api design, documentation, endpoints, schema, backend --- 💬 Feedback & Feature Requests: https://bytesagain.com/feedback Powered by BytesAgain | bytesagain.com

path: scripts/script.sh
content: #!/usr/bin/env bash
# Swagger Generator — devtools tool
# Powered by BytesAgain | bytesagain.com | [REDACTED_SECRET]
set -euo pipefail

DATA_DIR="${HOME}/.local/share/swagger-generator"
mkdir -p "$DATA_DIR"

_log() { echo "$(date '+%m-%d %H:%M') $1: $2" >> "$DATA_DIR/history.log"; }

_version() { echo "swagger-generator v2.0.0"; }

_help() {
    echo "Swagger Generator v2.0.0 — devtools toolkit"
    echo ""
    echo "Usage: swagger-generator <command> [args]"
    echo ""
    echo "Commands:"
    echo "  check              Check"
    echo "  validate           Validate"
    echo "  generate           Generate"
    echo "  format             Format"
    echo "  lint               Lint"
    echo "  explain            Explain"
    echo "  convert            Convert"
    echo "  template           Template"
    echo "  diff               Diff"
    echo "  preview            Preview"
    echo "  fix                Fix"
    echo "  report             Report"
    echo "  stats              Summary statistics"
    echo "  export <fmt>       Export (json|csv|txt)"
    echo "  status             Health check"
    echo "  help               Show this help"
    echo "  version            Show version"
    echo ""
    echo "Data: $DATA_DIR"
}

_stats() {
    echo "=== Swagger Generator Stats ==="
    local total=0
    for f in "$DATA_DIR"/*.log; do
        [ -f "$f" ] || continue
        local name=$(basename "$f" .log)
        local c=$(wc -l < "$f")
        total=$((total + c))
        echo "  $name: $c entries"
    done
    echo "  ---"
    echo "  Total: $total entries"
    echo "  Data size: $(du -sh "$DATA_DIR" 2>/dev/null | cut -f1)"
    echo "  Since: $(head -1 "$DATA_DIR/history.log" 2>/dev/null | cut -d'|' -f1 || echo 'N/A')"
}

_export() {
    local fmt="${1:-json}"
    local out="$DATA_DIR/export.$fmt"
    case "$fmt" in
        json)
            echo "[" > "$out"
            local first=1
            for f in "$DATA_DIR"/*.log; do
                [ -f "$f" ] || continue
                local name=$(basename "$f" .log)
                while IFS='|' read -r ts val; do
                    [ $first -eq 1 ] && first=0 || echo "," >> "$out"
                    printf '  {"type":"%s","time":"%s","value":"%s"}' "$name" "$ts" "$val" >> "$out"
                done < "$f"
            done
            echo "" >> "$out"
            echo "]" >> "$out"
            ;;
        csv)
            echo "type,time,value" > "$out"
            for f in "$DATA_DIR"/*.log; do
                [ -f "$f" ] || continue
                local name=$(basename "$f" .log)
                while IFS='|' read -r ts val; do
                    echo "$name,$ts,$val" >> "$out"
                done < "$f"
            done
            ;;
        txt)
            echo "=== Swagger Generator Export ===" > "$out"
            for f in "$DATA_DIR"/*.log; do
                [ -f "$f" ] || continue
                echo "--- $(basename "$f" .log) ---" >> "$out"
                cat "$f" >> "$out"
                echo "" >> "$out"
            done
            ;;
        *) echo "Formats: json, csv, txt"; return 1 ;;
    esac
    echo "Exported to $out ($(wc -c < "$out") bytes)"
}

_status() {
    echo "=== Swagger Generator Status ==="
    echo "  Version: v2.0.0"
    echo "  Data dir: $DATA_DIR"
    echo "  Entries: $(cat "$DATA_DIR"/*.log 2>/dev/null | wc -l) total"
    echo "  Disk: $(du -sh "$DATA_DIR" 2>/dev/null | cut -f1)"
    local last=$(tail -1 "$DATA_DIR/history.log" 2>/dev/null || echo "never")
    echo "  Last activity: $last"
    echo "  Status: OK"
}

_search() {
    local term="${1:?Usage: swagger-generator search <term>}"
    echo "Searching for: $term"
    local found=0
    for f in "$DATA_DIR"/*.log; do
        [ -f "$f" ] || continue
        local matches=$(grep -i "$term" "$f" 2>/dev/null || true)
        if [ -n "$matches" ]; then
            echo "  --- $(basename "$f" .log) ---"
            echo "$matches" | while read -r line; do
                echo "    $line"
                found=$((found + 1))
            done
        fi
    done
    [ $found -eq 0 ] && echo "  No matches found."
}

_recent() {
    echo "=== Recent Activity ==="
    if [ -f "$DATA_DIR/history.log" ]; then
        tail -20 "$DATA_DIR/history.log" | while IFS='' read -r line; do
            echo "  $line"
        done
    else
        echo "  No activity yet."
    fi
}

# Main dispatch
case "${1:-help}" in
    check)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent check entries:"
            tail -20 "$DATA_DIR/check.log" 2>/dev/null || echo "  No entries yet. Use: swagger-generator check <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/check.log"
            local total=$(wc -l < "$DATA_DIR/check.log")
            echo "  [Swagger Generator] check: $input"
            echo "  Saved. Total check entries: $total"
            _log "check" "$input"
        fi
        ;;
    validate)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent validate entries:"
            tail -20 "$DATA_DIR/validate.log" 2>/dev/null || echo "  No entries yet. Use: swagger-generator validate <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/validate.log"
            local total=$(wc -l < "$DATA_DIR/validate.log")
            echo "  [Swagger Generator] validate: $input"
            echo "  Saved. Total validate entries: $total"
            _log "validate" "$input"
        fi
        ;;
    generate)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent generate entries:"
            tail -20 "$DATA_DIR/generate.log" 2>/dev/null || echo "  No entries yet. Use: swagger-generator generate <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/generate.log"
            local total=$(wc -l < "$DATA_DIR/generate.log")
            echo "  [Swagger Generator] generate: $input"
            echo "  Saved. Total generate entries: $total"
            _log "generate" "$input"
        fi
        ;;
    format)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent format entries:"
            tail -20 "$DATA_DIR/format.log" 2>/dev/null || echo "  No entries yet. Use: swagger-generator format <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/format.log"
            local total=$(wc -l < "$DATA_DIR/format.log")
            echo "  [Swagger Generator] format: $input"
            echo "  Saved. Total format entries: $total"
            _log "format" "$input"
        fi
        ;;
    lint)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent lint entries:"
            tail -20 "$DATA_DIR/lint.log" 2>/dev/null || echo "  No entries yet. Use: swagger-generator lint <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/lint.log"
            local total=$(wc -l < "$DATA_DIR/lint.log")
            echo "  [Swagger Generator] lint: $input"
            echo "  Saved. Total lint entries: $total"
            _log "lint" "$input"
        fi
        ;;
    explain)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent explain entries:"
            tail -20 "$DATA_DIR/explain.log" 2>/dev/null || echo "  No entries yet. Use: swagger-generator explain <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/explain.log"
            local total=$(wc -l < "$DATA_DIR/explain.log")
            echo "  [Swagger Generator] explain: $input"
            echo "  Saved. Total explain entries: $total"
            _log "explain" "$input"
        fi
        ;;
    convert)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent convert entries:"
            tail -20 "$DATA_DIR/convert.log" 2>/dev/null || echo "  No entries yet. Use: swagger-generator convert <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/convert.log"
            local total=$(wc -l < "$DATA_DIR/convert.log")
            echo "  [Swagger Generator] convert: $input"
            echo "  Saved. Total convert entries: $total"
            _log "convert" "$input"
        fi
        ;;
    template)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent template entries:"
            tail -20 "$DATA_DIR/template.log" 2>/dev/null || echo "  No entries yet. Use: swagger-generator template <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/template.log"
            local total=$(wc -l < "$DATA_DIR/template.log")
            echo "  [Swagger Generator] template: $input"
            echo "  Saved. Total template entries: $total"
            _log "template" "$input"
        fi
        ;;
    diff)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent diff entries:"
            tail -20 "$DATA_DIR/diff.log" 2>/dev/null || echo "  No entries yet. Use: swagger-generator diff <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/diff.log"
            local total=$(wc -l < "$DATA_DIR/diff.log")
            echo "  [Swagger Generator] diff: $input"
            echo "  Saved. Total diff entries: $total"
            _log "diff" "$input"
        fi
        ;;
    preview)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent preview entries:"
            tail -20 "$DATA_DIR/preview.log" 2>/dev/null || echo "  No entries yet. Use: swagger-generator preview <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/preview.log"
            local total=$(wc -l < "$DATA_DIR/preview.log")
            echo "  [Swagger Generator] preview: $input"
            echo "  Saved. Total preview entries: $total"
            _log "preview" "$input"
        fi
        ;;
    fix)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent fix entries:"
            tail -20 "$DATA_DIR/fix.log" 2>/dev/null || echo "  No entries yet. Use: swagger-generator fix <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/fix.log"
            local total=$(wc -l < "$DATA_DIR/fix.log")
            echo "  [Swagger Generator] fix: $input"
            echo "  Saved. Total fix entries: $total"
            _log "fix" "$input"
        fi
        ;;
    report)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent report entries:"
            tail -20 "$DATA_DIR/report.log" 2>/dev/null || echo "  No entries yet. Use: swagger-generator report <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/report.log"
            local total=$(wc -l < "$DATA_DIR/report.log")
            echo "  [Swagger Generator] report: $input"
            echo "  Saved. Total report entries: $total"
            _log "report" "$input"
        fi
        ;;
    stats) _stats ;;
    export) shift; _export "$@" ;;
    search) shift; _search "$@" ;;
    recent) _recent ;;
    status) _status ;;
    help|--help|-h) _help ;;
    version|--version|-v) _version ;;
    *)
        echo "Unknown command: $1"
        echo "Run 'swagger-generator help' for available commands."
        exit 1
        ;;
esac

Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (CRITICAL)