feat: add toggle to omit optional request body in Try It Out#5765
Open
IsuruDilanga wants to merge 1 commit intoswagger-api:mainfrom
Open
feat: add toggle to omit optional request body in Try It Out#5765IsuruDilanga wants to merge 1 commit intoswagger-api:mainfrom
IsuruDilanga wants to merge 1 commit intoswagger-api:mainfrom
Conversation
Adds a 'Send request body' checkbox that appears in Try It Out mode when requestBody.required is false or not set. When unchecked: - Body textarea is hidden - No body is sent in the actual HTTP request - No Content-Type header is added When checked (default): - Existing behavior is preserved exactly Fixes swagger-api#4807
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
This PR does the following:
RequestBodyWrappercomponent that wraps swagger-ui'sRequestBodycomponent viawrapComponentswhen
requestBody.requiredisfalseor not setContent-Typeheader is sentin the actual HTTP request
Closes #4807
Behavior
required: false+ checkbox checked (default)required: false+ checkbox uncheckedContent-Typeheader sentrequired: trueFiles changed
src/plugins/editor-preview-swagger-ui/components/RequestBodyWrapper.jsx← new filesrc/plugins/editor-preview-swagger-ui/index.js← registersRequestBodywrapComponentHow to test
Setup
Paste the following YAML into the editor:
Test 1 — Optional body, checkbox unchecked (main feature)
POST /v2/authContent-Type: application/json✅Test 2 — Optional body, checkbox checked (default behavior preserved)
POST /v2/authContent-Type: application/jsonheader is present ✅Test 3 — Required body (no regression)
POST /v2/auth/required