Skip to content
This repository was archived by the owner on Mar 15, 2019. It is now read-only.

Commit ae39619

Browse files
author
Marc MacLeod
committed
don’t require a consumes to parse request body
1 parent f7d78ed commit ae39619

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/exporters/swagger.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ Swagger.prototype._mapResponseBody = function(endpoint, env) {
339339
};
340340

341341
Swagger.prototype._mapRequestBody = function(slRequestBody, requestTypes) {
342-
if (!slRequestBody.body) {
342+
if (_.isEmpty(slRequestBody.body)) {
343343
return [];
344344
}
345345
var result = [], body = jsonHelper.parse(slRequestBody.body) || {};
@@ -354,7 +354,7 @@ Swagger.prototype._mapRequestBody = function(slRequestBody, requestTypes) {
354354
var regex = /\"type\":[ ]*\"file\"|\"type\":[ ]*\"binary\"/;
355355
//export as formData only if schema includes file type property
356356
if (slRequestBody.body.match(regex) ||
357-
['multipart/form-data', 'application/x-www-form-urlencoded'].indexOf(requestTypes[0]) !== -1) {
357+
(!_.isEmpty(requestTypes) && ['multipart/form-data', 'application/x-www-form-urlencoded'].indexOf(requestTypes[0]) !== -1)) {
358358
for (var prop in body.properties) {
359359
param = body.properties[prop];
360360
param.in = 'formData';
@@ -536,10 +536,7 @@ Swagger.prototype._mapEndpoints = function (swaggerDef, env) {
536536
}
537537

538538
parameters = parameters.concat(this._mapQueryString(endpoint.QueryString));
539-
540-
if (!_.isEmpty(requestTypes)) {
541-
parameters = parameters.concat(this._mapRequestBody(endpoint.Body, requestTypes));
542-
}
539+
parameters = parameters.concat(this._mapRequestBody(endpoint.Body, requestTypes));
543540

544541
parameters = parameters.concat(this._mapRequestHeaders(endpoint.Headers));
545542
parameters = parameters.concat(this._mapEndpointTraitParameters(endpoint, parameters));

0 commit comments

Comments
 (0)