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

Commit

Permalink
Fix bug in oas-to-har when $ref lookup is required
Browse files Browse the repository at this point in the history
  • Loading branch information
Dom Harrington committed Jun 20, 2018
1 parent 9c6b00b commit 3d914af
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions packages/api-explorer/__tests__/lib/oas-to-har.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,26 @@ describe('body values', () => {
).log.entries[0].request.postData.text,
).toEqual(JSON.stringify({}));
});

it('should work for schemas that require a lookup', () => {
expect(
oasToHar(
{
components: {
requestBodies: { schema: { content: { 'application/json': { schema: { type: 'object', properties: { a: { type: 'integer' } } } } } } },
},
},
{
path: '/body',
method: 'get',
requestBody: {
$ref: '#/components/requestBodies/schema'
},
},
{ body: { a: 123 } },
).log.entries[0].request.postData.text,
).toEqual(JSON.stringify({ a: 123 }));
});
});

describe('formData values', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/api-explorer/src/lib/oas-to-har.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ module.exports = (
});
}

const schema = getSchema(pathOperation) || { schema: {} };
const schema = getSchema(pathOperation, oas) || { schema: {} };

if (schema.schema && Object.keys(schema.schema).length) {
// If there is formData, then the type is application/x-www-form-urlencoded
Expand Down

0 comments on commit 3d914af

Please sign in to comment.