File tree Expand file tree Collapse file tree 3 files changed +49
-3
lines changed
src/core/plugins/oas3/components Expand file tree Collapse file tree 3 files changed +49
-3
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import React from "react"
22import PropTypes from "prop-types"
33import ImPropTypes from "react-immutable-proptypes"
44import { Map , OrderedMap , List } from "immutable"
5- import { getCommonExtensions , getSampleSchema } from "core/utils"
5+ import { getCommonExtensions , getSampleSchema , stringify } from "core/utils"
66
77const RequestBody = ( {
88 requestBody,
@@ -83,15 +83,19 @@ const RequestBody = ({
8383
8484 let initialValue = prop . get ( "default" ) || prop . get ( "example" ) || ""
8585
86- if ( initialValue === "" && type === "object" ) {
86+ if ( initialValue === "" && type === "object" ) {
8787 initialValue = getSampleSchema ( prop , false , {
8888 includeWriteOnly : true
8989 } )
9090 }
9191
92+ if ( typeof initialValue !== "string" && type === "object" ) {
93+ initialValue = stringify ( initialValue )
94+ }
95+
9296 const isFile = type === "string" && ( format === "binary" || format === "base64" )
9397
94- return < tr key = { key } className = "parameters" >
98+ return < tr key = { key } className = "parameters" data-property-name = { key } >
9599 < td className = "col parameters-col_name" >
96100 < div className = { required ? "parameter__name required" : "parameter__name" } >
97101 { key }
Original file line number Diff line number Diff line change 1+ openapi : " 3.0.0"
2+
3+ paths :
4+ / :
5+ post :
6+ requestBody :
7+ required : true
8+ content :
9+ multipart/form-data :
10+ schema :
11+ type : object
12+ properties :
13+ first :
14+ type : object
15+ example :
16+ one : abc
17+ two : 123
18+ second :
19+ type : array
20+ items :
21+ type : string
22+ example :
23+ - " hi"
Original file line number Diff line number Diff line change 1+ describe ( "#5164: multipart property initial values" , ( ) => {
2+ it ( "should provide correct initial values for objects and arrays" , ( ) => {
3+ const correctObjectValue = JSON . stringify ( {
4+ "one" : "abc" ,
5+ "two" : 123
6+ } , null , 2 )
7+
8+ cy
9+ . visit ( "?url=/documents/bugs/5164.yaml" )
10+ . get ( "#operations-default-post_" )
11+ . click ( )
12+ . get ( ".try-out__btn" )
13+ . click ( )
14+ . get ( `.parameters[data-property-name="first"] textarea` )
15+ . should ( "have.value" , correctObjectValue )
16+ . get ( `.parameters[data-property-name="second"] input` )
17+ . should ( "have.value" , "hi" )
18+ } )
19+ } )
You can’t perform that action at this time.
0 commit comments