Skip to content

fix(api-explorer): restore Base URL editing for single-server API specs#970

Merged
jth-nw merged 1 commit into
devfrom
fix/api-explorer-base-url-edit
May 20, 2026
Merged

fix(api-explorer): restore Base URL editing for single-server API specs#970
jth-nw merged 1 commit into
devfrom
fix/api-explorer-base-url-edit

Conversation

@DanPiazza-Netwrix
Copy link
Copy Markdown
Contributor

Summary

  • The swizzled Server component only rendered the URL field when options.length > 1, leaving the edit panel completely empty for APIs with a single server URL (e.g. Change Tracker). Clicking Edit showed nothing but a Done button.
  • Added a swizzled slice.ts with a new setCustomServerUrl action that sets state.value.url directly without requiring a match in state.options, enabling free-form URL editing.
  • Replaced the conditional options.length > 1 select with a FormTextInput (using local draft state) for single-option APIs; dispatches setCustomServerUrl on Done.
  • Guarded the stale-URL reset so custom URLs aren't overwritten on re-render (reset only runs when options.length > 1).
  • Reset to default is now always visible (was previously only shown when server variables were present).
  • Added type="button" to both Reset and Done buttons — without it, pressing Enter in the URL field triggered Reset to default (browser default-submit behavior).

Test plan

  • Navigate to an API reference page with a single server URL (e.g. /docs/changetracker/8_1/api/reference/acknowledge-events-get)
  • Hover over Base URL — Edit button appears
  • Click Edit — URL text input is shown pre-filled with the current URL
  • Type a new URL — field accepts input without resetting
  • Press Enter — form stays open (does not reset)
  • Click Done — form closes and Base URL display updates to the new value
  • Click Edit again → click Reset to default — URL reverts to the original spec URL
  • Restart dev server and repeat — setCustomServerUrl is fully wired and URL persists to Redux (used in API request calls)

Note: Full Redux persistence of the custom URL requires a dev server restart after this PR is merged, as rspack must re-resolve the @theme/ApiExplorer/Server/slice alias to the new swizzled file.

Generated with AI

Co-Authored-By: Claude Code ai@netwrix.com

The swizzled Server component only showed the URL dropdown when
options.length > 1, leaving the edit form empty for APIs with a single
server URL. Clicking Edit showed nothing but a Done button.

- Add src/theme/ApiExplorer/Server/slice.ts (swizzled) with a new
  setCustomServerUrl action that sets state.value.url directly without
  requiring a match in state.options, enabling free-form URL editing
- Show a FormTextInput (local draft state) when options.length === 1,
  dispatching setCustomServerUrl on Done
- Guard the stale-URL reset so custom URLs aren't immediately
  overwritten (only resets when options.length > 1)
- Always show Reset to default, not just when variables are present
- Add type="button" to Reset and Done buttons so pressing Enter in the
  URL field no longer accidentally triggers Reset to default

Generated with AI

Co-Authored-By: Claude Code <ai@netwrix.com>
@jth-nw jth-nw merged commit 57808aa into dev May 20, 2026
7 checks passed
@jth-nw jth-nw deleted the fix/api-explorer-base-url-edit branch May 20, 2026 17:54
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