2

I trying to send post with some object using vibe.d rest client generator with such code:

class App
{
    string id;
    string cmd;
}

interface IntREST
{
    @path("/apps")
    @method(HTTPMethod.POST)
    App postApp(App app);
}

and vibe.d generate json with nesting like such

{
    "app": {
        "id": "appid",
        "cmd": "command"
    }
}

but I need to send json without nesting like

{
    "id": "appid",
    "cmd": "command"
}
Max Alibaev
  • 681
  • 7
  • 17
zunkree
  • 21
  • 3
  • Vibe generates the json based on the method signature. You could try App postApp(string id, string cmd) as your method instead, that'd generate the Json you expect, but you'd then need to convert it to an 'App' object in your implementation. – Colin Grogan Jun 15 '16 at 10:54
  • Basically App class have much more fields than two and this is not so conveniently to pass all they to the function. – zunkree Jun 15 '16 at 11:02
  • I asked a [similar question](https://github.com/rejectedsoftware/vibe.d/issues/1422) on the Vibe.d issue tracker, you should consider opening an enhancement request over there ;-) – greenify Jun 20 '16 at 14:57

1 Answers1

0

With vibe.d 0.8.0, you can mark the method with @bodyParam to get the desired result:

@bodyParam(app)
App postApp(App app);
Kai Nacke
  • 336
  • 1
  • 6