File tree 3 files changed +43
-2
lines changed
static/documents/features
3 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ export default class Response extends React.Component {
134
134
// Goal: find an example value for `sampleResponse`
135
135
if ( isOAS3 ) {
136
136
sampleSchema = activeMediaType . get ( "schema" ) ?. toJS ( )
137
- if ( examplesForMediaType ) {
137
+ if ( Map . isMap ( examplesForMediaType ) && ! examplesForMediaType . isEmpty ( ) ) {
138
138
const targetExamplesKey = this . getTargetExamplesKey ( )
139
139
const targetExample = examplesForMediaType
140
140
. get ( targetExamplesKey , Map ( { } ) )
@@ -208,7 +208,7 @@ export default class Response extends React.Component {
208
208
</ small >
209
209
) : null }
210
210
</ div >
211
- { examplesForMediaType ? (
211
+ { Map . isMap ( examplesForMediaType ) && ! examplesForMediaType . isEmpty ( ) ? (
212
212
< div className = "response-control-examples" >
213
213
< small className = "response-control-examples__title" >
214
214
Examples
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @prettier
3
+ */
4
+
5
+ describe ( "Response examples" , ( ) => {
6
+ it ( "should render a generated example when an empty examples object is provided" , ( ) => {
7
+ cy . visit ( "/?url=/documents/features/response-empty-examples-object.yaml" )
8
+ . get ( "#operations-TEST-test" )
9
+ . click ( )
10
+ . get ( ".example.microlight" )
11
+ . should ( "exist" )
12
+ . contains ( "{}" )
13
+ . get ( ".examples-select-element" )
14
+ . should ( "not.exist" )
15
+ } )
16
+ } )
Original file line number Diff line number Diff line change
1
+ openapi : 3.1.0
2
+ info :
3
+ title : TEST
4
+ description : TEST
5
+ version : ' 1.0'
6
+ servers :
7
+ - url : localhost:8080
8
+ tags :
9
+ - name : TEST
10
+ paths :
11
+ /test-endpoint :
12
+ get :
13
+ summary : Test
14
+ operationId : test
15
+ responses :
16
+ ' 200 ' :
17
+ description : OK
18
+ content :
19
+ application/json :
20
+ schema :
21
+ type : object
22
+ examples : {}
23
+ description : Test
24
+ tags :
25
+ - TEST
You can’t perform that action at this time.
0 commit comments