I am trying to set the path parameters when calling the endpoints of the API gateway via the JavaScript SDK and no luck. It seems that I either have something incorrectly configured, or there is an error in generating the SDK.
I can successfully call endpoints that do not accept path parameters, but when I try to pass a parameter that will be used as a path parameter, the SDK just replaces the path parameter with an empty one, and my call fails.
For example, suppose client is a properly initialized API gateway client. I have an endpoint named /measurement with a child of /measurement/{id} . I can call both directly.
client.measurementGet({},{}); - successfully calls my endpoint /measurement client.measurementIdGet({"id": "1234"}, {}); - The browser makes a call /measurement/ instead of /measurement/1234
Looking at the source of my apigClient.js, it looks like the SDK generator does not put the path parameters into the list of parameters it is looking for. For example, the code for my generated measurementIdGet method is as follows:
apigClient.measurementIdGet = function (params, body, additionalParams) { if(additionalParams === undefined) { additionalParams = {}; } apiGateway.core.utils.assertParametersDefined(params, [], ['body']); var measurementIdGetRequest = { verb: 'get'.toUpperCase(), path: pathComponent + uritemplate('/measurement/{id}').expand(apiGateway.core.utils.parseParametersToObject(params, [])), headers: apiGateway.core.utils.parseParametersToObject(params, []), queryParams: apiGateway.core.utils.parseParametersToObject(params, []), body: body }; return apiGatewayClient.makeRequest(measurementIdGetRequest, authType, additionalParams, config.apiKey); };
I dug into assertParametersDefined and parseParametersToObject , and it looks like these methods are expecting a list of parameters to look for. In both cases, the SDK generated empty lists instead of putting its path parameter there.
If I manually updated the generated file to change two lines to
apiGateway.core.utils.assertParametersDefined(params, ['id'], ['body']);
and
apiGateway.core.utils.parseParametersToObject(params, ['id'])
The SDK is making the correct call.
Am I missing something in my configuration or is there an error in the code generator?