Skip to content

POST missing parameters if body is also provided #239

@scholarsmate

Description

@scholarsmate

Here's the test case:

  @Test
  public void postHello()
    throws Exception
  {
    mockMvc.perform(post(buildApiPath("tests/hello")).param("name", "World").content("I have lots to share"))
        .andExpect(status().isOk())
        .andExpect(content().string("Hello World. Here is your content: I have lots to share"))
        .andDo(document("post-hello"));
  }

Here's the generated curl snippet:

[source,bash]
----
$ curl 'https://localhost:9070/api/v1/tests/hello' -i -X POST -d 'I have lots to share'
----[source,http]
----
POST /api/v1/tests/hello HTTP/1.1
Host: localhost
Content-Length: 20
Content-Type: application/x-www-form-urlencoded

I have lots to share
----[source,http]
----
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 55

Hello World. Here is your content: I have lots to share
----

Swagger gets it right:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' -d 'I have lots to share' 'http://192.168.90.70:9070/api/v1/tests/hello?name=World'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions