You should always define the `consumes`. 

In swagger-ui, we took a little bit of a shortcut and assume application/json 
if nothing is defined. You shouldn’t rely on it though.

 

 

 

From: <swagger-swaggersocket@googlegroups.com> on behalf of vijay kumar 
<vijju311...@gmail.com>
Reply-To: "swagger-swaggersocket@googlegroups.com" 
<swagger-swaggersocket@googlegroups.com>
Date: Thursday, 6 April 2017 at 1:24
To: Swagger <swagger-swaggersocket@googlegroups.com>
Subject: Is application/json is default consumes for POST opertion?

 

Hi, 

 

if consumes is not provided at operation or global level, do we need to use 
application/json as default consumes in case of POST operation? 

 

In petstore example of POST /store/order consumes is not defined and swagger.io 
(http://petstore.swagger.io/) uses the default consumer as "application/json" 
is it excepted behavior? 

 

"/store/order": {

"post": {

"tags": ["store"],

"summary": "Place an order for a pet",

"description": "",

"operationId": "placeOrder",

"produces": ["application/xml",

"application/json"],

"parameters": [{

"in": "body",

"name": "body",

"description": "order placed for purchasing the pet",

"required": true,

"schema": {

"$ref": "#/definitions/Order"

}

}],

"responses": {

"200": {

"description": "successful operation",

"schema": {

"$ref": "#/definitions/Order"

}

},

"400": {

"description": "Invalid Order"

}

}

}

},

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to swagger-swaggersocket+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to swagger-swaggersocket+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to