From 9a65d754402bba65e864a6bb90ef206538d17d5f Mon Sep 17 00:00:00 2001 From: Juan Hurtado Date: Tue, 7 Apr 2026 12:33:21 -0400 Subject: [PATCH] feat(plugins): Show multipart/form-data example and schema --- .../plugins/oas3/components/request-body.jsx | 24 ++++++++++++++++++- .../oas3-request-body-default-views.cy.js | 24 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/core/plugins/oas3/components/request-body.jsx b/src/core/plugins/oas3/components/request-body.jsx index 388f5cc6662..cfde12c2e3c 100644 --- a/src/core/plugins/oas3/components/request-body.jsx +++ b/src/core/plugins/oas3/components/request-body.jsx @@ -129,11 +129,12 @@ const RequestBody = ({ const isObjectContent = fn.hasSchemaType(mediaTypeValue.get("schema"), "object") + const isContentTypeMultipart = contentType.indexOf("multipart/") === 0 if ( isObjectContent && ( contentType === "application/x-www-form-urlencoded" || - contentType.indexOf("multipart/") === 0 + isContentTypeMultipart ) && schemaForMediaType.get("properties", OrderedMap()).size > 0 ) { @@ -203,6 +204,10 @@ const RequestBody = ({ }} /> + const schemaPartForKey = mediaTypeValue + .get("schema") + .update("properties", (properties) => properties.filter((v, k) => k === key)) + return
@@ -242,6 +247,23 @@ const RequestBody = ({ /> )}
: null } + {!isExecute && isContentTypeMultipart && objectType === "object" ? ( + + {initialValue} + + } + includeWriteOnly={true} + /> + ) : null } }) diff --git a/test/e2e-cypress/e2e/features/oas3-request-body-default-views.cy.js b/test/e2e-cypress/e2e/features/oas3-request-body-default-views.cy.js index d75c86a5e9a..ee9218343d2 100644 --- a/test/e2e-cypress/e2e/features/oas3-request-body-default-views.cy.js +++ b/test/e2e-cypress/e2e/features/oas3-request-body-default-views.cy.js @@ -12,5 +12,29 @@ describe("OAS3 default views", () => { .get(".parameters-col_description textarea") .should("contains.text", "\"stuff\": \"string\"") }) + + it("should display calculated object string as example (#5169)", () => { + cy.visit( + "/?url=/documents/features/request-body/multipart/default-views.yaml", + ) + .get("#operations-default-post_test") + .click() + // Show example + .get(".parameters-col_description code") + .should("contains.text", "\"stuff\": \"string\"") + // Switch to schema + .get(".parameters-col_description") + .contains("Schema") + .click() + .get(".parameters-col_description") + .should("contains.text", "parameters") + .should("not.contain.text", "file") + .should("contains.text", "TestBody") + // Expand Try It Out to hide example + .get(".try-out__btn") + .click() + .get(".parameters-col_description textarea") + .should("contains.text", "\"stuff\": \"string\"") + }) }) })