Merge pull request #344 from postmanlabs/feature/fix-urlencoded-required-properties

Fixed issue where non-required params were not disbled for urlencoded body.
This commit is contained in:
Vishal Shingala
2021-03-17 20:01:57 +05:30
committed by GitHub
3 changed files with 15 additions and 8 deletions

View File

@@ -1696,11 +1696,9 @@ module.exports = {
if (_.get(contentObj[URLENCODED], 'schema.type') === 'object') {
description = _.get(contentObj[URLENCODED], ['schema', 'properties', key, 'description'], '');
required = _.get(contentObj[URLENCODED], ['schema', 'properties', key, 'required'], false);
required = _.includes(_.get(contentObj[URLENCODED], ['schema', 'required']), key);
enumValue = _.get(contentObj[URLENCODED], ['schema', 'properties', key, 'enum']);
}
description = (required ? '(Required) ' : '') + description +
(enumValue ? ' (This can only be one of ' + enumValue + ')' : '');
!encoding[key] && (encoding[key] = {});
encoding[key].name = key;
@@ -1710,6 +1708,7 @@ module.exports = {
// for urlencoded body serialisation is treated similar to query param
// reference https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#fixed-fields-13
encoding[key].in = 'query';
_.isBoolean(required) && (encoding[key].required = required);
encoding[key].description = description;
params = this.convertParamsWithStyle(encoding[key], value, PARAMETER_SOURCE.REQUEST, components,
@@ -1756,7 +1755,7 @@ module.exports = {
if (_.get(contentObj[FORM_DATA], 'schema.type') === 'object') {
description = _.get(contentObj[FORM_DATA], ['schema', 'properties', key, 'description'], '');
required = _.get(contentObj[FORM_DATA], ['schema', 'properties', key, 'required'], false);
required = _.includes(_.get(contentObj[FORM_DATA], ['schema', 'required']), key);
enumValue = _.get(contentObj[FORM_DATA], ['schema', 'properties', key, 'enum']);
}
description = (required ? '(Required) ' : '') + description +