Skip to content

Commit 793f931

Browse files
authored
Merge pull request #91 from apiaddicts/feat/88/aditional_propertie
feat: adding additionalProperties property validation
2 parents 403f413 + 49d0353 commit 793f931

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/swagger2json/object.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const _ = require('lodash');
77
module.exports = function() {
88

99
return function get(swagger,parent){
10-
if (!swagger.properties){
11-
require('../utils/error.js')(`There is an object without properties: ${swagger}`);
12-
}
10+
11+
validationProperties(swagger);
12+
1313
let notInclude = false;
1414
if (parent && global.requiredParamsCatch && _.has(swagger, 'required')){
1515
if(!global.configurationFile.minimal_endpoints){
@@ -43,4 +43,13 @@ module.exports = function() {
4343
return object;
4444
};
4545

46+
function validationProperties(swagger){
47+
if(!swagger.properties || Object.keys(swagger.properties).length === 0){
48+
if(swagger.additionalProperties && swagger.additionalProperties !== false){
49+
return {}
50+
}
51+
require('../utils/error.js')(`There is an object without properties: ${JSON.stringify(swagger)}`);
52+
}
53+
}
54+
4655
}()

0 commit comments

Comments
 (0)