Ajiro API

v0.2.3
io.github.NITI-Lab/ajiro-api Checked 6 hours ago Published 13 days ago

Scan backend routes into per-endpoint YAML, run them as API regression tests and serve mocks.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

scan

Statically analyse the backend source and create/update the per-endpoint YAML files in api/. Run it after adding, removing or changing routes. Only `request` and `source` are managed by scan; `tests`, `mock`, summaries you wrote are preserved. Returns created/updated/unchanged counts, the list of endpoints with their YAML files and source locations, and `stale` files whose route no longer exists (never deleted automatically). Use dry_run to preview.

ParameterTypeDescription
dry_runbooleanReport what would change without writing files.
frameworkstringForce a framework instead of auto-detection: nextjs, hono, fastapi, express, go-nethttp, go-chi, go-echo.
pathsarrayDirectories or files to scan, relative to the project root (default: `sources` in ajiro-api.yaml).

test

Run the requests defined in the endpoint YAML files against the running API and check the responses. Returns a report: summary counts and one result per test; each failure has `check`, `path`, `expected`, `actual`, a one-line `message`, and the handler `source` (file:line) so you can jump to the code. The server under test must already be running at the environment's base_url. A failing test is reported in the result (ok=false), not as a tool error.

ParameterTypeDescription
base_urlstringOverride the environment base URL, e.g. http://localhost:8080.
envstringEnvironment name from ajiro-api.yaml (default: default_env).
filterstringOnly run endpoints/tests whose id, file or test name contains this text, e.g. `users.create`.
smoke_unsafebooleanAlso send the implicit smoke request to endpoints without tests whose method may change data (POST, PUT, PATCH, DELETE). Off by default; do not enable against shared or production environments.
update_snapshotsbooleanOverwrite stored snapshots with the actual responses. Only use when the new behaviour is intended.

list

List all endpoints defined in the api/ directory: id, method, path, YAML file, number of tests, source location and summary. Also reports files that failed to load. Use it to find the id to pass to get_endpoint or test.filter.

validate

Validate all endpoint YAML files without calling the API: YAML syntax, schema, duplicate ids, unknown depends_on, unsupported methods. Run it after editing YAML files. Returns {ok, errors:[{file,message}]}.

get_endpoint

Read one endpoint definition by id (as shown by `list`). Returns the YAML text, its relative file and absolute path, so you can edit the file (for example to add tests).

ParameterTypeDescription
id *stringEndpoint id, e.g. `users.create`.

schema

Return the JSON Schema of the YAML formats: `endpoint` for api/**/*.yaml files (request, tests, expect matchers, mock) or `config` for ajiro-api.yaml. Read it before writing or editing tests.

ParameterTypeDescription
which *stringWhich schema to return.