Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestBodyConverter for more than one argument #468

Closed
farconada opened this issue Jun 5, 2013 · 3 comments
Closed

RequestBodyConverter for more than one argument #468

farconada opened this issue Jun 5, 2013 · 3 comments

Comments

@farconada
Copy link

This converter only support one method argument, isnt it? see body paramater {"name": "Post 1", "body": "This is a blog post"}

instead if you use:
{"post": {"name": "Post 1", "body": "This is a blog post"}}
you could attach more than one parameter i.e
{
"post": {"name": "Post 1", "body": "This is a blog post"},
"anotherparam": {"text": "the text"}
}
also you could have a configuration parameter to enable if request parameter conversion is wrapped by a root tag

@tystr
Copy link
Contributor

tystr commented Jun 5, 2013

Indeed, I do see the use case for configuring the root parameter name to allow deserialization of request bodies like {"post": {"name" : "post 1"}}, but I'm not sure about allowing multiple roots like your second example, as this seems to go against REST principles of modifying a single resource.

@tystr
Copy link
Contributor

tystr commented Jun 5, 2013

It seems this may need to be handled by the serializer. For example, using jms serializer, this use case is handled for xml via the @XmlRoot annotation. http://jmsyst.com/libs/serializer/master/reference/annotations#xmlroot

@tystr
Copy link
Contributor

tystr commented Jun 14, 2013

I believe you could write a custom deserialization handler for jms serializer to handle the root tag bit. Another less ideal alternative/workaround could be to use a wrapper object for deserialization:

class UserWrapper
{
    /**
     * @var User
     * @Type("User")
     */
    protected $user;
    // ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants