electrode-native
electrode-native copied to clipboard
ern regen-api not respecting optional parameters
In and electrode api schema.json, set a parameter for an electrode bridge request as 'required: falseand then run
ern regen-api`.
e.g.
{
"setCurrentScreen": {
"post": {
"tags": [
"MyPortalAnalytics"
],
"operationId": "setCurrentScreen",
"parameters": [
{
"name": "screenName",
"in": "path",
"description": "The name of the current screen",
"required": true,
"type": "string"
},
{
"name": "screenClassOverride",
"in": "path",
"description": "The name of the screen class",
"required": false,
"type": "string"
}
]
}
}
}
The corresponding JS request function that is generated will require that the optional parameter is passed in args.
For the swagger example above, the following function is generated:
setCurrentScreen(screenName: string, screenClassOverride: string,timeout: number): Promise<any> {
const data = {}
// verify the required parameter 'screenName' is set
if (screenName == null) {
throw "Missing the required parameter 'screenName' when calling 'MyPortalAnalyticsApi#setCurrentScreen'";
}
// verify the required parameter 'screenClassOverride' is set
if (screenClassOverride == null) {
throw "Missing the required parameter 'screenClassOverride' when calling 'MyPortalAnalyticsApi#setCurrentScreen'";
}
data['screenName'] = screenName;
data['screenClassOverride'] = screenClassOverride;
return this._bridge.sendRequest("com.MyPortalAnalyticsApi.ern.api.request.setCurrentScreen", { data, timeout })
}
screenClassOverride should be an optional argument to the JS function
I'm using ERN 0.30
Thanks for reporting this one. Was able to reproduce even with latest Electrode Native version. Will have a look to this today.