← NightVisionCONTENT HISTORYWHAT CHANGED · RULE-BASED ANALYSIS
Update to NightVision
Snapshot Sep 30, 2026 · 23:13 UTC · version 0.2.0
Collection source: not recorded for this historical snapshot.
First saved snapshot
No earlier snapshot is available to establish a change.
Compare saved observations
Download comparison JSONFull technical diff · 0 changed fields
Full snapshot data
{
"name": "api-discovery",
"description": "Guide for agents to help users extract OpenAPI specs from source code using NightVision API Discovery. Use when running swagger extract, identifying framework support, troubleshooting extraction, handling unresolved variables, comparing API specs, or understanding Code Traceback.",
"included_files": [
{
"relative_path": "references/framework-support.md",
"size_in_bytes": 4028
}
],
"skill_md_contents": "---\nname: api-discovery\ndescription: Guide for agents to help users extract OpenAPI specs from source code using NightVision API Discovery. Use when running swagger extract, identifying framework support, troubleshooting extraction, handling unresolved variables, comparing API specs, or understanding Code Traceback.\nallowed-tools: Bash\n---\n\n# NightVision API Discovery\n\nUse this skill when helping users generate OpenAPI specifications from their source code using `nightvision swagger extract`. API Discovery performs static analysis — no running application or compilation needed — and annotates the spec with source file paths and line numbers (Code Traceback) so that vulnerabilities found during DAST scans trace back to exact code locations.\n\n## Agent workflow\n\nWhen a user asks to extract or document their API:\n\n1. **Check prerequisites** — verify the NightVision CLI is available (`nightvision --help`)\n2. **Examine the repo** — identify the backend language and web framework to determine the `--lang` flag and whether the framework is supported (see [references/framework-support.md](references/framework-support.md))\n3. **Run extraction** — execute `nightvision swagger extract` with the appropriate flags. On success, the CLI prints `\"Swagger file extracted successfully.\"` and writes the spec to the output path (default: `openapi-spec.yml`)\n4. **Review the output** — read the generated spec to check completeness. Handle unresolved variables if `nv.config` was created alongside the spec\n5. **Compare coverage** — if the user has an existing spec, run `nightvision swagger diff` to show what was discovered vs. what was documented\n6. **Upload to target** — attach the spec to a NightVision target for scanning\n\n**Related skills:** Use `scan-configuration` for target/auth setup, `ci-cd-integration` for pipeline integration, `scan-triage` for interpreting scan results.\n\n## Language flags\n\n| Language | Flag | Frameworks |\n|----------|------|------------|\n| Python | `--lang python` | Django, DRF, Flask, Flask-RESTful, FastAPI |\n| Java | `--lang java` | Spring Boot, JAX-RS/Jersey, Micronaut, Java EE/Jakarta EE |\n| JavaScript | `--lang js` | Express, NestJS, Fastify |\n| C# | `--lang dotnet` | ASP.NET Core (controllers, minimal APIs) |\n| Go | `--lang go` | Gin, httprouter, net/http (experimental) |\n| Ruby | `--lang ruby` | Rails, Grape |\n\nSee [references/framework-support.md](references/framework-support.md) for detailed component coverage per framework.\n\n## Running extraction\n\n```bash\n# Basic extraction (output defaults to openapi-spec.yml)\nnightvision swagger extract . --lang python\n\n# Specify output file and format\nnightvision swagger extract . --lang java -o api-spec.json --file-format json\n\n# Extract and upload directly to a NightVision target\nnightvision swagger extract . -t my-api -p my-project --lang python\n\n# Extract without uploading\nnightvision swagger extract . -o openapi-spec.yml --lang java --no-upload\n\n# Scan multiple source directories\nnightvision swagger extract ./service-a ./service-b --lang python\n\n# Extend an existing spec (add discovered endpoints to it)\nnightvision swagger extract . --lang python --extend existing-spec.yml\n\n# Exclude directories from analysis\nnightvision swagger extract . --lang python --exclude vendor,generated\n\n# Include code snippets in the spec (useful for debugging)\nnightvision swagger extract . --lang python --dump-code\n```\n\n### Extraction fallback for CI\n\nExtraction can fail if language detection fails or the framework isn't supported. Always guard against this in pipelines:\n\n```bash\nnightvision swagger extract . -t $TARGET --lang java || true\nif [ ! -e openapi-spec.yml ]; then cp backup-openapi-spec.yml openapi-spec.yml; fi\n```\n\n## Handling unresolved variables\n\nWhen static analysis can't resolve a variable (e.g., an API prefix read from an environment variable), it appears as a literal placeholder in the spec. NightVision generates an `nv.config` file to fix this.\n\n**Steps:**\n1. Run extraction — if unresolved variables exist, `nv.config` is created alongside the spec (in the first source directory passed to the command)\n2. Open `nv.config` — find the `replacements` object with `null` values\n3. Replace `null` with the actual values (check the app's config files, environment vars, etc.)\n4. Re-run extraction — the tool reads `nv.config` and substitutes the values. You can also use `-c` / `--config` to explicitly specify the config file path: `nightvision swagger extract . --lang python -c path/to/nv.config`\n\n```json\n// nv.config example\n{\n \"replacements\": {\n \"Microsoft.AspNetCore.Builder.WebApplication.Services...ApiPrefix\": null\n }\n}\n```\n\nThe agent should help the user find the actual value by searching their config files (`appsettings.json`, `.env`, `settings.py`, etc.) and updating `nv.config`.\n\n## Comparing API specs\n\nUse `swagger diff` to measure coverage or detect breaking changes:\n\n```bash\n# Summary diff (paths and schemas counts)\nnightvision swagger diff original-spec.yml discovered-spec.yml\n\n# Show only path-level changes (endpoints added/removed/modified)\nnightvision swagger diff original-spec.yml discovered-spec.yml --paths\n\n# Show only schema changes\nnightvision swagger diff original-spec.yml discovered-spec.yml --schemas\n\n# Show the full diff (paths and schemas together, with details)\nnightvision swagger diff original-spec.yml discovered-spec.yml --full-diff\n\n# Save diff output to file\nnightvision swagger diff original-spec.yml discovered-spec.yml -o diff-report.txt\n```\n\nCommon use cases:\n- **Coverage analysis** — compare a hand-written spec against the discovered one to find undocumented shadow APIs\n- **PR checks** — diff specs from the base branch vs. PR branch to detect breaking API changes\n- **Audit** — verify that all endpoints are documented\n\n## Detecting existing specs\n\nSearch the codebase for existing OpenAPI/Swagger files. The `detect` command takes no positional arguments — use `-p` to specify the root folder:\n\n```bash\n# Detect project roots in the current directory\nnightvision swagger detect\n\n# Detect in a specific directory\nnightvision swagger detect -p ./path/to/code\n\n# Save detection results as JSON\nnightvision swagger detect -o detection-results.json\n```\n\n## Code Traceback\n\nThe generated spec includes `x-source` annotations on each endpoint with the file path and line number where the route is declared. When this spec is used for DAST scanning:\n\n- Vulnerabilities found by NightVision link directly to the source code\n- GitHub Security Alerts, Azure Boards work items, and Jenkins Warnings show the exact file and line\n- Developers see where to fix, not just what to fix\n\nThis is why using NightVision-generated specs (vs. hand-written ones) significantly improves the triage experience.\n\n## Troubleshooting\n\n| Issue | Cause | Fix |\n|-------|-------|-----|\n| No endpoints found | Wrong `--lang` flag, or unsupported framework | Verify the framework is supported, check `--lang` value |\n| Unresolved variables in paths | Config values read from env vars without defaults | Fill in `nv.config` replacements and re-run |\n| Incomplete routes | Custom routing, non-standard framework usage | NightVision relies on standard framework patterns; custom routing may not be detected |\n| Extraction fails entirely | Syntax errors in source, missing files | Use `--diagnostics` to get language-level error details |\n| Spec missing sub-routes | Code in subdirectories not scanned | Pass multiple paths: `nightvision swagger extract ./src ./lib` |\n\nFor unsupported frameworks or components, contact support@nightviz.ai.\n"
}SHA-256: 6307e4a4e893754c09b4c3746474946f67c50f1b7ee6b0a41c03e8c5f705d328