feat(playground): add url-encoded body mode#2427
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
|
Preview build of published Zudoku package for commit c65781d. See the deployment at: https://d27d954e.cosmocargo-public-package.pages.dev Note This is a preview of the Cosmo Cargo example using the Zudoku package published to a local registry to ensure it'll be working when published to the public NPM registry. Last updated: 2026-05-11T10:05:09.375Z |
There was a problem hiding this comment.
Pull request overview
Adds first-class support for application/x-www-form-urlencoded request bodies in the OpenAPI Playground to better support OAuth token endpoints, alongside existing Text/File/Multipart modes.
Changes:
- Introduces URL-encoded body mode with a key/value grid UI and example seeding for
application/x-www-form-urlencoded. - Extracts request-body construction into a dedicated
buildRequestBodyhelper with a discriminatedContentTypeActionresult. - Adds URL-encoding helpers (
rowsToUrlEncoded,fromUrlEncoded, etc.) with unit tests, plus a Cosmo Cargo/oauth/tokenendpoint for manual validation.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/zudoku/src/lib/plugins/openapi/util/formatRequestBody.ts | Adds URL-encoding/decoding helpers and example-to-row conversion. |
| packages/zudoku/src/lib/plugins/openapi/util/formatRequestBody.test.ts | Unit tests for URL-encoding helpers. |
| packages/zudoku/src/lib/plugins/openapi/playground/request-panel/UrlEncodedField.tsx | Adds UI row component for URL-encoded key/value fields. |
| packages/zudoku/src/lib/plugins/openapi/playground/Playground.tsx | Integrates buildRequestBody, adds new urlencoded mode, and updates request preview handling. |
| packages/zudoku/src/lib/plugins/openapi/playground/createUrl.test.ts | Updates test fixture to include urlencodedFormFields. |
| packages/zudoku/src/lib/plugins/openapi/playground/buildRequestBody.ts | New helper to build request body and specify Content-Type actions per mode. |
| packages/zudoku/src/lib/plugins/openapi/playground/buildRequestBody.test.ts | Unit tests for buildRequestBody across modes. |
| packages/zudoku/src/lib/plugins/openapi/playground/BodyPanel.tsx | Adds URL-encoded mode selection and “Use Example” seeding for form-urlencoded examples. |
| examples/cosmo-cargo/schema/shipments.json | Adds /oauth/token endpoint using application/x-www-form-urlencoded for manual Playground testing. |
Comments suppressed due to low confidence (1)
packages/zudoku/src/lib/plugins/openapi/playground/BodyPanel.tsx:236
- Example selection replaces/sets a
Content-Typeheader using a case-sensitive filter (h.name !== "Content-Type"). Elsewhere in this component you treat header names case-insensitively (e.g.,h.name.toLowerCase() !== "content-type"), so this can leave duplicate Content-Type entries if the existing header casing differs. Filter case-insensitively here as well.
setValue("headers", [
...headers.filter((h) => h.name !== "Content-Type"),
{
name: "Content-Type",
value: mediaType,
active: true,
},
]);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
31046f9 to
30bc18e
Compare
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: dan-lee <571589+dan-lee@users.noreply.github.com>
Resolved by merging |
Closes #1016.
Adds a
URL-encodedbody mode to the playground, alongside Multipart. Fields are sent asapplication/x-www-form-urlencodedviaURLSearchParams. Mostly for OAuth token endpoints. Picking a urlencoded example pre-fills the rows and flips the dropdown.Cosmo Cargo gets a
POST /oauth/tokenendpoint to try it on.See preview in Playground