fury-adapter-oas3-parser
Advanced tools
Comparing version 0.10.2 to 0.11.0
# Fury OAS3 Parser Changelog | ||
## 0.11.0 (2020-04-20) | ||
### Enhancements | ||
- Compatibility with [Fury 3.0.0 Beta 14](https://github.com/apiaryio/api-elements.js/releases/tag/fury@3.0.0-beta.14). | ||
- Support for "default" response status codes. | ||
- Support for `Server Object` and `Server Variable Object` | ||
- The parser can now be configured to disable generation of example message | ||
bodies by providing an adapter option `generateMessageBody` as `false` during | ||
parse. | ||
## 0.10.2 (2020-03-16) | ||
@@ -4,0 +18,0 @@ |
@@ -6,9 +6,12 @@ const State = require('./state.js'); | ||
this.namespace = namespace; | ||
this.options = options || {}; | ||
if (options === undefined) { | ||
this.options = { generateSourceMap: false }; | ||
} else { | ||
this.options = options; | ||
if (this.options.generateSourceMap === undefined) { | ||
this.options.generateSourceMap = false; | ||
} | ||
if (this.options.generateMessageBody === undefined) { | ||
this.options.generateMessageBody = true; | ||
} | ||
this.state = new State(); | ||
@@ -15,0 +18,0 @@ } |
@@ -201,3 +201,3 @@ const R = require('ramda'); | ||
if (!messageBody && dataStructure && canGenerateMessageBodyForMediaType(mediaType)) { | ||
if (!messageBody && dataStructure && context.options.generateMessageBody && canGenerateMessageBodyForMediaType(mediaType)) { | ||
const asset = generateMessageBody(context, mediaType, dataStructure); | ||
@@ -204,0 +204,0 @@ if (asset) { |
@@ -15,2 +15,3 @@ /* eslint-disable no-underscore-dangle */ | ||
const parseOpenAPI = require('../openapi'); | ||
const parseServersArray = require('./parseServersArray'); | ||
const parseInfoObject = require('./parseInfoObject'); | ||
@@ -23,3 +24,3 @@ const parsePathsObject = require('./parsePathsObject'); | ||
const requiredKeys = ['openapi', 'info', 'paths']; | ||
const unsupportedKeys = ['servers', 'tags', 'externalDocs']; | ||
const unsupportedKeys = ['tags', 'externalDocs']; | ||
@@ -114,2 +115,3 @@ /** | ||
[hasKey('openapi'), parseOpenAPI(context)], | ||
[hasKey('servers'), R.compose(parseServersArray(context), getValue)], | ||
[hasKey('info'), R.compose(parseInfoObject(context), getValue)], | ||
@@ -133,2 +135,3 @@ [hasKey('components'), R.compose(parseComponentsObject(context), getValue)], | ||
const api = object.get('info'); | ||
const hosts = object.get('servers'); | ||
const components = object.get('components'); | ||
@@ -147,2 +150,6 @@ const security = object.get('security'); | ||
if (hosts) { | ||
api.push(hosts); | ||
} | ||
const resources = object.get('paths'); | ||
@@ -149,0 +156,0 @@ if (resources) { |
@@ -42,10 +42,3 @@ const R = require('ramda'); | ||
const createUnsupportedStatusCodeWarning = (member) => { | ||
let message; | ||
if (member.key.toValue() === 'default') { | ||
message = `'${name}' default responses are unsupported`; | ||
} else { | ||
message = `'${name}' response status code ranges are unsupported`; | ||
} | ||
const message = `'${name}' response status code ranges are unsupported`; | ||
return createWarning(namespace, message, member.key); | ||
@@ -59,6 +52,8 @@ }; | ||
const isStatusCodeOrDefault = R.anyPass([isStatusCode, hasKey('default')]); | ||
// FIXME Add support for status code ranges | ||
// https://github.com/apiaryio/fury-adapter-oas3-parser/issues/64 | ||
const validateStatusCode = pipeParseResult(namespace, | ||
R.unless(isStatusCode, createUnsupportedStatusCodeWarning), | ||
R.unless(isStatusCodeOrDefault, createUnsupportedStatusCodeWarning), | ||
R.unless(isKeyString, attachStatusCodeNotStringWarning)); | ||
@@ -84,3 +79,7 @@ | ||
const response = member.value; | ||
response.statusCode = String(member.key.toValue()); | ||
if (isStatusCode(member)) { | ||
response.statusCode = String(member.key.toValue()); | ||
} | ||
return response; | ||
@@ -87,0 +86,0 @@ })); |
@@ -9,3 +9,3 @@ const R = require('ramda'); | ||
const { | ||
isArray, isNull, isString, hasKey, hasValue, getValue, | ||
isString, hasKey, hasValue, getValue, | ||
} = require('../../predicates'); | ||
@@ -16,2 +16,3 @@ const parseObject = require('../parseObject'); | ||
const parseBoolean = require('../parseBoolean'); | ||
const parseEnum = require('../parseEnum'); | ||
const parseReference = require('../parseReference'); | ||
@@ -38,13 +39,2 @@ | ||
const parseEnum = context => pipeParseResult(context.namespace, | ||
R.unless(isArray, createWarning(context.namespace, `'${name}' 'enum' is not an array`)), | ||
(element) => { | ||
const enumElement = new context.namespace.elements.Enum(); | ||
enumElement.enumerations = element; | ||
enumElement.enumerations.forEach( | ||
R.unless(isNull, value => value.attributes.set('typeAttributes', ['fixed'])) | ||
); | ||
return enumElement; | ||
}); | ||
function constructObjectStructure(namespace, schema) { | ||
@@ -158,3 +148,3 @@ const element = R.or(schema.get('properties'), new namespace.elements.Object()); | ||
[hasKey('type'), parseType], | ||
[hasKey('enum'), R.compose(parseEnum(context), getValue)], | ||
[hasKey('enum'), R.compose(parseEnum(context, name), getValue)], | ||
[hasKey('properties'), R.compose(parseProperties, getValue)], | ||
@@ -161,0 +151,0 @@ [hasKey('items'), R.compose(parseSubSchema, getValue)], |
{ | ||
"name": "fury-adapter-oas3-parser", | ||
"version": "0.10.2", | ||
"version": "0.11.0", | ||
"description": "Open API Specification 3 API Elements Parser", | ||
@@ -28,7 +28,7 @@ "author": "Apiary.io <support@apiary.io>", | ||
"media-typer": "^1.0.1", | ||
"ramda": "0.26.1", | ||
"ramda": "0.27.0", | ||
"yaml-js": "^0.2.3" | ||
}, | ||
"peerDependencies": { | ||
"fury": "3.0.0-beta.13" | ||
"fury": "3.0.0-beta.14" | ||
}, | ||
@@ -38,3 +38,3 @@ "devDependencies": { | ||
"eslint": "^5.16.0", | ||
"fury": "3.0.0-beta.13", | ||
"fury": "3.0.0-beta.14", | ||
"mocha": "^5.2.0" | ||
@@ -45,3 +45,3 @@ }, | ||
}, | ||
"gitHead": "6e1847da00044d7c1a2dade05572be01cb87d23d" | ||
"gitHead": "50efa2948c1d449bf6a13bfb15b4768920813d66" | ||
} |
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
137542
48
3180
+ Addedfury@3.0.0-beta.14(transitive)
+ Addedramda@0.27.0(transitive)
- Removedfury@3.0.0-beta.13(transitive)
- Removedramda@0.26.10.27.2(transitive)
Updatedramda@0.27.0