diff --git a/lib/index.js b/lib/index.js index 82b2e17..0ef1103 100644 --- a/lib/index.js +++ b/lib/index.js @@ -195,16 +195,19 @@ function parseBody (body = {}, method) { 'text/plain': {} } break - case 'formdata': + case 'formdata': { + let required = body.formdata.filter(obj => /\[required\]/gi.test(obj.description)).map(obj => obj.key) content = { 'multipart/form-data': { schema: { type: 'object', + ...(required.length ? { required: required } : {}), properties: body.formdata.reduce(mapFormData(), {}) } } } break + } case 'urlencoded': content = { 'application/x-www-form-urlencoded': { diff --git a/test/resources/output/FormData.yml b/test/resources/output/FormData.yml index 69f576c..da7d3d9 100644 --- a/test/resources/output/FormData.yml +++ b/test/resources/output/FormData.yml @@ -16,6 +16,9 @@ paths: multipart/form-data: schema: type: object + required: + - name + - email properties: name: type: string