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

Commit 2dc341e

Browse files
author
Dom Harrington
committed
Fix regression introduced in 0.9.4 which caused the reference guides to fail
1 parent 9b44ac7 commit 2dc341e

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

packages/api-explorer/__tests__/index.test.jsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,26 @@ describe('oas', () => {
151151
expect(explorer.find('Doc').get(0).props.oas).toBe(oas);
152152
});
153153

154+
// Of course... `typeof null === 'object'`
155+
it('should not error if `doc.api.apiSetting` is null', () => {
156+
const explorer = shallow(
157+
<ApiExplorer
158+
{...props}
159+
docs={[
160+
Object.assign({}, baseDoc, {
161+
api: { method: 'get', apiSetting: null },
162+
}),
163+
]}
164+
/>,
165+
);
166+
167+
expect(explorer.find('Doc').get(0).props.oas).toEqual({});
168+
});
169+
154170
it('should set it to empty object', () => {
155171
const explorer = shallow(
156172
<ApiExplorer
157173
{...props}
158-
oasFiles={{
159-
'api-setting': oas,
160-
}}
161174
docs={[baseDoc]}
162175
/>,
163176
);

packages/api-explorer/src/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ApiExplorer extends React.Component {
5050
const apiSetting =
5151
doc.category.apiSetting ||
5252
(typeof doc.api.apiSetting === 'string' && doc.api.apiSetting) ||
53-
(typeof doc.api.apiSetting === 'object' && doc.api.apiSetting._id);
53+
(typeof doc.api.apiSetting === 'object' && doc.api.apiSetting && doc.api.apiSetting._id);
5454

5555
return this.props.oasFiles[apiSetting];
5656
}

0 commit comments

Comments
 (0)