mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
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:
@@ -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 +
|
||||
|
||||
Reference in New Issue
Block a user