Skip to main content

โšก Quick Reference

Commands Cheat Sheetโ€‹

๐Ÿš€ Main Commandsโ€‹

# Start development server
yarn start

# Update all API documentation
yarn docs:update

# Clean + update + build production
yarn docs:rebuild

# Build production
yarn build

๐Ÿ“ฅ Swagger Managementโ€‹

# Fetch swagger from all services in .env
yarn swagger:fetch

# Enhance swagger files (add host, basePath, security)
yarn swagger:enhance

# Fetch + enhance (all-in-one)
yarn swagger:update

๐Ÿ“š Documentation Generationโ€‹

# Generate docs for all APIs
yarn gen-all-docs

# Generate docs for specific API
yarn gen-api-docs <api-name>

# Example:
yarn gen-api-docs auth
yarn gen-api-docs rewards

๐Ÿงน Cleaningโ€‹

# Clean all API docs
yarn clean-all-docs

# Clean specific API docs
yarn clean-api-docs <api-name>

# Clear Docusaurus cache
yarn clear

# Clear everything (cache + node_modules cache)
rm -rf .docusaurus node_modules/.cache

๐Ÿ”ง Sidebar & Tagsโ€‹

# Fix sidebars + generate tag pages
yarn sidebar:fix

File Structureโ€‹

nomion-docs/
โ”œโ”€โ”€ .env # โš™๏ธ Service configurations (GITIGNORED)
โ”œโ”€โ”€ .env.example # ๐Ÿ“ Template for .env
โ”œโ”€โ”€ examples/ # ๐Ÿ“„ Swagger JSON files
โ”‚ โ”œโ”€โ”€ auth.swagger.json
โ”‚ โ”œโ”€โ”€ rewards.swagger.json
โ”‚ โ””โ”€โ”€ statistic.swagger.json
โ”œโ”€โ”€ docs/
โ”‚ โ”œโ”€โ”€ api/ # ๐Ÿ“š Auto-generated API docs
โ”‚ โ”‚ โ”œโ”€โ”€ auth/
โ”‚ โ”‚ โ”œโ”€โ”€ rewards/
โ”‚ โ”‚ โ””โ”€โ”€ statistic/
โ”‚ โ””โ”€โ”€ guides/ # ๐Ÿ“– Manual documentation
โ”‚ โ”œโ”€โ”€ add-new-service.md
โ”‚ โ””โ”€โ”€ quick-reference.md
โ”œโ”€โ”€ scripts/ # ๐Ÿ› ๏ธ TypeScript utilities
โ”‚ โ”œโ”€โ”€ swagger-manager.ts # Fetch & enhance swagger
โ”‚ โ””โ”€โ”€ sidebar-manager.ts # Fix sidebars & tag pages
โ””โ”€โ”€ api-config.ts # ๐ŸŽฏ Auto-detect APIs from examples/

Environment Variables Formatโ€‹

# Template for each service
{SERVICE_NAME}_SWAGGER_JSON_URL=https://...
USERNAME_{SERVICE_NAME}=admin
PASSWORD_{SERVICE_NAME}=password
{SERVICE_NAME}_BASE_PATH=/path # Optional
{SERVICE_NAME}_LABEL=Display Name # Optional

Example:โ€‹

AUTH_SWAGGER_JSON_URL=https://backend-dev.nomion.io/auth/swagger/json
USERNAME_AUTH=admin
PASSWORD_AUTH=secret123
AUTH_BASE_PATH=/auth
AUTH_LABEL=Authentication API

Common Workflowsโ€‹

๐Ÿ†• Add New Serviceโ€‹

# 1. Add to .env
echo "NEWSERVICE_SWAGGER_JSON_URL=https://..." >> .env
echo "USERNAME_NEWSERVICE=admin" >> .env
echo "PASSWORD_NEWSERVICE=password" >> .env

# 2. Update docs
yarn docs:update

# 3. Start server
yarn start

๐Ÿ”„ Update Existing Serviceโ€‹

# Fetch latest swagger
yarn swagger:fetch

# Regenerate docs
yarn docs:update

๐Ÿงน Full Rebuildโ€‹

# Clean everything and rebuild
yarn docs:rebuild

# Or manual steps:
yarn clean-all-docs
yarn clear
yarn docs:update
yarn build

๐Ÿ› Fix Issuesโ€‹

# Clear cache
yarn clear

# Regenerate specific API
yarn clean-api-docs auth
yarn gen-api-docs auth

# Hard reset
rm -rf .docusaurus node_modules/.cache
yarn start

API Testingโ€‹

๐Ÿ”‘ Bearer Token Formatโ€‹

Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Important: Must include "Bearer " prefix with a space!

๐Ÿ“ API Endpointsโ€‹

Format: https://{host}{basePath}{path}

Example:

  • Host: backend-dev.nomion.io
  • BasePath: /reward
  • Path: /v1/admin/user-rewards
  • Full URL: https://backend-dev.nomion.io/reward/v1/admin/user-rewards

Git Workflowโ€‹

๐Ÿ“ Before Commitโ€‹

# Make sure .env is gitignored
echo ".env" >> .gitignore

# Check what will be committed
git status

# Don't commit:
# - .env file
# - .docusaurus/ folder
# - node_modules/

โœ… Safe to Commitโ€‹

โœ… examples/*.swagger.json
โœ… docs/api/**/*.mdx
โœ… .env.example
โœ… scripts/*.ts
โœ… package.json
โœ… docusaurus.config.ts

Troubleshooting Quick Fixesโ€‹

IssueQuick Fix
API returns 404Check basePath in swagger file
No Authorization buttonRun yarn swagger:enhance
Chunk loading errorRun yarn clear && yarn start
Navbar not showing serviceRestart dev server
Bearer token not workingAdd "Bearer " prefix with space
CORS errorBackend must enable CORS headers

Performance Tipsโ€‹

โšก Faster Developmentโ€‹

# Only regenerate specific API instead of all
yarn gen-api-docs auth

# Skip sidebar fix if not needed
yarn swagger:update && yarn gen-all-docs

# Use --no-minify for faster builds
yarn build --no-minify

๐Ÿ’พ Reduce Build Sizeโ€‹

  • Clean unused API docs
  • Remove old swagger files from examples/
  • Clear .docusaurus/ regularly

Keyboard Shortcuts (in docs)โ€‹

ShortcutAction
/Focus search
sFocus search
Ctrl+KCommand palette (if enabled)

Useful URLsโ€‹

Development:    http://localhost:3000
API Explorer: http://localhost:3000/docs/api/{service}/
Search: http://localhost:3000/search

Supportโ€‹


Last Updated: November 2025

Add New Service (2 Steps)โ€‹

1. Add to .envโ€‹

{SERVICE_NAME}_SWAGGER_JSON_URL=https://your-api.com/swagger.json
USERNAME_{SERVICE_NAME}=admin
PASSWORD_{SERVICE_NAME}=password

2. Run Updateโ€‹

yarn docs:update

Done! โœจ

Common Commandsโ€‹

CommandDescription
yarn docs:updateMain command - Fetch & generate all docs
yarn swagger:fetchFetch Swagger files from URLs in .env
yarn gen-all-docsGenerate docs from existing Swagger files
yarn startStart dev server
yarn buildBuild for production
yarn clearClear cache

Environment Variables Formatโ€‹

# Required
{SERVICE_NAME}_SWAGGER_JSON_URL=https://...

# Optional (if endpoint requires auth)
USERNAME_{SERVICE_NAME}=admin
PASSWORD_{SERVICE_NAME}=secret

Examples:

AUTH_SWAGGER_JSON_URL=https://auth.api.com/swagger.json
PAYMENT_SWAGGER_JSON_URL=https://payment.api.com/swagger.json
NOTIFICATION_SWAGGER_JSON_URL=https://notify.api.com/swagger.json

Auto-Generated Structureโ€‹

{SERVICE_NAME} โ†’ service-name
โ†“
examples/service-name.swagger.json
โ†“
docs/api/service-name/
โ†“
/docs/api/service-name/service-name-api

Custom Service Labelโ€‹

Edit api-config.ts:

const specialCases: Record<string, string> = {
'auth': 'Auth',
'payment': 'Payment', // Add here
};

Troubleshootingโ€‹

Service not showing?โ€‹

yarn clear
yarn docs:update
yarn start

Fetch failed?โ€‹

  • โœ… Check URL is accessible
  • โœ… Verify username/password if required
  • โœ… Check .env file syntax
  • โœ… Ensure HTTPS endpoint allows self-signed certs

Build errors?โ€‹

yarn clean-all-docs
yarn clear
yarn docs:update

Full Update Pipelineโ€‹

yarn docs:update runs:

  1. fetch-swagger - Fetch from URLs
  2. enhance-swagger - Add metadata
  3. fix-swagger - Fix security schemes
  4. fix-swagger-operations - Normalize IDs
  5. gen-api-docs all - Generate docs
  6. generate-tag-pages - Create tag pages
  7. fix-sidebars - Fix navigation

New Feature: Curl Debug Tabโ€‹

After sending any API request, a Curl tab appears showing the exact curl command for debugging! ๐ŸŽ‰

curl --location 'https://api.example.com/v1/users' \
--header 'Authorization: Bearer xxx' \
--header 'Content-Type: application/json' \
--data '{"name":"John"}'

Perfect for:

  • ๐Ÿ“‹ Copy-paste to terminal
  • ๐Ÿ› Debug requests
  • ๐Ÿ“ Share with team
  • ๐Ÿ”ง Test in Postman/Insomnia