@@ -743,7 +743,7 @@ let QUERYPARAM = 'query',
743
743
* @param {Set<string> } [parentRequired=new Set()] - A set of parent-required property keys to inherit.
744
744
* @returns {Object } The processed schema details.
745
745
*/
746
- processSchema = ( resolvedSchema , parentRequired = new Set ( ) ) => {
746
+ processSchema = ( resolvedSchema ) => {
747
747
if ( resolvedSchema . type === 'object' && resolvedSchema . properties ) {
748
748
const schemaDetails = {
749
749
type : resolvedSchema . type || 'unknown' ,
@@ -767,7 +767,7 @@ let QUERYPARAM = 'query',
767
767
format : prop . format || undefined
768
768
} ;
769
769
770
- if ( requiredProperties . has ( key ) || parentRequired . has ( key ) ) {
770
+ if ( requiredProperties . has ( key ) ) {
771
771
schemaDetails . required . push ( key ) ;
772
772
}
773
773
if ( prop . properties ) {
@@ -778,7 +778,7 @@ let QUERYPARAM = 'query',
778
778
}
779
779
}
780
780
else if ( prop . type === 'array' && prop . items ) {
781
- propertyDetails . items = processSchema ( prop . items , parentRequired = requiredProperties ) ;
781
+ propertyDetails . items = processSchema ( prop . items ) ;
782
782
}
783
783
784
784
schemaDetails . properties [ key ] = propertyDetails ;
@@ -2119,6 +2119,7 @@ let QUERYPARAM = 'query',
2119
2119
keyName = name ;
2120
2120
properties = createProperties ( schema , param ) ;
2121
2121
}
2122
+
2122
2123
pathParamTypeInfo = { keyName, properties } ;
2123
2124
if ( keyName && param . schema && param . schema . type ) {
2124
2125
pathParamTypes . push ( pathParamTypeInfo ) ;
@@ -2136,6 +2137,7 @@ let QUERYPARAM = 'query',
2136
2137
2137
2138
pmParams . push ( ...deserialisedParams ) ;
2138
2139
} ) ;
2140
+
2139
2141
return { pathParamTypes, pathParams : pmParams } ;
2140
2142
} ,
2141
2143
@@ -2199,16 +2201,14 @@ let QUERYPARAM = 'query',
2199
2201
keyName ,
2200
2202
paramValue = resolveValueOfParameter ( context , param ) ;
2201
2203
2202
- if ( param && param . schema ) {
2204
+ if ( param && param . name && param . schema && param . schema . type ) {
2203
2205
const { name, schema } = param ;
2204
2206
keyName = name ;
2205
2207
properties = createProperties ( schema , param ) ;
2206
2208
}
2207
2209
headerTypeInfo = { keyName, properties } ;
2208
2210
2209
- if ( keyName && param . schema && param . schema . type ) {
2210
- headerTypes . push ( headerTypeInfo ) ;
2211
- }
2211
+ headerTypes . push ( headerTypeInfo ) ;
2212
2212
2213
2213
if ( typeof paramValue === 'number' || typeof paramValue === 'boolean' ) {
2214
2214
// the SDK will keep the number-ness,
@@ -2222,6 +2222,7 @@ let QUERYPARAM = 'query',
2222
2222
2223
2223
pmParams . push ( ...deserialisedParams ) ;
2224
2224
} ) ;
2225
+
2225
2226
return { headerTypes, headers : pmParams } ;
2226
2227
} ,
2227
2228
@@ -2267,9 +2268,7 @@ let QUERYPARAM = 'query',
2267
2268
resolvedResponseBodyResult = resolveBodyData (
2268
2269
context , responseContent [ bodyType ] , bodyType , true , code , requestBodyExamples ) ;
2269
2270
allBodyData = resolvedResponseBodyResult . generatedBody ;
2270
- resolvedResponseBodyTypes = resolvedResponseBodyResult ?
2271
- resolvedResponseBodyResult . resolvedSchemaType :
2272
- undefined ;
2271
+ resolvedResponseBodyTypes = resolvedResponseBodyResult . resolvedSchemaType ;
2273
2272
2274
2273
return _ . map ( allBodyData , ( bodyData ) => {
2275
2274
let requestBodyData = bodyData . request ,
@@ -2350,11 +2349,11 @@ let QUERYPARAM = 'query',
2350
2349
2351
2350
headers . push ( ...serialisedHeader ) ;
2352
2351
2353
- if ( headerData && headerData . schema ) {
2352
+ if ( headerData && headerData . name && headerData . schema && headerData . schema . type ) {
2354
2353
const { name, schema } = headerData ;
2355
2354
keyName = name ;
2356
2355
properties = {
2357
- type : schema . type || 'unknown' ,
2356
+ type : schema . type ,
2358
2357
format : schema . format || undefined ,
2359
2358
default : schema . default !== undefined ? schema . default : undefined ,
2360
2359
required : schema . required || false ,
@@ -2370,9 +2369,7 @@ let QUERYPARAM = 'query',
2370
2369
2371
2370
}
2372
2371
headerTypeInfo = { keyName, properties } ;
2373
- if ( keyName && headerData . schema && headerData . schema . type ) {
2374
- headerTypes . push ( headerTypeInfo ) ;
2375
- }
2372
+ headerTypes . push ( headerTypeInfo ) ;
2376
2373
} ) ;
2377
2374
2378
2375
return { resolvedHeaderTypes : headerTypes , headers } ;
@@ -2468,7 +2465,7 @@ let QUERYPARAM = 'query',
2468
2465
headerFamily ,
2469
2466
isBodyTypeXML ,
2470
2467
resolvedExamplesObject = { } ,
2471
- responseBlock = { } ;
2468
+ responseTypes = { } ;
2472
2469
2473
2470
// store all request examples which will be used for creation of examples with correct request and response matching
2474
2471
if ( typeof requestBody === 'object' ) {
@@ -2515,20 +2512,18 @@ let QUERYPARAM = 'query',
2515
2512
resolveSchema ( context , responseObj , { isResponseSchema : true } ) ) : responseObj ,
2516
2513
{ includeAuthInfoInExample } = context . computedOptions ,
2517
2514
auth = request . auth ,
2518
- resolvedExamples = resolveResponseBody ( context , responseSchema , requestBodyExamples , code ) || { } ;
2515
+ resolvedExamples = resolveResponseBody ( context , responseSchema , requestBodyExamples , code ) || { } ,
2516
+ { resolvedHeaderTypes, headers } = resolveResponseHeaders ( context , responseSchema . headers ) ,
2517
+ responseBodyHeaderObj ;
2519
2518
resolvedExamplesObject = resolvedExamples [ 0 ] && resolvedExamples [ 0 ] . resolvedResponseBodyTypes ;
2520
2519
// eslint-disable-next-line one-var
2521
- let { resolvedHeaderTypes, headers } = resolveResponseHeaders ( context , responseSchema . headers ) ,
2522
- responseBodyHeaderObj ,
2523
- responseTypes ;
2524
- responseBodyHeaderObj = resolvedExamplesObject ?
2520
+ responseBodyHeaderObj =
2525
2521
{
2526
2522
body : JSON . stringify ( resolvedExamplesObject , null , 2 ) ,
2527
2523
headers : JSON . stringify ( resolvedHeaderTypes , null , 2 )
2528
- } : { } ;
2524
+ } ;
2529
2525
2530
- responseTypes = { [ code ] : responseBodyHeaderObj } ;
2531
- Object . assign ( responseBlock , responseTypes ) ;
2526
+ Object . assign ( responseTypes , { [ code ] : responseBodyHeaderObj } ) ;
2532
2527
2533
2528
_ . forOwn ( resolvedExamples , ( resolvedExample = { } ) => {
2534
2529
let { body, contentHeader = [ ] , bodyType, acceptHeader, name } = resolvedExample ,
@@ -2593,7 +2588,7 @@ let QUERYPARAM = 'query',
2593
2588
return {
2594
2589
responses,
2595
2590
acceptHeader : requestAcceptHeader ,
2596
- unifiedResponseTypes : responseBlock
2591
+ responseTypes : responseTypes
2597
2592
} ;
2598
2593
} ;
2599
2594
@@ -2614,17 +2609,13 @@ module.exports = {
2614
2609
{ pathParamTypes, pathParams } = resolvePathParamsForPostmanRequest ( context , operationItem , method ) ,
2615
2610
{ pathVariables, collectionVariables } = filterCollectionAndPathVariables ( url , pathParams ) ,
2616
2611
requestBody = resolveRequestBodyForPostmanRequest ( context , operationItem [ method ] ) ,
2617
- bodyTypes = requestBody && requestBody . resolvedSchemaTypeObject ,
2612
+ requestBodyTypes = requestBody && requestBody . resolvedSchemaTypeObject ,
2618
2613
request ,
2619
2614
securitySchema = _ . get ( operationItem , [ method , 'security' ] ) ,
2620
2615
authHelper = generateAuthForCollectionFromOpenAPI ( context . openapi , securitySchema ) ,
2621
2616
{ alwaysInheritAuthentication } = context . computedOptions ,
2622
2617
requestIdentifier ,
2623
- requestBlock ,
2624
- typesObject = { } ;
2625
- if ( requestBody && requestBody . resolvedSchemaTypeObject ) {
2626
- delete requestBody . resolvedSchemaTypeObject ;
2627
- }
2618
+ requestTypesObject = { } ;
2628
2619
headers . push ( ..._ . get ( requestBody , 'headers' , [ ] ) ) ;
2629
2620
pathVariables . push ( ...baseUrlData . pathVariables ) ;
2630
2621
collectionVariables . push ( ...baseUrlData . collectionVariables ) ;
@@ -2645,8 +2636,8 @@ module.exports = {
2645
2636
auth : alwaysInheritAuthentication ? undefined : authHelper
2646
2637
} ;
2647
2638
2648
- const unifiedRequestTypes = {
2649
- body : JSON . stringify ( bodyTypes , null , 2 ) ,
2639
+ const requestTypes = {
2640
+ body : JSON . stringify ( requestBodyTypes , null , 2 ) ,
2650
2641
headers : JSON . stringify ( headerTypes , null , 2 ) ,
2651
2642
pathParam : JSON . stringify ( pathParamTypes , null , 2 ) ,
2652
2643
queryParam : JSON . stringify ( queryParamTypes , null , 2 )
@@ -2655,12 +2646,12 @@ module.exports = {
2655
2646
{
2656
2647
responses,
2657
2648
acceptHeader,
2658
- unifiedResponseTypes
2649
+ responseTypes
2659
2650
} = resolveResponseForPostmanRequest ( context , operationItem [ method ] , request ) ;
2660
2651
2661
2652
requestIdentifier = method + path ;
2662
- requestBlock = { request : unifiedRequestTypes , response : unifiedResponseTypes } ;
2663
- Object . assign ( typesObject , { [ requestIdentifier ] : requestBlock } ) ;
2653
+ Object . assign ( requestTypesObject ,
2654
+ { [ requestIdentifier ] : { request : requestTypes , response : responseTypes } } ) ;
2664
2655
2665
2656
// add accept header if found and not present already
2666
2657
if ( ! _ . isEmpty ( acceptHeader ) ) {
@@ -2675,7 +2666,7 @@ module.exports = {
2675
2666
} )
2676
2667
} ,
2677
2668
collectionVariables,
2678
- typesObject
2669
+ requestTypesObject
2679
2670
} ;
2680
2671
} ,
2681
2672
0 commit comments