Skip to content

fix: paginated JSON output, regenerate API client, add JSON Schema support#93

Merged
glimow merged 15 commits intomainfrom
fix/paginated-json-output
Mar 28, 2026
Merged

fix: paginated JSON output, regenerate API client, add JSON Schema support#93
glimow merged 15 commits intomainfrom
fix/paginated-json-output

Conversation

@glimow
Copy link
Copy Markdown
Member

@glimow glimow commented Mar 26, 2026

Summary

  • Fix paginated JSON output — All list commands (scans, issues, assets, profiles, audit, events, locations, problems) were emitting one JSON array per page. Now accumulates all pages before printing, producing valid JSON.
  • Regenerate API client from latest OpenAPI spec — Fixes PRIVATE enum deserialization error that broke assets list, issues list, and profiles list --all. Updates 763 generated files.
  • Fix convert.py — Handle null values in enum arrays from the updated spec.
  • Add JSON Schema output (-o schema) — New output format for AI agent integration that returns the JSON Schema of command output.
  • Add --input-schema flag — Shows expected stdin JSON Schema for create/update commands.
  • Add schema generation packagepkg/cli/schema/ with comprehensive tests.

Test plan

  • scans list with 268 results (3 pages) emits single valid JSON array
  • assets list returns 239 items (previously crashed on PRIVATE enum)
  • issues list returns 1721 items (previously crashed on PRIVATE enum)
  • profiles list --all returns 243 items (previously crashed)
  • audit list, events list, locations list, problems all return valid JSON
  • go test ./... passes
  • go build ./... clean
  • Verify -o schema output on list/get commands
  • Verify --input-schema on create commands

Tristan Kalos (Glimow) and others added 5 commits March 26, 2026 18:50
Add a new `-o schema` output format that generates JSON Schema for
command output types. This enables AI agents and automation tools to
programmatically discover the structure of CLI command outputs without
needing to execute commands or maintain external documentation.

Changes:
- Add pkg/cli/schema package with reflection-based schema generation
- Add `schema` output format option to all commands
- Update help text to document the new output format

Usage: escape-cli <command> -o schema

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add exhaustive case handling for all reflect.Kind values to satisfy
the exhaustive linter. Cases already handled above the switch (Pointer,
Slice, Array, Map) are included for completeness.
Add support for AI agents to discover input JSON Schema for commands
that accept stdin input. This complements the existing -o schema flag
which shows output schemas.

Changes:
- Add --input-schema global flag to root command
- Add InputSchema function to out package
- Update create/update commands to support --input-schema:
  - profiles create-rest, create-webapp, create-graphql
  - custom-rules create, update
  - assets create
- Document AI agent integration flags in help text
Paginated list commands were calling out.Table() once per page,
emitting multiple JSON arrays to stdout (e.g. [...]\n[...]\n[...]).
This broke any JSON parser consuming -o json output.

Now all pages are collected into a single slice before printing,
producing one valid JSON array regardless of pagination.

Affected commands: scans list, issues list, assets list, profiles list,
audit list, events list, locations list, problems list.
@glimow glimow requested a review from QuentinN42 as a code owner March 26, 2026 22:26
Tristan Kalos (Glimow) added 2 commits March 27, 2026 00:27
- Regenerate pkg/api/v3/ from latest public.escape.tech/v3/openapi.json
- Fix PRIVATE enum deserialization error that broke assets list, issues list,
  and profiles list --all
- Fix convert.py to handle null values in enum arrays from updated spec
- Update wrapper layer (pkg/api/escape/) for renamed response types
  (ScanDetailed1 → StartScan200Response, ProfileDetailed → GetProfile200Response, etc.)
Merge schema output and input-schema features, resolving conflicts
with pagination fixes and regenerated API types.
@glimow glimow changed the title fix: paginated list commands emit valid JSON fix: paginated JSON output, regenerate API client, add JSON Schema support Mar 26, 2026
glimow and others added 8 commits March 26, 2026 23:30
events list with no --levels flag was silently defaulting to ERROR only,
hiding all INFO/WARNING/DEBUG events. Now returns all levels by default.
- `profiles update` - update metadata (name, description, cron) via flags or stdin JSON
- `profiles update-configuration` - update scan config (auth, scope, frontend_dast) via stdin JSON

Closes the feature gap that required the web UI or direct API calls
to modify profile configuration.
Allows replacing the API schema (OpenAPI, Postman, GraphQL) attached to
a profile. Works with the existing upload schema command:
  1. escape-cli upload schema < spec.json
  2. escape-cli profiles update-schema <profile-id> <schema-id>
Adds a comprehensive E2E test infrastructure using go-internal/testscript
with 10 test suites covering auth, CRUD lifecycles (tags, assets, profiles,
scans), output formats, error paths, and read-only endpoints.

Tests run against the live Escape API behind the e2e build tag and require
E2E_API_KEY to be set. CI job added to pr.yaml (runs after unit tests).
Use exec.CommandContext, suppress os.RemoveAll error, rename unused
parameters to _ (required by testscript function signature).
Use errors.New for static error strings, suppress magic number lint
for cobra.ExactArgs(2).
@glimow glimow merged commit c6a9b9a into main Mar 28, 2026
17 checks passed
@glimow glimow deleted the fix/paginated-json-output branch March 28, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant