Skip to content

feat(api-doc): add user and userRole paths with detailed documentation#896

Closed
nevil-mathew wants to merge 1 commit into
developfrom
api-doc-rewrite
Closed

feat(api-doc): add user and userRole paths with detailed documentation#896
nevil-mathew wants to merge 1 commit into
developfrom
api-doc-rewrite

Conversation

@nevil-mathew

@nevil-mathew nevil-mathew commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator
  • Implemented user-related API paths including read, profileById, setLanguagePreference, update, and share.
  • Added userRole paths for listing, creating, updating, and deleting user roles.
  • Included comprehensive descriptions, parameters, and response schemas for each endpoint.
  • Introduced scripts for route inventory and coverage checks to ensure API documentation accuracy.
  • Added validation for public controller actions.

Summary by CodeRabbit

  • New Features

    • Added automated API documentation generation and validation.
    • Added route coverage checks to identify undocumented live API endpoints.
    • Added username query validation to reject empty values.
    • Updated local development services to use PostgreSQL with improved service health checks.
  • Bug Fixes

    • Improved Docker build exclusions so nested dependency folders are omitted.
    • Added baseline handling for known undocumented routes to reduce false failures.

- Implemented user-related API paths including read, profileById, setLanguagePreference, update, and share.
- Added userRole paths for listing, creating, updating, and deleting user roles.
- Included comprehensive descriptions, parameters, and response schemas for each endpoint.
- Introduced scripts for route inventory and coverage checks to ensure API documentation accuracy.
- Added validation for public controller actions.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Ignoring CodeRabbit configuration file changes. For security, only the configuration from the base branch is applied for open source repositories.

Walkthrough

The PR adds API documentation generation and route coverage checks to CI, introduces route inventory tooling, replaces the local Mongo stack with Postgres Citus, adds a public validator module, and expands CodeRabbit review and merge checks.

Changes

API Documentation Validation

Layer / File(s) Summary
Documentation scripts and validator contract
src/package.json, src/validators/v1/public.js
Adds scripts and development tools for OpenAPI documentation, plus public validator exports including username validation.
Live route inventory
src/scripts/api-doc/route-inventory.js
Boots the Express app without binding a port, traverses mounted routes, and writes route inventory data.
OpenAPI route coverage
src/scripts/api-doc/check-route-coverage.js, src/scripts/api-doc/route-coverage-baseline.json
Matches live route patterns against documented OpenAPI paths, suppresses baseline gaps, and reports new gaps.
CI documentation phase
.circleci/config.yml, .gitignore
Bundles and lints API docs, checks route coverage, stores the OpenAPI artifact, and ignores generated outputs.

Local Development Infrastructure

Layer / File(s) Summary
Healthy service dependencies
docker-compose.yml
Updates Zookeeper, Kafka, and Redis runtime settings, health checks, and dependency ordering.
Postgres Citus persistence
docker-compose.yml
Adds Postgres Citus with readiness checks and persistent storage, replacing Mongo storage.
User service orchestration
docker-compose.yml, .dockerignore
Builds the local user service from source, configures Postgres/Kafka/Redis connectivity, and ignores nested node_modules directories.

Review Governance

Layer / File(s) Summary
Review workflow controls
.coderabbit.yaml
Updates request-changes behavior, review details, path filters, commit statuses, and auto-review targeting.
Labels and path guidance
.coderabbit.yaml
Adds semantic labeling criteria and expanded guidance for API, security, configuration, service, validator, and database changes.
Pre-merge gates
.coderabbit.yaml
Adds Conventional Commit title validation and an API documentation update check.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Poem

A bunny checks each route with care,
While Postgres hops in everywhere.
Kafka waits, and Redis pings,
OpenAPI gains documented wings.
CI bundles docs so bright—
Review gates guard them day and night.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding user and userRole API documentation paths.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch api-doc-rewrite

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/package.json

Parsing error: Unexpected token :


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

💡 Need a hand with PR review? Try Gitar by Sonar!

- id: 22
email: mentee_3t7m88mkgp@tunerlabs.com
email_verified: 'false'
password: $2a$10$dSGsyZDLYnC2UKv3sni.HOp52VCOwWGajXkRSF.C40dJDZy6YL4rK

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (2)
src/scripts/api-doc/route-inventory.js (1)

27-27: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove unused variable.

The METHODS array is defined but never used in the script.

♻️ Proposed fix
-const METHODS = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'all']
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/scripts/api-doc/route-inventory.js` at line 27, Remove the unused METHODS
constant from the route inventory script, leaving the remaining route-inventory
logic unchanged.

Source: Linters/SAST tools

.gitignore (1)

82-85: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Ignore the generated API doc bundle.

The docs:bundle script generates src/api-doc/api-doc.yaml as an output artifact. It should be added to the .gitignore to prevent it from being accidentally committed, similar to the other regenerated tooling outputs.

♻️ Proposed fix
 # Regenerated API doc tooling outputs (not build inputs, no reason to version)
 src/scripts/api-doc/route-inventory.json
 src/redoc-static.html
+src/api-doc/api-doc.yaml
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.gitignore around lines 82 - 85, Add src/api-doc/api-doc.yaml to the
generated API documentation entries in .gitignore, alongside
route-inventory.json and redoc-static.html, so the docs:bundle output is
excluded from version control.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.coderabbit.yaml:
- Around line 47-54: Update the path_filters configuration to stop excluding
Markdown files and the deployment/infrastructure directories, specifically
remove the !**/*.md, !dev-ops/**, and !deployment/** entries so CodeRabbit can
review files covered by the docs and config label instructions.

In `@docker-compose.yml`:
- Around line 67-69: Update the Postgres service environment alongside
POSTGRES_USER and POSTGRES_PASSWORD to configure initialization of the database
targeted by DEV_DATABASE_URL, using the expected elevate-user database name.
Ensure fresh volumes create that database so the user service can connect
without separate setup.
- Line 70: Remove the POSTGRES_HOST_AUTH_METHOD override from the compose
configuration so the published Postgres service does not enable trust
authentication; retain the default password-based authentication, or explicitly
configure scram-sha-256 instead.

In `@src/validators/v1/public.js`:
- Around line 6-12: Implement the required request validation inside the
branding and userInvites validators, matching each endpoint’s expected incoming
fields and applying appropriate checks to all accepted data; if either endpoint
has no input requiring validation, remove that empty validator instead of
retaining a placeholder. Preserve the existing checkUsername behavior.

---

Nitpick comments:
In @.gitignore:
- Around line 82-85: Add src/api-doc/api-doc.yaml to the generated API
documentation entries in .gitignore, alongside route-inventory.json and
redoc-static.html, so the docs:bundle output is excluded from version control.

In `@src/scripts/api-doc/route-inventory.js`:
- Line 27: Remove the unused METHODS constant from the route inventory script,
leaving the remaining route-inventory logic unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 12982fdc-ef67-4304-9d04-85ae0aed930d

📥 Commits

Reviewing files that changed from the base of the PR and between eb1d469 and 78822ce.

⛔ Files ignored due to path filters (36)
  • src/api-doc/api-doc.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/account.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/admin.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/cloudServices.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/entity-type.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/feature.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/form.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/notification.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/org-admin.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/organization-feature.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/organization.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/profile.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/securitySchemes.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/tenant.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/user.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/userRole.yaml is excluded by !src/api-doc/**
  • src/api-doc/components/userentity.yaml is excluded by !src/api-doc/**
  • src/api-doc/openapi.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/account.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/admin.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/cloud-services.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/entity-type.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/entity.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/feature.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/form.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/modules.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/notification.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/org-admin.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/organization-feature.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/organization.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/permissions.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/rolePermissionMapping.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/system.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/tenant.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/user.yaml is excluded by !src/api-doc/**
  • src/api-doc/paths/userRole.yaml is excluded by !src/api-doc/**
📒 Files selected for processing (10)
  • .circleci/config.yml
  • .coderabbit.yaml
  • .dockerignore
  • .gitignore
  • docker-compose.yml
  • src/package.json
  • src/scripts/api-doc/check-route-coverage.js
  • src/scripts/api-doc/route-coverage-baseline.json
  • src/scripts/api-doc/route-inventory.js
  • src/validators/v1/public.js

Comment thread .coderabbit.yaml
Comment on lines 47 to +54
path_filters:
- "!deployment/**"
- "!dev-ops/**"
- "!release-notes/**"
- "!src/api-doc/**"
- "!src/assets/**"
- "!src/configs/**"
- "!src/public/**"
- "!src/temp/**"
- "!**/*.md"
- '!deployment/**'
- '!dev-ops/**'
- '!release-notes/**'
- '!src/assets/**'
- '!src/public/**'
- '!src/temp/**'
- '!**/*.md'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Resolve contradiction between excluded paths and review instructions.

The paths excluded in path_filters contradict the instructions given for applying labels, preventing CodeRabbit from seeing the files you want it to review:

  • !**/*.md excludes all Markdown files. This contradicts the docs label instruction (lines 41-42), which explicitly asks to review changes to "README files, setup notes, operational docs".
  • !dev-ops/** and !deployment/** exclude infrastructure directories. Based on the repository's setup (e.g., docker-compose.yml being run from dev-ops/), this contradicts the config label instruction (lines 39-40), which expects CodeRabbit to review changes affecting "deployment, or Docker files".

If you want CodeRabbit to review these files and apply the corresponding labels, remove them from path_filters.

💡 Proposed fixes
   path_filters:
-    - '!deployment/**'
-    - '!dev-ops/**'
     - '!release-notes/**'
     - '!src/assets/**'
     - '!src/public/**'
     - '!src/temp/**'
-    - '!**/*.md'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
path_filters:
- "!deployment/**"
- "!dev-ops/**"
- "!release-notes/**"
- "!src/api-doc/**"
- "!src/assets/**"
- "!src/configs/**"
- "!src/public/**"
- "!src/temp/**"
- "!**/*.md"
- '!deployment/**'
- '!dev-ops/**'
- '!release-notes/**'
- '!src/assets/**'
- '!src/public/**'
- '!src/temp/**'
- '!**/*.md'
path_filters:
- '!release-notes/**'
- '!src/assets/**'
- '!src/public/**'
- '!src/temp/**'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.coderabbit.yaml around lines 47 - 54, Update the path_filters configuration
to stop excluding Markdown files and the deployment/infrastructure directories,
specifically remove the !**/*.md, !dev-ops/**, and !deployment/** entries so
CodeRabbit can review files covered by the docs and config label instructions.

Comment thread docker-compose.yml
Comment on lines +67 to +69
environment:
POSTGRES_USER: '${POSTGRES_USER:-postgres}'
POSTGRES_PASSWORD: '${POSTGRES_PASSWORD:-postgres}'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n -C3 'POSTGRES_DB|DEV_DATABASE_URL|CREATE DATABASE|elevate-user' \
  docker-compose.yml src Dockerfile

Repository: ELEVATE-Project/user

Length of output: 50378


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the relevant sections of docker-compose.yml with line numbers.
sed -n '55,110p' docker-compose.yml | cat -n

Repository: ELEVATE-Project/user

Length of output: 1991


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== docker-compose postgres-related lines ==\n'
sed -n '1,120p' docker-compose.yml | cat -n

printf '\n== init scripts / postgres setup files ==\n'
git ls-files | rg -n '(^|/)(docker-entrypoint-initdb\.d|init|postgres|postgresql|sql)(/|$)|setup\.sh$|\.sql$' -N

printf '\n== explicit database creation or DB name references ==\n'
rg -n -C2 'CREATE DATABASE|createdb|POSTGRES_DB|elevate-user|docker-entrypoint-initdb\.d|initdb' docker-compose.yml src .github README.md

Repository: ELEVATE-Project/user

Length of output: 46148


Create the database that DEV_DATABASE_URL targets. The Postgres container currently initializes only POSTGRES_USER, so on a fresh volume it will create postgres, not elevate-user. That leaves the user service pointing at a database that doesn’t exist and it will fail to connect until the DB is created separately.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docker-compose.yml` around lines 67 - 69, Update the Postgres service
environment alongside POSTGRES_USER and POSTGRES_PASSWORD to configure
initialization of the database targeted by DEV_DATABASE_URL, using the expected
elevate-user database name. Ensure fresh volumes create that database so the
user service can connect without separate setup.

Comment thread docker-compose.yml
environment:
POSTGRES_USER: '${POSTGRES_USER:-postgres}'
POSTGRES_PASSWORD: '${POSTGRES_PASSWORD:-postgres}'
POSTGRES_HOST_AUTH_METHOD: '${POSTGRES_HOST_AUTH_METHOD:-trust}'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n -C2 'POSTGRES_HOST_AUTH_METHOD|5432:5432|POSTGRES_PASSWORD' docker-compose.yml

Repository: ELEVATE-Project/user

Length of output: 751


🏁 Script executed:

#!/bin/bash
cat -n docker-compose.yml | sed -n '50,85p'

Repository: ELEVATE-Project/user

Length of output: 1284


🏁 Script executed:

#!/bin/bash
cat -n docker-compose.yml | sed -n '1,120p'

Repository: ELEVATE-Project/user

Length of output: 4099


🌐 Web query:

Docker Official Image postgres POSTGRES_HOST_AUTH_METHOD trust password authentication docs

💡 Result:

The POSTGRES_HOST_AUTH_METHOD environment variable in the official PostgreSQL Docker image is used to control the authentication method for host connections in the pg_hba.conf file [1][2]. When a database is uninitialized, the image uses this variable to append an entry to pg_hba.conf, typically following this pattern: echo "host all all all $POSTGRES_HOST_AUTH_METHOD" >> pg_hba.conf Key details regarding this variable include: Default Behavior: If left unspecified, the image defaults to scram-sha-256 password authentication (for versions 14+) or md5 (for older releases) [1][2]. The "trust" Option: Setting POSTGRES_HOST_AUTH_METHOD to trust allows connections without a password [1][2]. Official documentation strongly discourages this usage because it enables anyone to connect without authentication, even if a password is configured via POSTGRES_PASSWORD [1][3]. If you set the variable to trust, a password is not required [1][2]. Security Considerations: - Trust authentication is considered insecure if the PostgreSQL port is exposed to a network, as it allows unauthorized access [3]. - While the default pg_hba.conf generated by the image includes local-only trust entries (e.g., localhost), these are generally restricted to internal container use unless the container is run with host networking mode [4]. - To use more secure authentication methods or to explicitly control initialization parameters, you can use POSTGRES_INITDB_ARGS (e.g., --auth-host=scram-sha-256) alongside the standard variables [1][2][4]. For more information on specific authentication methods, consult the official PostgreSQL documentation on pg_hba.conf [1][2].

Citations:


Remove the trust auth override for Postgres
This compose file publishes 5432 on the host, so POSTGRES_HOST_AUTH_METHOD: 'trust' makes the database reachable without a password for anyone who can connect to that port. Unset it and keep password auth enabled (or set scram-sha-256 explicitly).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docker-compose.yml` at line 70, Remove the POSTGRES_HOST_AUTH_METHOD override
from the compose configuration so the published Postgres service does not enable
trust authentication; retain the default password-based authentication, or
explicitly configure scram-sha-256 instead.

Comment on lines +6 to +12
branding: (req) => {},

checkUsername: (req) => {
req.checkQuery('username').trim().notEmpty().withMessage('username field is empty')
},

userInvites: (req) => {},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Implement missing validation rules.

The branding and userInvites validator functions are currently empty. As per path instructions, all incoming data must be thoroughly validated. Please implement the necessary validation rules for these endpoints, or remove the placeholder functions if no validation is required.

🧰 Tools
🪛 ESLint

[error] 6-6: 'req' is defined but never used.

(no-unused-vars)


[error] 12-12: 'req' is defined but never used.

(no-unused-vars)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/validators/v1/public.js` around lines 6 - 12, Implement the required
request validation inside the branding and userInvites validators, matching each
endpoint’s expected incoming fields and applying appropriate checks to all
accepted data; if either endpoint has no input requiring validation, remove that
empty validator instead of retaining a placeholder. Preserve the existing
checkUsername behavior.

Sources: Path instructions, Linters/SAST tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants