-
Notifications
You must be signed in to change notification settings - Fork 23
fix(changetracker): improve API auth UX and move API to top-level sidebar #901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jth-nw
merged 17 commits into
dev
from
DanPiazza-Netwrix/fix-changetracker-api-auth-scheme
May 14, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
334a25c
fix(changetracker): improve API auth UX and move API section to top-l…
DanPiazza-Netwrix 7a899e0
fix(changetracker): clarify API explorer auth steps in reference index
DanPiazza-Netwrix f3428d3
fix(vale): auto-fix style issues (Vale + Dale)
github-actions[bot] 001f18b
fix(changetracker): content and style cleanup across API reference se…
DanPiazza-Netwrix 0939f11
fix(vale): auto-fix style issues (Vale + Dale)
github-actions[bot] d2c4d44
fix(changetracker): escape placeholder URL in agents.md to prevent MD…
DanPiazza-Netwrix 085d074
fix(vale): auto-fix style issues (Vale + Dale)
github-actions[bot] a082b8f
fix(changetracker): polish agents and authentication API docs
DanPiazza-Netwrix 809306d
fix(changetracker): remove trailing periods from all API operation su…
DanPiazza-Netwrix 4c8c706
fix(changetracker): remove duplicate HTTP methods from API spec
DanPiazza-Netwrix dce37ff
fix(vale): auto-fix style issues (Vale + Dale)
github-actions[bot] b9c7d4e
feat(changetracker): automate OpenAPI method deduplication
DanPiazza-Netwrix 482fddf
fix(vale): auto-fix style issues (Vale + Dale)
github-actions[bot] fac6f56
ci: add OpenAPI method dedup workflow
DanPiazza-Netwrix 42fc086
docs(changetracker): add CLAUDE.md for API reference directory
DanPiazza-Netwrix fe954a5
fix(changetracker): apply doc review editorial suggestions
DanPiazza-Netwrix c561c88
Merge branch 'dev' into DanPiazza-Netwrix/fix-changetracker-api-auth-…
DanPiazza-Netwrix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| name: OpenAPI Method Dedup | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize] | ||
| branches: | ||
| - dev | ||
| paths: | ||
| - 'static/openapi/**.yaml' | ||
| - 'static/openapi/**.yml' | ||
|
|
||
| concurrency: | ||
| group: openapi-dedup-${{ github.event.pull_request.number }} | ||
|
|
||
| jobs: | ||
| dedup: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| pull-requests: read | ||
| steps: | ||
| - name: Check if triggered by this workflow's own commit | ||
| id: bot-check | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| COMMIT=$(gh api repos/${{ github.repository }}/commits/${{ github.event.pull_request.head.sha }} \ | ||
| --jq '{author: .commit.author.name, message: .commit.message}') | ||
| MESSAGE=$(echo "$COMMIT" | jq -r '.message') | ||
| if echo "$MESSAGE" | grep -qE '^chore\(openapi\): deduplicate'; then | ||
| echo "Skipping: commit is from openapi-dedup workflow" | ||
| echo "skip=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "skip=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Checkout PR branch | ||
| if: steps.bot-check.outputs.skip != 'true' | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.ref }} | ||
| token: ${{ secrets.VALE_TOKEN }} | ||
|
|
||
| - name: Configure git identity | ||
Check warningCode scanning / CodeQL Checkout of untrusted code in trusted context Medium
Potential unsafe checkout of untrusted pull request on privileged workflow.
|
||
| if: steps.bot-check.outputs.skip != 'true' | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| - name: Set up Node.js | ||
| if: steps.bot-check.outputs.skip != 'true' | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| if: steps.bot-check.outputs.skip != 'true' | ||
| run: npm ci --ignore-scripts | ||
|
|
||
| - name: Run deduplication | ||
| id: dedup | ||
| if: steps.bot-check.outputs.skip != 'true' | ||
| run: | | ||
| OUTPUT=$(node scripts/deduplicate-openapi-methods.mjs) | ||
| echo "$OUTPUT" | ||
| if echo "$OUTPUT" | grep -q 'already clean'; then | ||
| echo "changed=false" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
| echo "summary=$OUTPUT" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Commit and push deduplicated spec | ||
| if: steps.bot-check.outputs.skip != 'true' && steps.dedup.outputs.changed == 'true' | ||
| env: | ||
| VALE_TOKEN: ${{ secrets.VALE_TOKEN }} | ||
| run: | | ||
| git add static/openapi/ | ||
| git commit -m "chore(openapi): deduplicate HTTP methods in Change Tracker Hub spec | ||
|
|
||
| ${{ steps.dedup.outputs.summary }} | ||
|
|
||
| Generated with AI | ||
|
|
||
| Co-Authored-By: Claude Code <ai@netwrix.com>" | ||
|
|
||
| git remote set-url origin "https://x-access-token:${VALE_TOKEN}@github.com/${{ github.repository }}.git" | ||
| git push | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # CLAUDE.md — Change Tracker 8.1 API Reference | ||
|
|
||
| This file provides guidance for working in `docs/changetracker/8.1/api/`. | ||
|
|
||
| ## Directory layout | ||
|
|
||
| ``` | ||
| api/ | ||
| ├── CLAUDE.md # This file | ||
| ├── _category_.json # Sidebar label and position for the API section | ||
| ├── overview.md # Hand-authored API overview | ||
| ├── agents.md # Hand-authored: agentsRanked endpoint guide | ||
| ├── authentication.md # Hand-authored: auth flow and PowerShell example | ||
| ├── credentials.md # Hand-authored: credentials CRUD endpoints | ||
| ├── register-agents.md # Hand-authored: agent registration endpoint | ||
| └── reference/ # Generated from OpenAPI spec — see below | ||
| ├── _category_.json # Tracked; triggers structured sidebar injection | ||
| ├── index.md # Tracked; hand-authored intro for the reference | ||
| ├── sidebar.ts # Generated; loaded by products.js | ||
| └── *.mdx / *.json # Generated; gitignored | ||
| ``` | ||
|
|
||
| ## OpenAPI spec | ||
|
|
||
| **Source:** `static/openapi/changetracker-hub-8.1.yaml` | ||
|
|
||
| This spec is auto-generated by ASP.NET Swashbuckle. A key consequence: Swashbuckle exposes both GET and POST on virtually every endpoint (GET takes query-string params, POST takes a form body — same operation, different parameter-passing conventions). The generated reference would otherwise list every endpoint twice. | ||
|
|
||
| ### Deduplication | ||
|
|
||
| `scripts/deduplicate-openapi-methods.mjs` removes the semantically incorrect method from each dual-method endpoint (keeps GET for reads, POST for mutations). It is: | ||
|
|
||
| - **Idempotent** — if the spec is already clean, it exits without touching the file. | ||
| - **Automatic in CI** — the `openapi-dedup` GitHub Actions workflow runs it whenever the YAML changes in a PR and commits the result back to the branch. | ||
| - **Automatic on every build** — wired into `prestart`, `prebuild`, and `preci` in `package.json`, so it always runs before `gen-api-docs`. | ||
|
|
||
| **17 endpoints intentionally keep both GET and POST** (auth flows, downloads, report rendering, and two `commandParser` endpoints where GET and POST do genuinely different things). These are listed in the `KEEP_BOTH` set at the top of the script. | ||
|
|
||
| When the API team ships a new spec, no manual action is needed — push the YAML and the CI workflow handles the rest. For a full local refresh (dedup + clean stale pages + regenerate): | ||
|
|
||
| ```bash | ||
| npm run openapi:sync | ||
| ``` | ||
|
|
||
| ## Regenerating the reference locally | ||
|
|
||
| The MDX files under `reference/` are gitignored (except `_category_.json` and `index.md`) and regenerated at build time. To regenerate manually: | ||
|
|
||
| ```bash | ||
| # Full refresh — use when the OpenAPI spec has changed | ||
| npm run openapi:sync | ||
|
|
||
| # Quick regenerate only (no clean, no dedup — safe for minor changes) | ||
| npx docusaurus gen-api-docs changetracker-hub | ||
| ``` | ||
|
|
||
| **`clean-api-docs` deletes `reference/_category_.json`** — `npm run openapi:sync` restores it automatically via `git checkout`. If you run `clean-api-docs` manually, restore it with: | ||
|
|
||
| ```bash | ||
| git checkout -- docs/changetracker/8.1/api/reference/_category_.json | ||
| ``` | ||
|
|
||
| ## Sidebar integration | ||
|
|
||
| `reference/_category_.json` has `"customProps": { "isGeneratedApiSidebar": true }`. The `sidebarItemsGenerator` in `src/config/products.js` detects this flag and replaces the category's children with the structured sidebar from `reference/sidebar.ts` (loaded via `loadApiSidebarItems`). | ||
|
|
||
| The `transformApiSidebarLabels` function in `products.js`: | ||
| - Converts camelCase category labels to Title Case (e.g. `agentsRanked` → `Agents Ranked`) | ||
| - Strips trailing periods from operation labels | ||
|
|
||
| The `changetracker-hub` info page (an auto-generated landing page with a misaligned URL and label) is filtered out of the sidebar in `products.js`: | ||
|
|
||
| ```js | ||
| .filter(item => !(item.type === 'doc' && item.id?.endsWith('/changetracker-hub'))) | ||
| ``` | ||
|
|
||
| The `parseFrontMatter` hook in `docusaurus.config.js` also strips trailing periods from `title` and `sidebar_label` in generated MDX frontmatter (for the browser tab and breadcrumb). The root cause — trailing periods in OpenAPI `summary` fields — has been fixed directly in the YAML, so these hooks are now a safety net for future spec updates. | ||
|
|
||
| ## Auth scheme | ||
|
|
||
| The security scheme is `type: http` / `scheme: bearer`. This renders the interactive explorer panel as **"AUTHORIZATION: HTTP"** with a **Bearer Token** input field, and auto-prepends `Bearer ` to the value. Do not change it back to `type: apiKey` — that shows a confusingly labeled plain-text input. | ||
|
|
||
| ## MDX gotchas | ||
|
|
||
| - **Angle-bracket placeholders** like `<hub-url>` are parsed as JSX tags in MDX and cause build errors. Always wrap them in backticks: `` `https://<hub-url>/api` ``. | ||
| - **Code fences** in hand-authored files must have a language specifier (`json`, `powershell`, `bash`, etc.) — bare ` ``` ` fences are flagged by linting. | ||
|
|
||
| ## Product name | ||
|
|
||
| Always **Change Tracker** (two words). Never `ChangeTracker`. |
2 changes: 1 addition & 1 deletion
2
...acker/8.1/integration/api/_category_.json → docs/changetracker/8.1/api/_category_.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "label": "API", | ||
| "position": 20, | ||
| "position": 115, | ||
| "collapsed": true, | ||
| "collapsible": true, | ||
| "link": { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...ker/8.1/integration/api/authentication.md → docs/changetracker/8.1/api/authentication.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.