Skip to content

Commit

Permalink
fix: issue #735 no required for arrays in swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
glennjones committed Jun 11, 2022
1 parent 22b74c2 commit a3d27cb
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 123 deletions.
5 changes: 5 additions & 0 deletions lib/definitions.js
Expand Up @@ -63,6 +63,11 @@ internals.append = function(definitionName, definition, currentCollection, force

delete definition.optional;

// The "required" keyword is only applicable for objects not arrays
if (definition.required && definition.items !== undefined) {
delete definition.required
}

// find definitionName by matching hash of object
if (settings.reuseDefinitions) {
foundDefinitionName = internals.hasDefinition(definition, currentCollection);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -53,7 +53,7 @@
"handlebars": "^4.7.7",
"http-status": "^1.5.2",
"json-schema-ref-parser": "^6.1.0",
"swagger-parser": "4.0.2",
"swagger-parser": "^10.0.3",
"swagger-ui-dist": "^4.11.1"
},
"devDependencies": {
Expand Down
6 changes: 2 additions & 4 deletions test/Integration/responses-tests.js
Expand Up @@ -609,8 +609,7 @@ lab.experiment('responses', () => {
type: 'array',
items: {
$ref: '#/definitions/datapoint'
},
required: ['datapoint']
}
}
});
const isValid = await Validate.test(response.result);
Expand Down Expand Up @@ -663,8 +662,7 @@ lab.experiment('responses', () => {
type: 'array',
items: {
$ref: '#/definitions/datapoint'
},
required: ['datapoint']
}
}
});
const isValid = await Validate.test(response.result);
Expand Down

0 comments on commit a3d27cb

Please sign in to comment.