OpenAPI/Swagger docs for the Ecom web app and FileManager microservice.
Supplementary API reference for Ecom, covering the Web app and the FileManager microservice in a single OpenAPI 3.0 specification rendered with Swagger UI. Server-rendered pages are out of scope, except for a few read-only ones that the spec documents directly.
- Live docs: https://ecom-api-docs.vercel.app/
- Spec: openapi.yaml (source of truth) / openapi.json (generated)
- Source: thaihadefi/Ecom
The spec's own tag list (storefront, admin, payments, FileManager, site) defines what is covered. Browse it in Swagger UI rather than here.
The spec states these decisions explicitly so readers don't have to infer them from the source:
- REST Level 2. JSON endpoints are plural resources under
/api(storefront) and/admin/api(admin), and the HTTP method states the action:POSTcreates,PUT/PATCHchange,DELETEremoves, andGETnever writes. Payment and OAuth callbacks keep the URLs their providers call. - Response convention. Success is HTTP 200 with
{ "code": "success", ... }. Errors use the matching status (400/401/403/404/409/429/500/502/503) with{ "code": "error", "message": "..." }. JSON endpoints never redirect: an unauthenticated or unauthorized request gets 401/403 whatever the method, and only server-rendered pages redirect to login. - Auth. Browsers use the
tokenUser/tokenAdminHTTP-only cookies. API clients useAuthorization: Bearer <accessToken>, which the login endpoints return. A request carrying that header is authenticated by the header alone. FileManager's/filesand/foldersuseAuthorization: Bearer <FILE_MANAGER_SECRET>. - Try it out. The
serversentry ishttp://localhost:3000because neither service is deployed publicly yet, so "Try it out" only reaches a copy of Ecom you have running. The Web app sends CORS headers on non-admin routes, so the Vercel copy can reach a local storefront with a Bearer token: log in, then paste the returnedaccessTokenunder "Authorize". Admin endpoints skip CORS on purpose, so try those from the same-origin copy at/api-docs/, where the browser sends the login cookie automatically. - Verified, not just written.
yarn verifydiffs the spec against the Ecom source: routes, required auth, Joi constraints, upload limits, permissions, rate limits, and the error statuses each operation can return.yarn contract:statusboots both apps on a throwaway database and checks the real HTTP status of requests that should fail. - Real-time chat. Socket.IO isn't a REST operation, so it has no tag to browse. The event names and connection details are in the spec's top-level description instead.
yarn install- Node.js 18+ and Yarn for building and previewing the docs.
- For
yarn verifyand the contract tests you also need:- Node.js 22.12+, because these commands load the Ecom source and its dependencies (
sanitize-htmlrequires it); - a checkout of Ecom next to this repository, or at the path in
ECOM_DIR, withyarn installrun inWebandFileManager; - Python 3.9+ for the Schemathesis pass.
- Node.js 22.12+, because these commands load the Ecom source and its dependencies (
All commands are defined in package.json.
yarn build # validate, regenerate openapi.json / index.html / vendor/swagger-ui
yarn validate # validation only
yarn start # serve locally on http://localhost:8080
yarn sync-web # build, then copy the site into ../Ecom/Web/public/api-docsUpdate openapi.yaml whenever a route, method or payload changes in Ecom, then check it:
yarn verify # compare the spec against the Ecom source; fails on any difference
yarn sync-statuses # add error statuses the source can return but an operation doesn't list yet
yarn contract:setup # once: install the contract-test dependencies and Schemathesis
yarn contract:status # real HTTP statuses, against a throwaway database
yarn contract # Schemathesis: generated requests for every operation (slow)openapi.yamlis the spec and the only file to edit by hand.openapi.jsonand the copy embedded inindex.htmlare generated.scripts/build.jsvalidates the spec, regeneratesopenapi.jsonandindex.html, and copies Swagger UI intovendor/.audit/implementsyarn verify. Each check is one file underaudit/checks/, andaudit/run.jsruns them.contract/runs the Ecom apps against a throwaway MongoDB and checks them against the spec.status-codes.jsholds requests that must fail with a given status, andrun.jsruns a Schemathesis pass.index.html,css/,js/andvendor/swagger-ui/are the Swagger UI page and its assets. They are served from the same origin, with no third-party CDN.
- Vercel serves the repository root at https://ecom-api-docs.vercel.app/. Push the regenerated
index.html,openapi.yaml,openapi.json,vendor/,css/andjs/together. - Same-origin copy:
yarn sync-webcopies the same files intoWeb/public/api-docsin the Ecom repository, which serves them at/api-docs/. This copy is what lets "Try it out" send the HTTP-only cookies for admin endpoints. Redeploy Ecom after every spec change so the two copies stay identical. - The generated files (
openapi.json, the spec embedded inindex.html, andvendor/swagger-ui/) come fromyarn build. Never edit them by hand. - Swagger UI version: bump it in
package.jsonwithyarn add --dev --exact swagger-ui-dist@<version>, then runyarn build.
Ask questions and report spec mistakes in GitHub issues. If you open a pull request, edit only openapi.yaml by hand and run yarn build and yarn verify before submitting.
MIT © 2026 Ecom Team