Maintaining these docs
Commands
| Command | What it does |
|---|---|
npm install | Install (Node 20+). |
npm start | Dev server with hot reload at http://localhost:3000. Runs extract + coverage first. |
npm run build | Static site in build/ (host anywhere: IIS, S3, Netlify, GitHub Pages). Runs extract + strict coverage first. |
npm run serve | Serve the built site locally. |
npm run extract | Re-read the HRMS.WebAPI source into src/data/api.json. Default source: ../HRMS.WebAPI/HRMS.WebAPI; pass another path with npm run extract -- <path>. |
npm run coverage | Check that every in-scope endpoint is documented or excluded. --strict fails on unaccounted endpoints. |
Build against the branch the app will run on (today feature/mobile-changes of HRMS.WebAPI): check it out in ../HRMS.WebAPI before npm run build.
What is generated and what is written by hand
| Generated from code (never edit by hand) | Written by hand |
|---|---|
| Routes, HTTP methods, auth/admin flags | Guide pages (docs/guide) |
| Parameters and where they go (path/query/body) | Section intros, flows and per-endpoint notes (docs/api) |
| Request/response field names (camelCase), types, enums | Example values (merged over generated examples) |
| Validation/error messages the server can return | scripts/excluded-endpoints.json reasons |
| Types & enums page, endpoint index, coverage |
When the API changes
npm run extract, thennpm run coverage.- A new endpoint in an in-scope controller shows up as "unaccounted": document it on the right section page with an
Endpointcomponent whoseidis the route (for exampleLeaveApplication/GetAllLeaveApplications), under a heading with an explicit{#anchor}, or add it toscripts/excluded-endpoints.jsonwith a reason. - A removed or renamed endpoint fails the build ("unknown endpoint id"): update the page.
- Changed fields, types and error messages update automatically; re-read the hand-written notes for that endpoint.
- New behaviour rules: update Server rules and Known API gaps.
How the extractor works
scripts/extract-api.mjs parses the C# source (no compilation):
- Controllers:
[Route]+[HttpGet/Post/…("template")],[Authorize]/[AllowAnonymous],[CanAccessFilter]. - Parameter binding follows
[ApiController]:[FromX]wins; complex types → body; simple types → route if named in the template, else query. - JSON names use Newtonsoft's camelCase algorithm; enums are numbers;
[JsonProperty]/[JsonIgnore]are honoured. - Duplicate class names in different namespaces are resolved with the file's
usingdirectives. - Error messages: follows the controller → service interface → implementation → method (and same-class helpers, two levels) and collects
ApiValidationResponse/ApiErrorResponsemessages, resolvingconst stringmessages.
Things it cannot see: logic inside stored procedures, messages built at runtime, and stored procedures that exist only in the database. Those are covered in the hand-written notes where they matter.