@@ -36,11 +36,11 @@ import { snakizeKeys, pascalizeKeys, mapObject, filterObject } from './other'
36
36
* @param {String } [options.spec] - Override OpenAPI definition
37
37
* @param {String } [options.internalUrl] - Node internal URL
38
38
* @param {Boolean } [options.disableBigNumbers]
39
- * @param {Boolean } [options.keysOfValuesToIgnore] TODO: Convert keys according to Swagger definitions instead
39
+ * @param {Boolean } [options.disableCaseConversion]
40
40
* @return {Object } Swagger client
41
41
* @example (await genSwaggerClient('https://mainnet.aeternity.io/api')).getAccountByPubkey('ak_jupBUgZNbcC4krDLR3tAkw1iBZoBbkNeShAq4atBtpFWmz36r')
42
42
*/
43
- export default async ( specUrl , { spec, internalUrl, disableBigNumbers, keysOfValuesToIgnore } = { } ) => {
43
+ export default async ( specUrl , { spec, internalUrl, disableBigNumbers, disableCaseConversion } = { } ) => {
44
44
spec = spec || await ( await fetch ( specUrl ) ) . json ( )
45
45
const jsonImp = disableBigNumbers ? JSON : JsonBig
46
46
@@ -69,8 +69,10 @@ export default async (specUrl, { spec, internalUrl, disableBigNumbers, keysOfVal
69
69
} ,
70
70
responseInterceptor : response => {
71
71
if ( ! response . text ) return response
72
- const body = pascalizeKeys ( jsonImp . parse ( response . text ) , keysOfValuesToIgnore )
73
- return Object . assign ( response , { body } )
72
+ const body = jsonImp . parse ( response . text )
73
+ return Object . assign ( response , {
74
+ body : disableCaseConversion ? body : pascalizeKeys ( body )
75
+ } )
74
76
}
75
77
} )
76
78
} ) )
@@ -107,7 +109,7 @@ export default async (specUrl, { spec, internalUrl, disableBigNumbers, keysOfVal
107
109
if ( typeof value !== 'object' ) return [ param , value ]
108
110
const rootKeys = Object . keys ( parameters . find ( p => p . name === param ) . schema . properties )
109
111
const filteredValue = filterObject (
110
- snakizeKeys ( value , keysOfValuesToIgnore ) ,
112
+ disableCaseConversion ? value : snakizeKeys ( value ) ,
111
113
( [ key ] ) => rootKeys . includes ( key )
112
114
)
113
115
return [ param , jsonImp . stringify ( filteredValue ) ]
0 commit comments