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

Handle invalid security scheme components #208

Merged
merged 1 commit into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/fury-adapter-oas3-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- Fixes a bug where parsing an OpenAPI 3.1.0 or higher document will result in
an parse result containing only a warning and missing the API Category.

- Fixes the parser from throwing an error while handling invalid or unsupported
security scheme components.

## 0.7.2 (2019-04-01)

### Bug Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,11 @@ function parseComponentsObject(context, element) {
const array = new namespace.elements.Array([]);

object.forEach((value, key) => {
// eslint-disable-next-line no-param-reassign
value.meta.id = key.clone();
array.push(value);
if (value) {
// eslint-disable-next-line no-param-reassign
value.meta.id = key.clone();
array.push(value);
}
});

return array;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,24 @@ describe('Components Object', () => {
expect(securitySchemes.get(0)).to.be.instanceof(namespace.elements.AuthScheme);
expect(securitySchemes.get(0).meta.id.toValue()).to.equal('token');
});

it('handles invalid security scheme', () => {
const components = new namespace.elements.Object({
securitySchemes: {
Basic: null,
},
});

const parseResult = parse(context, components);
expect(parseResult.length).to.equal(2);

const parsedComponents = parseResult.get(0);
expect(parsedComponents).to.be.instanceof(namespace.elements.Object);

const schemes = parsedComponents.get('securitySchemes');
expect(schemes).to.be.instanceof(namespace.elements.Array);
expect(schemes.isEmpty).to.be.true;
});
});

describe('#examples', () => {
Expand Down