Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
fix: adding support for handling requestBody if its in a $ref (#847)
Browse files Browse the repository at this point in the history
  • Loading branch information
erunion committed Jul 17, 2020
1 parent 783fe1a commit 7f80255
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 12 deletions.
6 changes: 3 additions & 3 deletions packages/api-explorer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/api-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@readme/oas-extensions": "^6.13.0",
"@readme/oas-to-har": "^6.15.1",
"@readme/oas-to-snippet": "^6.15.1",
"@readme/oas-tooling": "^3.5.2",
"@readme/oas-tooling": "^3.5.4",
"@readme/react-jsonschema-form": "^1.1.5",
"@readme/syntax-highlighter": "^6.15.1",
"@readme/variable": "^6.13.0",
Expand Down
63 changes: 63 additions & 0 deletions packages/oas-to-har/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,69 @@ describe('requestBody', () => {
).toBeUndefined();
});

describe('multipart/form-data', () => {
it('should handle multipart/form-data request bodies', () => {
const har = oasToHar(
new Oas({
components: {
requestBodies: {
payload: {
required: true,
content: {
'multipart/form-data': {
schema: {
type: 'object',
properties: {
'Document file': {
type: 'string',
format: 'binary',
},
},
},
},
},
},
},
securitySchemes: {
bearerAuth: {
type: 'apiKey',
name: 'Authorization',
in: 'header',
},
},
},
}),
{
path: '/multipart',
method: 'post',
security: [
{
bearerAuth: [],
},
],
requestBody: {
$ref: '#/components/requestBodies/payload',
},
responses: {
default: {
description: 'OK',
},
},
},
{
body: {
'Document file': '.....',
},
}
);

expect(har.log.entries[0].request.headers).toStrictEqual([
{ name: 'Content-Type', value: 'multipart/form-data' },
]);
expect(har.log.entries[0].request.postData.mimeType).toBe('multipart/form-data');
});
});

describe('`json` type', () => {
it('should work for refs that require a lookup', () => {
expect(
Expand Down
6 changes: 3 additions & 3 deletions packages/oas-to-har/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/oas-to-har/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "src/index.js",
"dependencies": {
"@readme/oas-extensions": "^6.13.0",
"@readme/oas-tooling": "^3.5.2"
"@readme/oas-tooling": "^3.5.4"
},
"scripts": {
"inspect": "jsinspect",
Expand Down
6 changes: 3 additions & 3 deletions packages/oas-to-snippet/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/oas-to-snippet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"devDependencies": {
"@readme/eslint-config": "^3.2.0",
"@readme/oas-examples": "^3.4.0",
"@readme/oas-tooling": "^3.5.2",
"@readme/oas-tooling": "^3.5.4",
"eslint": "^7.0.0",
"jest": "^26.0.1",
"prettier": "^2.0.1"
Expand Down

0 comments on commit 7f80255

Please sign in to comment.