fix(oas3): show request body description for file upload content types#10836
fix(oas3): show request body description for file upload content types#10836yogeshwaran-c wants to merge 4 commits intoswagger-api:masterfrom
Conversation
When a request body uses a content type like application/octet-stream that triggers file upload mode, the description from the requestBody object was not being displayed. Instead, only the "Example values are not available" message was shown (in non-execute mode) or just the file input (in execute mode). This renders the requestBody description above the file input or the example-not-available message, consistent with how descriptions are shown for other content types. Fixes swagger-api#5637
9c819d3 to
8d1d1ed
Compare
|
@yogeshwaran-c please add tests for you changes |
|
@lukaszzazulak Added unit tests in 527322c (see The suite covers the fix end-to-end:
Run: 4/4 passing locally. Lint is clean ( |
|
@yogeshwaran-c please add e2e test in Cypress, there are already existing similar tests, have a look and add similar tests to cover new cases added here |
…oad content types
|
@lukaszzazulak thanks for the review -- added Cypress e2e coverage in f0ad27c. New files:
Covered content types:
Each suite asserts:
Let me know if you'd like additional variants or different selectors. |
|
@yogeshwaran-c tests are failing; please make sure tests pass locally (for all of your PRs) |
OAS3 wrap-components/markdown.jsx renders with class renderedMarkdown, not the core markdown class; the prior selectors never matched and all eight new e2e cases timed out in CI.
|
@lukaszzazulak you were right — the new e2e spec was using the core Markdown class ( Fixed in 247ea14 by switching the selector to Verified locally: |
Description
When a request body uses a content type like
application/octet-streamthat triggers file upload mode, thedescriptionfrom therequestBodyobject was not displayed. The early return in the file upload branch skipped the description rendering that exists for other content types.This change renders the
requestBody.description(via Markdown component) above the file input or the "Example values are not available" message, consistent with how descriptions are shown forapplication/json,multipart/form-data, and other content types.Motivation and Context
Fixes #5637
Users who document their file upload endpoints with descriptions (e.g., "A zip file containing files that will be unzipped") expect those descriptions to be visible in Swagger UI, regardless of the content type.
How Has This Been Tested?
Markdowncomponent andrequestBodyDescriptionvariable are already available in scope at the point of the change{ requestBodyDescription && <Markdown source={requestBodyDescription} /> }is reused from lines 146-148 and 276-278 in the same fileScreenshots (if appropriate):
N/A - description text is now visible above file upload inputs
Checklist
My PR contains...
src/is unmodified: changes to documentation, CI, metadata, etc.)package.json)My changes...
Documentation
Automated tests