mean-expert-official / loopback-sdk-builder

Tool for auto-generating Software Development Kits (SDKs) for LoopBack
Other
399 stars 178 forks source link

Wrong api service generation #651

Open RomainSanchez opened 4 years ago

RomainSanchez commented 4 years ago

What type of issue are you creating?

What version of this module are you using?

Hi when generating the service for a model, the typescript function does not post the request data.

here is my model remote method config:

"methods": {
    "upload": {
      "http": [
        {
          "path": "/upload",
          "verb": "post"
        }
      ],
      "accepts": [
        {
          "arg": "req",
          "type": "object",
          "required": true,
          "http": {
            "source": "req"
          },
          "description": "The http request"
        }
      ],
      "returns": [{
        "arg": "response",
        "type": "string",
          "required": true,
        "description": "The http response"
      }],
      "description": "Upload a file"
    }
  }

And here is the generated function :

 public upload(req: any, customHeaders?: Function): Observable<any> {
    let _method: string = "POST";
    let _url: string = LoopBackConfig.getPath() + "/" + LoopBackConfig.getApiVersion() +
    "/Attachments/upload";
    let _routeParams: any = {};
    let _postBody: any = {};
    let _urlParams: any = {};
    let result = this.request(_method, _url, _routeParams, _urlParams, _postBody, null, customHeaders);
    return result;
  }

The _postBody is empty, the req parameter is not used.

In older versions it used to be let _postBody = {data: req}