Skip to content

Commit 67f5064

Browse files
committed
Use of lodash to access properties
instead of accessing spec.info.title directly,
1 parent b509057 commit 67f5064

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

lib/30XUtils/inputValidation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ module.exports = {
3232
}
3333

3434
if (!spec.info.hasOwnProperty('$ref')) {
35-
if (_.isNil(spec.info.title)) {
35+
if (_.isNil(_.get(spec, 'info.title'))) {
3636
return {
3737
result: false,
3838
reason: 'Specification must contain a title in order to generate a collection'
3939
};
4040
}
4141

42-
if (_.isNil(spec.info.version)) {
42+
if (_.isNil(_.get(spec, 'info.version'))) {
4343
return {
4444
result: false,
4545
reason: 'Specification must contain a semantic version number of the API in the Info Object'

lib/31XUtils/inputValidation31X.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ module.exports = {
2626
}
2727

2828
if (!spec.info.hasOwnProperty('$ref')) {
29-
if (_.isNil(spec.info.title)) {
29+
if (_.isNil(_.get(spec, 'info.title'))) {
3030
return {
3131
result: false,
3232
reason: 'Specification must contain a title in order to generate a collection'
3333
};
3434
}
3535

36-
if (_.isNil(spec.info.version)) {
36+
if (_.isNil(_.get(spec, 'info.version'))) {
3737
return {
3838
result: false,
3939
reason: 'Specification must contain a semantic version number of the API in the Info Object'

lib/swaggerUtils/inputValidationSwagger.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
const _ = require('lodash');
22
module.exports = {
33

44
/**
@@ -20,7 +20,8 @@ module.exports = {
2020
reason: 'The Swagger specification must have an "info" field'
2121
};
2222
}
23-
if (!(spec.info.title && spec.info.version) && !options.isFolder) {
23+
if (!(_.get(spec, 'info.title') && _.get(spec, 'info.version')) && !options.isFolder) {
24+
2425
return {
2526
result: false,
2627
reason: 'Title, and version fields are required for the Info Object'

0 commit comments

Comments
 (0)