api: serve interactive OpenAPI docs at /api/docs (offline) + llms.txt
Generate docs/openapi.json (3.1, 362 operations) from the API inventory via scripts/gen_openapi.py, and serve it with a self-hosted Redoc bundle at /api/docs - no CDN, works on the air-gapped box. Also serve docs/llms.txt (a concise LLM entrypoint) at /api/docs/llms.txt. New core 'docs' blueprint; staticdocs/ excluded from the naming check (vendored minified JS).
This commit is contained in:
58
docs/llms.txt
Normal file
58
docs/llms.txt
Normal file
@@ -0,0 +1,58 @@
|
||||
# ShopDB Flask API - LLM guide
|
||||
|
||||
ShopDB is a plugin-based asset-management system (PCs, printers, machines,
|
||||
network devices, measuring tools, applications, knowledge base, USB, warranties)
|
||||
for GE Aerospace sites. This file is the quick entrypoint; the full machine
|
||||
spec is the OpenAPI at `/api/docs/openapi.json` (browse it at `/api/docs`).
|
||||
|
||||
## Base URL
|
||||
Prod (West Jefferson): `https://tsgwp00525.wjs.geaerospace.net/shopdb`
|
||||
All API paths are under `/api` (e.g. `<base>/api/assets`). Dev: `http://localhost:5001`.
|
||||
|
||||
## Auth
|
||||
Three schemes:
|
||||
- **Bearer JWT** - most endpoints. Get one by logging in, or use a managed
|
||||
Personal Access Token (PAT). Send `Authorization: Bearer <token>`.
|
||||
- Login: `POST /api/auth/login` `{ "username": "...", "password": "..." }`
|
||||
-> `data.access_token`. Refresh: `POST /api/auth/refresh`.
|
||||
- PATs are minted in the UI (Settings > API Tokens); a *scoped* PAT is limited
|
||||
to named permissions and suspends the admin bypass.
|
||||
- **X-API-Key** - unattended/service endpoints (collector ingest, GE-Enforce
|
||||
fetch). Send `X-API-Key: <managed-token>`.
|
||||
- **Public** - some read endpoints (e.g. printer install-list, employee search,
|
||||
dashboards) need no auth.
|
||||
|
||||
Auth level per endpoint is in the OpenAPI `security` field: `bearerAuth`,
|
||||
`apiKeyAuth`, or none. Admin-only and permission-gated routes both use bearer.
|
||||
|
||||
## Response envelope
|
||||
JSON endpoints return `{ "status": "success", "data": <payload>, "meta": {...} }`.
|
||||
Errors: `{ "status": "error", "message": "...", "code": "..." }` with an HTTP 4xx/5xx.
|
||||
Lists include `meta.total` / pagination. A few feed endpoints (screensaver, some
|
||||
installer text formats) return raw text/JSON without the envelope - noted per route.
|
||||
|
||||
## Common recipes
|
||||
- Search everything: `GET /api/search?q=<term>` (multi-word = AND across words).
|
||||
- List assets on the map: `GET /api/assets/map`.
|
||||
- List a type: `GET /api/printers`, `/api/computers`, `/api/machines`,
|
||||
`/api/network`, `/api/measuringtools` (paginated: `?page=&perpage=`).
|
||||
- Get one: `GET /api/printers/<id>` etc.
|
||||
- Create (bearer): `POST /api/printers` `{assetnumber, windowsname, vendorid, ...}`.
|
||||
- Reports: `GET /api/reports` (list), `GET /api/reports/pc-relationships` (PC<->machine).
|
||||
- Printer installer data: `GET /api/printers/install-list` (public; add
|
||||
`?format=text` for a pipe-delimited variant); `GET /api/printers/pc-default?machine=<n>`.
|
||||
- Collector ingest (X-API-Key): `POST /api/collector/computers`.
|
||||
- GE-Enforce: `GET /api/geenforce/manifest?pctype=<scope>`,
|
||||
`GET /api/geenforce/payload/<sha256>`, `POST /api/geenforce/report`.
|
||||
- Import (admin PAT, preserves timestamps with `X-Import-Mode`): see docs/IMPORT-API.md.
|
||||
|
||||
## Conventions
|
||||
- DB-mirrored params/fields use lowercase concatenated names (no underscores):
|
||||
`locationid`, `vendorid`, `windowsname` - match them exactly.
|
||||
- IDs in paths are integers.
|
||||
- Plugin endpoints live under the plugin's prefix (`/api/<plugin>/...`).
|
||||
|
||||
## Full reference
|
||||
- Machine spec: `GET /api/docs/openapi.json` (OpenAPI 3.1, 362 operations).
|
||||
- Interactive: `GET /api/docs` (Redoc).
|
||||
- Human reference: `docs/API-REFERENCE.md`.
|
||||
Reference in New Issue
Block a user