@@ -42,7 +42,7 @@ export default class ParameterRow extends Component {
4242
4343 if ( isOAS3 ) {
4444 let { schema } = getParameterSchema ( parameterWithMeta , { isOAS3 } )
45- enumValue = schema . get ( "enum" )
45+ enumValue = schema ? schema . get ( "enum" ) : undefined
4646 } else {
4747 enumValue = parameterWithMeta ? parameterWithMeta . get ( "enum" ) : undefined
4848 }
@@ -59,7 +59,7 @@ export default class ParameterRow extends Component {
5959 if ( value !== undefined && value !== paramValue ) {
6060 this . onChangeWrapper ( numberToString ( value ) )
6161 }
62-
62+ // todo: could check if schema here; if not, do not call. impact?
6363 this . setDefaultValue ( )
6464 }
6565
@@ -97,17 +97,16 @@ export default class ParameterRow extends Component {
9797 let { specSelectors, pathMethod, rawParam, oas3Selectors } = this . props
9898
9999 const paramWithMeta = specSelectors . parameterWithMetaByIdentity ( pathMethod , rawParam ) || Map ( )
100-
101100 const { schema } = getParameterSchema ( paramWithMeta , { isOAS3 : specSelectors . isOAS3 ( ) } )
102-
103101 const parameterMediaType = paramWithMeta
104102 . get ( "content" , Map ( ) )
105103 . keySeq ( )
106104 . first ( )
107105
108- const generatedSampleValue = getSampleSchema ( schema . toJS ( ) , parameterMediaType , {
106+ // getSampleSchema could return null
107+ const generatedSampleValue = schema ? getSampleSchema ( schema . toJS ( ) , parameterMediaType , {
109108 includeWriteOnly : true
110- } )
109+ } ) : null
111110
112111 if ( ! paramWithMeta || paramWithMeta . get ( "value" ) !== undefined ) {
113112 return
@@ -121,14 +120,14 @@ export default class ParameterRow extends Component {
121120 if ( specSelectors . isSwagger2 ( ) ) {
122121 initialValue = paramWithMeta . get ( "x-example" )
123122 || paramWithMeta . getIn ( [ "schema" , "example" ] )
124- || schema . getIn ( [ "default" ] )
123+ || ( schema && schema . getIn ( [ "default" ] ) )
125124 } else if ( specSelectors . isOAS3 ( ) ) {
126125 const currentExampleKey = oas3Selectors . activeExamplesMember ( ...pathMethod , "parameters" , this . getParamKey ( ) )
127126 initialValue = paramWithMeta . getIn ( [ "examples" , currentExampleKey , "value" ] )
128127 || paramWithMeta . getIn ( [ "content" , parameterMediaType , "example" ] )
129128 || paramWithMeta . get ( "example" )
130- || schema . get ( "example" )
131- || schema . get ( "default" )
129+ || ( schema && schema . get ( "example" ) )
130+ || ( schema && schema . get ( "default" ) )
132131 || paramWithMeta . get ( "default" ) // ensures support for `parameterMacro`
133132 }
134133
@@ -144,7 +143,7 @@ export default class ParameterRow extends Component {
144143 if ( initialValue !== undefined ) {
145144 this . onChangeWrapper ( initialValue )
146145 } else if (
147- schema . get ( "type" ) === "object"
146+ schema && schema . get ( "type" ) === "object"
148147 && generatedSampleValue
149148 && ! paramWithMeta . get ( "examples" )
150149 ) {
@@ -212,12 +211,12 @@ export default class ParameterRow extends Component {
212211 let { schema } = getParameterSchema ( param , { isOAS3 } )
213212 let paramWithMeta = specSelectors . parameterWithMetaByIdentity ( pathMethod , rawParam ) || Map ( )
214213
215- let format = schema . get ( "format" )
216- let type = schema . get ( "type" )
214+ let format = schema ? schema . get ( "format" ) : null
215+ let type = schema ? schema . get ( "type" ) : null
216+ let itemType = schema ? schema . getIn ( [ "items" , "type" ] ) : null
217217 let isFormData = inType === "formData"
218218 let isFormDataSupported = "FormData" in win
219219 let required = param . get ( "required" )
220- let itemType = schema . getIn ( [ "items" , "type" ] )
221220
222221 let value = paramWithMeta ? paramWithMeta . get ( "value" ) : ""
223222 let commonExt = showCommonExtensions ? getCommonExtensions ( schema ) : null
@@ -229,24 +228,26 @@ export default class ParameterRow extends Component {
229228 let paramExample // undefined
230229 let isDisplayParamEnum = false
231230
232- if ( param !== undefined ) {
231+ if ( param !== undefined && schema ) {
233232 paramItems = schema . get ( "items" )
234233 }
235234
236235 if ( paramItems !== undefined ) {
237236 paramEnum = paramItems . get ( "enum" )
238237 paramDefaultValue = paramItems . get ( "default" )
239- } else {
238+ } else if ( schema ) {
240239 paramEnum = schema . get ( "enum" )
241240 }
242241
243- if ( paramEnum !== undefined && paramEnum . size > 0 ) {
242+ if ( paramEnum && paramEnum . size && paramEnum . size > 0 ) {
244243 isDisplayParamEnum = true
245244 }
246245
247246 // Default and Example Value for readonly doc
248247 if ( param !== undefined ) {
249- paramDefaultValue = schema . get ( "default" )
248+ if ( schema ) {
249+ paramDefaultValue = schema . get ( "default" )
250+ }
250251 if ( paramDefaultValue === undefined ) {
251252 paramDefaultValue = param . get ( "default" )
252253 }
0 commit comments