Skip to content

More convention: complex type should default to [Body] #89

Closed

Description

@clairernovotny

Right now it seems like you need to put [Body] on a parameter you want to be in the body. How about reversing that or at least making the defaults based on the verb.

I.e., for PUT/POST, a complex type would go in the body and any other parameters to the query string.
for GET, a complex type would translate to a query string parameter along with any other parameters.

Activity

  1. bennor commented on Dec 13, 2014

    @bennor
    Contributor

    I kind of like the idea, because easy == awesome, but what if somebody wants a complex type serialized as a query parameter.

    I guess we could do the following:

    • All parameters that appear in the URL template are always included in the URL, so complex types can be included as explicit querystring parameters (which I think we support already).
    • Add any other simple types as querystring parameters automatically (again, we already do this).
    • If there's only one complex type, treat it like it has an implicit [Body(BodySerializationMethod.Json)].

    What do we do if there's more than one complex type though?

    • 💥?
    • Only put the first one in the body and put any additional ones in the querystring?

    I don't think we want to wind up in a situation where we need to add a [QueryString] or [Url] attribute.

    One more thing: obviously, we'd want to treat any string as a simple type. Are there any other complex types we'd need to treat as simple types by default?

  2. clairernovotny commented on Dec 15, 2014

    @clairernovotny
    MemberAuthor

    I agree with your assumptions above...

    If there's more than one complex type, I think one of them has to have a [Body] attribute; otherwise there's no way to know what the user intended. I think it's weird to put a complex type on the query string for a put/post/patch but shrug

    I don't think string should really ever be counted as a complex type anyway :P

  3. flagbug commented on May 11, 2016

    @flagbug
    Contributor

    Closing this, as it seems to be fixed with #102

  4. locked and limited conversation to collaborators on Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions