nupfel/Web-API — pull request #12 by robn (2014-07-02 13:13:56+00:00)
Title: Support mandatory deep hash params for JSON and XML output

I don't quite now how to describe this, so I'll just write about my use case.

The [UserVoice API](https://developer.uservoice.com/docs/api/reference/) accepts form-urlencoded or JSON payloads. Some calls (eg [create ticket](https://developer.uservoice.com/docs/api/reference/#_api_v1_tickets_post)) take a "deep" structure, in this case `ticket`. For form-urlencoded the args are eg `ticket[subject]`. For JSON you pass in an actual deep hash structure.

In the case of the "create ticket" call, there's two mandatory parameters inside the `ticket` hash, `subject` and `message`. There's no way to tell `Web::API` that they're mandatory, as it just does a naive toplevel check of the options.

So this patch adds support for that. If the output content type is something that can accept a hash (ie JSON and XML), then a mandatory parameter called `foo.bar` will be interpreted as key `bar` inside hash `foo`. So using the UserVoice "create ticket" call again, it requires at minimum this structure:

```perl
{
email => q{...},
ticket => {
subject => q{...},
message => {...},
},
}
```

Which we can now declare as:
```perl
mandatory => [qw(email ticket.subject ticket.message)]
```

I suppose the other possibility might be to make `mandatory` take a hashref instead and then we just have to match up the keys. Its probably safer for the future, but a bit less convenient to use. Thoughts?