mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
changed the order of content type headers in openapi spec file and giving json as a first preference
This commit is contained in:
18
lib/util.js
18
lib/util.js
@@ -602,25 +602,19 @@ module.exports = {
|
||||
responseBody: ''
|
||||
};
|
||||
}
|
||||
let headers = Object.keys(contentObj),
|
||||
result = [];
|
||||
let headers = Object.keys(contentObj);
|
||||
|
||||
for (let i = 0; i < headers.length; i++) {
|
||||
let headerFamily = this.getHeaderFamily(headers[i]);
|
||||
if (headerFamily !== HEADER_TYPE.INVALID) {
|
||||
result.push(headerFamily);
|
||||
cTypeHeader = headers[i];
|
||||
hasComputedType = true;
|
||||
if (headerFamily === HEADER_TYPE.JSON) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result[HEADER_TYPE.JSON]) {
|
||||
cTypeHeader = result[HEADER_TYPE.JSON];
|
||||
hasComputedType = true;
|
||||
}
|
||||
else if (result[HEADER_TYPE.XML]) {
|
||||
cTypeHeader = result[HEADER_TYPE.XML];
|
||||
hasComputedType = true;
|
||||
}
|
||||
|
||||
// if no JSON or XML, take whatever we have
|
||||
if (!hasComputedType) {
|
||||
cTypes = Object.keys(contentObj);
|
||||
|
||||
@@ -30,13 +30,13 @@
|
||||
"200": {
|
||||
"description": "Ok: Successfully processed the request.",
|
||||
"content": {
|
||||
"application/vnd.retailer.v3+json": {
|
||||
"application/vnd.retailer.v3+xml": {
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
},
|
||||
"application/vnd.retailer.v3+xml": {
|
||||
"application/vnd.retailer.v3+json": {
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
|
||||
@@ -41,7 +41,7 @@ describe('CONVERT FUNCTION TESTS ', function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should generate collection for a custom content type headers requests.' +
|
||||
it('Should generate collection for a custom content type headers requests' +
|
||||
specPath4, function(done) {
|
||||
var openapi = fs.readFileSync(specPath4, 'utf8');
|
||||
Converter.convert({ type: 'string', data: openapi }, { schemaFaker: true }, (err, conversionResult) => {
|
||||
|
||||
Reference in New Issue
Block a user