openapi-request-coercer
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -7,2 +7,6 @@ # openapi-request-coercer Changelog | ||
## 2.2.1 - 2019-01-31 | ||
### Added | ||
- openapi-types: OpenAPIV3: relax security requirement object types (#327) | ||
## 2.2.0 - 2018-11-21 | ||
@@ -9,0 +13,0 @@ ### Added |
@@ -5,5 +5,3 @@ "use strict"; | ||
function OpenAPIRequestCoercer(args) { | ||
var loggingKey = args && args.loggingKey ? | ||
args.loggingKey + ": " : | ||
''; | ||
var loggingKey = args && args.loggingKey ? args.loggingKey + ": " : ''; | ||
if (!args) { | ||
@@ -15,5 +13,3 @@ throw new Error(loggingKey + "missing args argument"); | ||
} | ||
var extensionBase = args && args.extensionBase ? | ||
args.extensionBase : | ||
'x-openapi-coercion'; | ||
var extensionBase = args && args.extensionBase ? args.extensionBase : 'x-openapi-coercion'; | ||
var strictExtensionName = extensionBase + "-strict"; | ||
@@ -72,4 +68,6 @@ var enableObjectCoercion = !!args.enableObjectCoercion; | ||
var OBJECT_FORMAT_COERCER = { | ||
"default": function (input) { return JSON.parse(input); } | ||
//other formats | ||
"default": function (input) { | ||
return JSON.parse(input); | ||
} | ||
// other formats | ||
}; | ||
@@ -88,3 +86,3 @@ var COERCION_STRATEGIES = { | ||
object: function (format, input) { | ||
return (OBJECT_FORMAT_COERCER[format] || OBJECT_FORMAT_COERCER['default'])(input); | ||
return (OBJECT_FORMAT_COERCER[format] || OBJECT_FORMAT_COERCER["default"])(input); | ||
}, | ||
@@ -123,7 +121,7 @@ boolean: function (input) { | ||
function buildCoercer(args) { | ||
var l = args.isHeaders ? | ||
function (name) { | ||
var l = args.isHeaders | ||
? function (name) { | ||
return name.toLowerCase(); | ||
} : | ||
function (name) { | ||
} | ||
: function (name) { | ||
return name; | ||
@@ -150,6 +148,9 @@ }; | ||
} | ||
if (schema.items.type === 'array' || (schema.items.schema && schema.items.schema.type === 'array')) { | ||
if (schema.items.type === 'array' || | ||
(schema.items.schema && schema.items.schema.type === 'array')) { | ||
throw new Error(args.loggingKey + "nested arrays are not allowed (items was of type array)"); | ||
} | ||
var itemsType = (schema.items.schema && schema.items.schema.type) ? schema.items.schema.type : schema.items.type; | ||
var itemsType = schema.items.schema && schema.items.schema.type | ||
? schema.items.schema.type | ||
: schema.items.type; | ||
itemCoercer = getCoercer(itemsType, strict); | ||
@@ -161,3 +162,5 @@ if (itemsType === 'object') { | ||
else { | ||
var itemsFormat = (schema.items.schema) ? schema.items.schema.format : schema.format; | ||
var itemsFormat = schema.items.schema | ||
? schema.items.schema.format | ||
: schema.format; | ||
itemCoercer = itemCoercer.bind(null, itemsFormat); | ||
@@ -172,3 +175,3 @@ } | ||
if (param.style === 'form' && param["in"] === 'query') { | ||
collectionFormat = (param.explodes) ? 'multi' : 'csv'; | ||
collectionFormat = param.explodes ? 'multi' : 'csv'; | ||
} | ||
@@ -179,6 +182,8 @@ else if (param.style === 'simple' && | ||
} | ||
else if (param.style === 'spaceDelimited' && param["in"] === 'query') { | ||
else if (param.style === 'spaceDelimited' && | ||
param["in"] === 'query') { | ||
collectionFormat = 'ssv'; | ||
} | ||
else if (param.style === 'pipeDelimited' && param["in"] === 'query') { | ||
else if (param.style === 'pipeDelimited' && | ||
param["in"] === 'query') { | ||
collectionFormat = 'pipes'; | ||
@@ -185,0 +190,0 @@ } |
{ | ||
"name": "openapi-request-coercer", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Coerce request properties according to an openapi parameter list.", | ||
@@ -29,4 +29,4 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"openapi-types": "^1.3.1" | ||
"openapi-types": "1.3.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
22511
251
+ Addedopenapi-types@1.3.4(transitive)
- Removedopenapi-types@1.3.5(transitive)
Updatedopenapi-types@1.3.4