Skip to content

Commit b39272b

Browse files
authored
Merge pull request #1157 from shockey/bug/opid-safe-access
Don't try to access operation.operationId if operation isn't an object
2 parents 99fd9bc + 0402f89 commit b39272b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/helpers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ export function isSwagger2(spec) {
2727

2828
// Strategy for determining operationId
2929
export function opId(operation, pathName, method = '') {
30+
if (!operation || typeof operation !== 'object') {
31+
return null
32+
}
3033
const idWithoutWhitespace = (operation.operationId || '').replace(/\s/g, '')
3134
if (idWithoutWhitespace.length) {
3235
return escapeString(operation.operationId)

0 commit comments

Comments
 (0)