Skip to content

Commit ac106cd

Browse files
ft(oas3): show the schema tab in the Try it Out mode (#10488)
* ft: show the schema tab in the Try it Out mode
1 parent 4680916 commit ac106cd

File tree

2 files changed

+45
-29
lines changed

2 files changed

+45
-29
lines changed

src/core/plugins/oas3/components/request-body.jsx

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,15 @@ const RequestBody = ({
262262
if (testValueForJson) {
263263
language = "json"
264264
}
265+
const example = isExecute ? <RequestBodyEditor
266+
value={requestBodyValue}
267+
errors={requestBodyErrors}
268+
defaultValue={sampleRequestBody}
269+
onChange={onChange}
270+
getComponent={getComponent}
271+
/> : <HighlightCode className="body-param__example" language={language}>
272+
{stringify(requestBodyValue) || sampleRequestBody}
273+
</HighlightCode>
265274

266275
return <div>
267276
{ requestBodyDescription &&
@@ -282,35 +291,17 @@ const RequestBody = ({
282291
/>
283292
) : null
284293
}
285-
{
286-
isExecute ? (
287-
<div>
288-
<RequestBodyEditor
289-
value={requestBodyValue}
290-
errors={requestBodyErrors}
291-
defaultValue={sampleRequestBody}
292-
onChange={onChange}
293-
getComponent={getComponent}
294-
/>
295-
</div>
296-
) : (
297-
<ModelExample
298-
getComponent={ getComponent }
299-
getConfigs={ getConfigs }
300-
specSelectors={ specSelectors }
301-
expandDepth={1}
302-
isExecute={isExecute}
303-
schema={mediaTypeValue.get("schema")}
304-
specPath={specPath.push("content", contentType)}
305-
example={
306-
<HighlightCode className="body-param__example" language={language}>
307-
{stringify(requestBodyValue) || sampleRequestBody}
308-
</HighlightCode>
309-
}
310-
includeWriteOnly={true}
311-
/>
312-
)
313-
}
294+
<ModelExample
295+
getComponent={ getComponent }
296+
getConfigs={ getConfigs }
297+
specSelectors={ specSelectors }
298+
expandDepth={1}
299+
isExecute={isExecute}
300+
schema={mediaTypeValue.get("schema")}
301+
specPath={specPath.push("content", contentType)}
302+
example={example}
303+
includeWriteOnly={true}
304+
/>
314305
{
315306
sampleForMediaType ? (
316307
<Example
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
describe("OpenAPI 3.0 Schema rendering", () => {
2+
it("should render the Schema tab in Try it out mode for request body", () => {
3+
cy
4+
.visit("?url=/documents/features/oas3-xml.json")
5+
.get("#operations-default-post_foo")
6+
.click()
7+
.get(".btn.try-out__btn")
8+
.click()
9+
.get(".opblock-section-request-body")
10+
.within(() => {
11+
cy.contains("button", "Schema")
12+
.should("exist")
13+
.and("be.visible")
14+
.click()
15+
16+
cy
17+
.get('[data-name="modelPanel"]')
18+
.should("be.visible")
19+
20+
cy
21+
.get('[data-name="examplePanel"]')
22+
.should("not.exist")
23+
})
24+
})
25+
})

0 commit comments

Comments
 (0)