electrode-native icon indicating copy to clipboard operation
electrode-native copied to clipboard

ern regen-api not respecting optional parameters

Open noormohiuddin opened this issue 5 years ago • 2 comments

In and electrode api schema.json, set a parameter for an electrode bridge request as 'required: falseand then runern 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

noormohiuddin avatar May 16 '19 15:05 noormohiuddin

I'm using ERN 0.30

noormohiuddin avatar May 16 '19 15:05 noormohiuddin

Thanks for reporting this one. Was able to reproduce even with latest Electrode Native version. Will have a look to this today.

belemaire avatar May 16 '19 17:05 belemaire