feat: add server variable input for API Explorer via custom JS#258
Open
fern-api[bot] wants to merge 10 commits intomainfrom
Open
feat: add server variable input for API Explorer via custom JS#258fern-api[bot] wants to merge 10 commits intomainfrom
fern-api[bot] wants to merge 10 commits intomainfrom
Conversation
Author
|
Requested by: Devon White |
❌ Link Check FailedPreview: https://signalwire-preview-9f858c40-1d53-4e98-b4d3-20d25cbf08ed.docs.buildwithfern.com/docs ❌ 1 Broken Link(s)
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Adds a vanilla JS script that injects a dedicated Space name input field into the API Explorer ("Try It") panel for endpoints that use OpenAPI server variables.
Why
Addresses the server variable discoverability issue described in fern-api/fern#14493. Currently, users must double-click the base URL to edit server variables — this is not discoverable and leads to confusion.
How it works
MutationObserverwatches for.playground-endpoint-baseurlelements in the API Explorer panel.{Your_Space_Name},YOUR_SPACE) is detected, a labeled input field is injected into the explorer form.atomWithStoragelocalStorage keys (selected-environment-urland per-API variants)StorageEvents so React re-renders the URL bar and code sampleslocalStoragehttps://{space_name}.signalwire.com) and Compatibility API (https://{space_name}.signalwire.com/api/laml/2010-04-01) endpoints.Changes
v2 (6c32ca2)
document.getElementById()check instead of data attribute, preventing multiple sections from appearingatomWithStoragekeys + syntheticStorageEventdispatch, which updates both the URL bar and code samplesv1 (74cdc76)
Files changed
fern/server-variable-input.js— Custom JS script (434 lines)fern/docs.yml— Addedjs:section to load the script withafterInteractivestrategyRelated
Requested by: Fern Support