Skip to main content

Maintaining these docs

Commands​

CommandWhat it does
npm installInstall (Node 20+).
npm startDev server with hot reload at http://localhost:3000. Runs extract + coverage first.
npm run buildStatic site in build/ (host anywhere: IIS, S3, Netlify, GitHub Pages). Runs extract + strict coverage first.
npm run serveServe the built site locally.
npm run extractRe-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 coverageCheck 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 flagsGuide 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, enumsExample values (merged over generated examples)
Validation/error messages the server can returnscripts/excluded-endpoints.json reasons
Types & enums page, endpoint index, coverage

When the API changes​

  1. npm run extract, then npm run coverage.
  2. A new endpoint in an in-scope controller shows up as "unaccounted": document it on the right section page with an Endpoint component whose id is the route (for example LeaveApplication/GetAllLeaveApplications), under a heading with an explicit {#anchor}, or add it to scripts/excluded-endpoints.json with a reason.
  3. A removed or renamed endpoint fails the build ("unknown endpoint id"): update the page.
  4. Changed fields, types and error messages update automatically; re-read the hand-written notes for that endpoint.
  5. 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 using directives.
  • Error messages: follows the controller → service interface → implementation → method (and same-class helpers, two levels) and collects ApiValidationResponse/ApiErrorResponse messages, resolving const string messages.

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.