Skip to content

Commit

Permalink
refactor(oas): get rid of redundant local variables
Browse files Browse the repository at this point in the history
closes #181
  • Loading branch information
derevnjuk committed Feb 24, 2023
1 parent 8584463 commit 40ab53a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/oas/src/converter/parts/postdata/BodyConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,16 @@ export abstract class BodyConverter<T extends OpenAPI.Document>
fields?.[key]?.contentType ??
this.inferContentType(val, propertySchema);

const filenameRequired = this.filenameRequired(contentType);
const base64Encoded = this.BASE64_FORMATS.includes(
propertySchema?.format
);

const headers = [
`Content-Disposition: form-data; name="${key}"${
filenameRequired ? `; filename="${key}"` : ''
this.filenameRequired(contentType) ? `; filename="${key}"` : ''
}`,
...(contentType !== 'text/plain'
? [`Content-Type: ${contentType}`]
: []),
...(base64Encoded ? ['Content-Transfer-Encoding: base64'] : [])
...(this.BASE64_FORMATS.includes(propertySchema?.format)
? ['Content-Transfer-Encoding: base64']
: [])
];
const body = this.encodeOther(val);

Expand Down

0 comments on commit 40ab53a

Please sign in to comment.