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

Make it possible to send JSON payloads instead of URL query strings

Open joshtwo opened this issue 9 years ago • 4 comments

Q A
Bug or feature request? request
Which Swagger/OpenAPI version? 3.0
Which Swagger-UI version? 3.0.21
How did you install Swagger-UI? Node.js
Which browser & version? Firefox 55
Which operating system? Linux

Expected Behavior

Make it possible for the UI to send something like {"key1": "value", "key2": "value"} in a POST request to an API endpoint.

Current Behavior

Right now, you can only send something like key1=value&key2=value in the body, unless I'm missing something.

Possible Solution

Some sort of config parameter.

ui = new SwaggerUIBundle({
   ...
   payloadType: 'json'
   ...
});

joshtwo avatar Oct 11 '17 04:10 joshtwo

@joshtwo, this is possible 😄 see the addPet operation in the Petstore for an example: http://petstore.swagger.io/#/pet/addPet

shockey avatar Oct 11 '17 04:10 shockey

This is clearly an issue with my API then, sorry about that. I see what's going on here; I don't have the "consumes" options set at all in the swagger.json I generate.

joshtwo avatar Oct 11 '17 05:10 joshtwo

No worries @joshtwo! Did the consumes option get you what you wanted in your operation?

shockey avatar Oct 11 '17 19:10 shockey

Closing due to inactivity.

This is simply to keep our issue tracker clean - feel free to comment if there are any further thoughts or concerns, and we'll be happy to reopen this issue.

shockey avatar Oct 17 '17 19:10 shockey