mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Deref object in form data params
Dereference form data params
This commit is contained in:
@@ -1820,6 +1820,10 @@ module.exports = {
|
||||
bodyData = this.convertToPmBodyData(contentObj[FORM_DATA], requestType, FORM_DATA,
|
||||
PARAMETER_SOURCE.REQUEST, options.indentCharacter, components, options, schemaCache);
|
||||
encoding = contentObj[FORM_DATA].encoding ? contentObj[FORM_DATA].encoding : {};
|
||||
|
||||
if (contentObj[FORM_DATA].hasOwnProperty('schema') && contentObj[FORM_DATA].schema.hasOwnProperty('$ref')) {
|
||||
contentObj[FORM_DATA].schema = this.getRefObject(contentObj[FORM_DATA].schema.$ref, components, options);
|
||||
}
|
||||
// create the form parameters and add it to the request body object
|
||||
_.forOwn(bodyData, (value, key) => {
|
||||
|
||||
|
||||
33
test/data/valid_openapi/form_data_param_description.yaml
Normal file
33
test/data/valid_openapi/form_data_param_description.yaml
Normal file
@@ -0,0 +1,33 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: My REST API
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/description-test:
|
||||
post:
|
||||
description: Endpoint description
|
||||
operationId: description-test
|
||||
requestBody:
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
$ref: '#/components/schemas/RequestSchema'
|
||||
responses:
|
||||
"201":
|
||||
description: Response description
|
||||
content:
|
||||
application/json;charset=UTF-8:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
responseParam:
|
||||
type: string
|
||||
description: Response param description
|
||||
components:
|
||||
schemas:
|
||||
RequestSchema:
|
||||
type: object
|
||||
properties:
|
||||
requestParam:
|
||||
type: string
|
||||
description: Request param description
|
||||
@@ -50,7 +50,8 @@ describe('CONVERT FUNCTION TESTS ', function() {
|
||||
issue10229 = path.join(__dirname, VALID_OPENAPI_PATH, '/issue#10229.json'),
|
||||
deepObjectLengthProperty = path.join(__dirname, VALID_OPENAPI_PATH, '/deepObjectLengthProperty.yaml'),
|
||||
valuePropInExample = path.join(__dirname, VALID_OPENAPI_PATH, '/valuePropInExample.yaml'),
|
||||
petstoreParamExample = path.join(__dirname, VALID_OPENAPI_PATH, '/petstoreParamExample.yaml');
|
||||
petstoreParamExample = path.join(__dirname, VALID_OPENAPI_PATH, '/petstoreParamExample.yaml'),
|
||||
formDataParamDescription = path.join(__dirname, VALID_OPENAPI_PATH, '/form_data_param_description.yaml');
|
||||
|
||||
|
||||
it('Should add collection level auth with type as `bearer`' +
|
||||
@@ -1141,6 +1142,21 @@ describe('CONVERT FUNCTION TESTS ', function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('[Github #559]Should convert description in form data parameters' +
|
||||
petstoreParamExample, function(done) {
|
||||
var openapi = fs.readFileSync(formDataParamDescription, 'utf8');
|
||||
Converter.convert({ type: 'string', data: openapi },
|
||||
{ }, (err, conversionResult) => {
|
||||
expect(err).to.be.null;
|
||||
expect(conversionResult.result).to.equal(true);
|
||||
expect(conversionResult.output[0].data.item[0].request.body.formdata[0].description)
|
||||
.to.equal('Request param description');
|
||||
expect(conversionResult.output[0].data.item[0].request.body.formdata[0].key).to.equal('requestParam');
|
||||
expect(conversionResult.output[0].data.item[0].request.body.formdata[0].value).to.equal('<string>');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('Converting swagger 2.0 files', function() {
|
||||
it('should convert path paramters to postman-compatible paramters', function (done) {
|
||||
|
||||
Reference in New Issue
Block a user