swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

UI does not show request body

Open dthorpe opened this issue 13 years ago • 7 comments

Swagger-UI does not appear to show the request body in interactive "Try it out!" operations.

For example, see the wordnik api doc for authenticating the user using a POST request: http://developer.wordnik.com/docs.html#!/account/authenticatePost_post_1

dthorpe avatar Jul 31 '13 19:07 dthorpe

swagger-ui is only designed to display the response body

fehguy avatar Aug 02 '14 05:08 fehguy

Do you want to eloborate? These seems like a silly response to me in my humble opinion. Why does SwaggerUI only show responses? Would it not be nice to see the exact request that is being sent, ideally as a JSON object?

enricribas avatar Oct 28 '14 16:10 enricribas

I think it depends on what swagger-ui is being used for. If interactive documentation, then the inputs for the request are the right scope of information. If as a debugging tool, then yes I can understand why you'd want to have the full raw request. If that's your goal, I'd suggest forking the UI and rendering the data--everything is available in the underlying swagger-js library.

fehguy avatar Oct 28 '14 16:10 fehguy

Raw request vs "inputs for the request" is a pedantic distinction at this point - Swagger doesn't display request bodies in any form currently. All you can see is the output, not the input. As documentation for a web API, Swagger shows you only half of the information required to form a usable POST request.

dthorpe avatar Oct 28 '14 22:10 dthorpe

I don't follow your distinction between request bodies and request parameters.

webron avatar Dec 10 '14 10:12 webron

Oh sorry, I thought this was basic HTTP terminology.

>> GET /api/user?gender=male [request parameter]

@ApiOperation(value = "Get users")
@RequestMapping(value = "", method = RequestMethod.GET)
public List<User> getUsers(@RequestParam(value = "gender", required = false) String gender) { ... }


>> POST /api/user with HTTP request body content [request body]

    {
        name : "john doe"
        genader: "male"
    }

@ApiOperation(value = "Create a user")
@RequestMapping(value = "", method = RequestMethod.POST)
public User createUsers(@RequestBody @Valid User user) { ... }

boeboe avatar Dec 10 '14 11:12 boeboe

Since you opened #771, let's keep the correspondence there.

webron avatar Dec 10 '14 11:12 webron