@apielements/openapi2-parser
Advanced tools
Comparing version 0.30.0 to 0.31.0
# API Elements: OpenAPI 2 Parser Changelog | ||
## 0.31.0 (2020-05-12) | ||
### Bug Fixes | ||
- The parser will now produce a data structure for Schema Object's which do not | ||
contain a `type`. | ||
- Added the `fixedType` attribute to array data structures which describe | ||
arrays with fixed types in the items. For example, the following schema which | ||
describes an array where the values MUST be of type string: | ||
```yaml | ||
type: array | ||
items: | ||
type: string | ||
``` | ||
Previously we generated a data structure for an array which didn't fix the | ||
values of the array to be a string type. Instead provided an example that the | ||
value of the array MAY be a string. | ||
- Support required keys in a Schema Object which are not found in the | ||
properties list. | ||
## 0.30.0 (2020-04-29) | ||
@@ -4,0 +28,0 @@ |
@@ -99,7 +99,7 @@ /* eslint-disable class-methods-use-this, arrow-body-style */ | ||
const refElements = refs.map(ref => new RefElement(ref)); | ||
element.content = element.content.concat(refElements); | ||
element.content.push(...refElements); | ||
} | ||
} | ||
element.content = element.content.concat(_.map(properties, (subschema, property) => { | ||
element.content.push(..._.map(properties, (subschema, property) => { | ||
const member = this.generateMember(property, subschema); | ||
@@ -115,2 +115,11 @@ | ||
// Create member elements for required keys which are not defined in properties | ||
const missingRequiredProperties = required.filter(name => properties[name] === undefined); | ||
const requiredMembers = missingRequiredProperties.map((name) => { | ||
const member = new this.minim.elements.Member(name); | ||
member.attributes.set('typeAttributes', ['required']); | ||
return member; | ||
}); | ||
element.content.push(...requiredMembers); | ||
return element; | ||
@@ -125,2 +134,4 @@ } | ||
if (schema.items) { | ||
element.attributes.set('typeAttributes', ['fixedType']); | ||
if (_.isArray(schema.items)) { | ||
@@ -209,7 +220,2 @@ schema.items.forEach((item) => { | ||
} | ||
if (schema.properties) { | ||
// Assume user meant object | ||
return 'object'; | ||
} | ||
} | ||
@@ -278,2 +284,11 @@ | ||
throw new Error(`Unhandled schema type '${type}'`); | ||
} else { | ||
element = new this.minim.elements.Enum(); | ||
element.enumerations = [ | ||
new this.minim.elements.String(), | ||
new this.minim.elements.Number(), | ||
new this.minim.elements.Boolean(), | ||
this.generateArray(schema), | ||
this.generateObject(schema), | ||
]; | ||
} | ||
@@ -280,0 +295,0 @@ |
{ | ||
"name": "@apielements/openapi2-parser", | ||
"version": "0.30.0", | ||
"version": "0.31.0", | ||
"description": "Swagger 2.0 parser for Fury.js", | ||
@@ -41,7 +41,8 @@ "author": "Apiary.io <support@apiary.io>", | ||
"mocha": "^7.1.1", | ||
"swagger-zoo": "^3.1.2" | ||
"swagger-zoo": "^3.1.3" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
} | ||
}, | ||
"gitHead": "afe6ace0248c29878c95c618e028e4dd36cc102d" | ||
} |
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
120256
15
2428