Skip to content
This repository has been archived by the owner on Jul 23, 2021. It is now read-only.

Commit

Permalink
Handle null values in object check (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
KariHe authored and tchock committed Nov 12, 2019
1 parent 78a81be commit 672f62e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function replaceModelRefs(restApiId, cfModel) {
}
cfModel.DependsOn.add(match[1]+'Model');
}
} else if (typeof obj[key] === 'object') {
} else if (typeof obj[key] === 'object' && obj[key] !== null) {
replaceRefs(obj[key]);
}
}
Expand Down
22 changes: 22 additions & 0 deletions src/models.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,27 @@ describe('ServerlessAWSDocumentation', function() {
});
});

it('should not crash with null values', () => {
let modelInput = {
contentType: 'application/json',
name: 'TestModel',
schema: {
type: 'object',
properties: {
prop: {
enum: ['test', null],
default: null
}
}
}
};

let modelExecution = function() {
objectUnderTest.createCfModel({
Ref: 'ApiGatewayRestApi',
})(modelInput);
}
expect(modelExecution).not.toThrow();
});
});
})

0 comments on commit 672f62e

Please sign in to comment.