Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit 248f0f2

Browse files
authored
Merge pull request #208 from apiaryio/kylef/oas3-invalid-schemes
Handle invalid security scheme components
2 parents 7dab229 + 5bf3518 commit 248f0f2

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

Diff for: packages/fury-adapter-oas3-parser/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
- Fixes a bug where parsing an OpenAPI 3.1.0 or higher document will result in
88
an parse result containing only a warning and missing the API Category.
99

10+
- Fixes the parser from throwing an error while handling invalid or unsupported
11+
security scheme components.
12+
1013
## 0.7.2 (2019-04-01)
1114

1215
### Bug Fixes

Diff for: packages/fury-adapter-oas3-parser/lib/parser/oas/parseComponentsObject.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,11 @@ function parseComponentsObject(context, element) {
150150
const array = new namespace.elements.Array([]);
151151

152152
object.forEach((value, key) => {
153-
// eslint-disable-next-line no-param-reassign
154-
value.meta.id = key.clone();
155-
array.push(value);
153+
if (value) {
154+
// eslint-disable-next-line no-param-reassign
155+
value.meta.id = key.clone();
156+
array.push(value);
157+
}
156158
});
157159

158160
return array;

Diff for: packages/fury-adapter-oas3-parser/test/unit/parser/oas/parseComponentsObject-test.js

+18
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,24 @@ describe('Components Object', () => {
322322
expect(securitySchemes.get(0)).to.be.instanceof(namespace.elements.AuthScheme);
323323
expect(securitySchemes.get(0).meta.id.toValue()).to.equal('token');
324324
});
325+
326+
it('handles invalid security scheme', () => {
327+
const components = new namespace.elements.Object({
328+
securitySchemes: {
329+
Basic: null,
330+
},
331+
});
332+
333+
const parseResult = parse(context, components);
334+
expect(parseResult.length).to.equal(2);
335+
336+
const parsedComponents = parseResult.get(0);
337+
expect(parsedComponents).to.be.instanceof(namespace.elements.Object);
338+
339+
const schemes = parsedComponents.get('securitySchemes');
340+
expect(schemes).to.be.instanceof(namespace.elements.Array);
341+
expect(schemes.isEmpty).to.be.true;
342+
});
325343
});
326344

327345
describe('#examples', () => {

0 commit comments

Comments
 (0)