fury-adapter-oas3-parser
Advanced tools
Comparing version 0.7.0 to 0.7.2
# Fury OAS3 Parser Changelog | ||
## 0.7.2 (2019-04-01) | ||
### Bug Fixes | ||
- Added validation of media types, previously we would throw an error while | ||
handling invalid media types. | ||
## 0.7.0 (2019-03-26) | ||
@@ -4,0 +11,0 @@ |
const R = require('ramda'); | ||
const mediaTyper = require('media-typer'); | ||
const pipeParseResult = require('../../pipeParseResult'); | ||
const { isExtension, hasKey, getValue } = require('../../predicates'); | ||
const { | ||
isExtension, hasKey, getKey, getValue, | ||
} = require('../../predicates'); | ||
const { | ||
createWarning, | ||
@@ -47,2 +49,11 @@ createUnsupportedMemberWarning, | ||
const isValidMediaType = (mediaType) => { | ||
try { | ||
mediaTyper.parse(mediaType.toValue()); | ||
} catch (error) { | ||
return false; | ||
} | ||
return true; | ||
}; | ||
/** | ||
@@ -63,2 +74,10 @@ * Parse Media Type Object | ||
const createInvalidMediaTypeWarning = mediaType => createWarning(namespace, | ||
`'${name}' media type '${mediaType.toValue()}' is invalid`, mediaType); | ||
const validateMediaType = R.unless( | ||
R.compose(isValidMediaType, getKey), | ||
R.compose(createInvalidMediaTypeWarning, getKey) | ||
); | ||
const createExamplesNotJSONWarning = createWarning(namespace, | ||
@@ -104,2 +123,4 @@ `'${name}' 'examples' is only supported for JSON media types`); | ||
const parseMediaType = pipeParseResult(namespace, | ||
validateMediaType, | ||
getValue, | ||
parseObject(context, name, parseMember), | ||
@@ -152,5 +173,5 @@ (mediaTypeObject) => { | ||
return parseMediaType(element.value); | ||
return parseMediaType(element); | ||
} | ||
module.exports = R.curry(parseMediaTypeObject); |
{ | ||
"name": "fury-adapter-oas3-parser", | ||
"version": "0.7.0", | ||
"version": "0.7.2", | ||
"description": "Open API Specification 3 API Elements Parser", | ||
@@ -39,3 +39,3 @@ "author": "Apiary.io <support@apiary.io>", | ||
}, | ||
"gitHead": "853dfac567e80f4c57b6058eabcc231d282753a5" | ||
"gitHead": "3b66bdecfc9232e008843a7c78b51fdf13e7cc72" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
117575
41
2540