fix(theme): pre-populate parameter defaults in API explorer form#1448
Merged
Conversation
Read `schema.default` when initializing the params slice and sync that value into react-hook-form on mount for text, select, and boolean form items so the right-hand request form renders defaults instead of empty inputs. Affected all parameter locations (header, query, path, cookie); headers were the most visible regression. Also adds an OpenAPI test schema covering each location and schema type used by the demo `tests` plugin instance. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Size Change: +6.29 kB (+0.28%) Total Size: 2.27 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Visit the preview URL for this PR (updated for commit 336f8c2): https://docusaurus-openapi-36b86--pr1448-s4giwsls.web.app (expires Mon, 11 May 2026 19:12:07 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: bf293780ee827f578864d92193b8c2866acd459f |
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.
Summary
schema.defaultwhen initializing the params slice (ApiItem/index.tsx) so each parameter carries its defaultvalueinto redux for code-snippet generation.ParamTextFormItem,ParamSelectFormItem, andParamBooleanFormItemso the right-hand request form renders the default instead of an empty input. Select/boolean items also pass the controller's value through toFormSelectfor the visible selection.demo/examples/tests/paramDefaults.yamlcovering header, query, path, and cookie parameters with string, integer, enum, and boolean defaults. Picked up automatically by the existingtestsplugin instance.Fixes #1226 — the report focused on header parameters but the bug affected all four
inlocations.Test plan
yarn workspace docusaurus-theme-openapi-docs tsc --noEmit(already passing locally)yarn docusaurus gen-api-docs tests && yarn start→ open the newParameter Defaults Demo APIpages and confirm the right-hand form is pre-populated for each parameter location and type.---) still dispatchesundefinedcorrectly so the snippet drops the parameter.Out of scope (good follow-ups)
ParamArrayFormItem— needs auseEffectsimilar to the existingschema.exampleseeding (line 101).ParamMultiSelectFormItem).ParamSelectFormItemandParamBooleanFormItemregister under the static namesparamSelect/paramBoolean, so multiple instances on one page step on each other. Should eventually be keyed byparam.name.🤖 Generated with Claude Code