Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ _.forEach(endpointsParsed, function (endpointParsed, i) {
endpointsParsed[i].bodyResponse = require('./src/parser/'+version+'/body.js')(endpointParsed.verb, endpointParsed.path, true)
endpointsParsed[i].authorization = require('./src/parser/authorization.js')(endpointParsed.verb, endpointParsed.path, authorizationTokens)
endpointsParsed[i].queryParams = require('./src/parser/'+version+'/queryParams.js')(endpointParsed.verb, endpointParsed.path)
endpointsParsed[i].headers = require('./src/parser/'+version+'/headers.js')(endpointParsed.verb, endpointParsed.path)
endpointsParsed[i].summary = require('./src/parser/summary.js')(endpointParsed.verb, endpointParsed.path)
endpointsParsed[i].microcks = require('./src/parser/openapi3/microcks.js')(endpointParsed.verb, endpointParsed.path)
});

//GENERATOR-------------------------------- */
let endpointsPostman = [];
const endpoints = require('./src/generator/endpoints.js')(endpointsParsed);
// console.log(endpoints);

_.forEach(endpoints, function (endpoint, i) {
for (let index = 0; index < endpoint.count; index++) {
Expand Down
2 changes: 1 addition & 1 deletion src/generator/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = function() {
microcks: endpoint.microcks || false,
request: {
method: endpoint.verb,
header: [],
header: endpoint.headers ? endpoint.headers : [],
body: {
mode: "raw",
raw: ""
Expand Down
2 changes: 1 addition & 1 deletion src/generator/environmentVariablesNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = function() {
if(request.header){
for (let i in request.header){
request.header[i].key = extractVariablesFromString(numerateItem,request.header[i].key,items,itemKeys,id);
request.header[i].value = extractVariablesFromString(numerateItem, request.header[i].value, items, itemKeys, id, request.header[i].key === 'Authorization');
request.header[i].value = typeof request.header[i].value == 'number' || typeof request.header[i].value == 'object' ? request.header[i].value : extractVariablesFromString(numerateItem, request.header[i].value, items, itemKeys, id, request.header[i].key === 'Authorization');
}
}
if (request.body && request.body.raw) {
Expand Down
42 changes: 42 additions & 0 deletions src/parser/openapi3/headers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** Part of APIAddicts. See LICENSE fileor full copyright and licensing details. Supported by Madrid Digital and CloudAPPi **/

'use strict'

const _ = require('lodash');

module.exports = function() {

return function get(verb,path){
if (!_.isObject(global.definition.paths)) {
require('../../utils/error.js')('paths is required')
}

let parameters = global.definition.paths[path][_.toLower(verb)]['parameters'];
// parameters = replaceRefs(parameters);
let headers = _.filter(parameters, ['in', 'header'])
const result = []
_.forEach(headers, function(header) {
result.push({
key: header.name,
type: header.schema.type,
required : header.required,
value: getExamples(header)
});
});
return result
};

function getExamples(header) {
if (header.example) {
return header.example
}
else {
if (header.hasOwnProperty('examples')) {
const value = header.examples[Object.keys(header.examples)[0]];
return value[Object.keys(value)[0]];
}
return header.example;
}
}

}()
42 changes: 42 additions & 0 deletions src/parser/swagger2/headers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** Part of APIAddicts. See LICENSE fileor full copyright and licensing details. Supported by Madrid Digital and CloudAPPi **/

'use strict'

const _ = require('lodash');

module.exports = function() {

return function get(verb,path){
if (!_.isObject(global.definition.paths)) {
require('../../utils/error.js')('paths is required')
}

let parameters = global.definition.paths[path][_.toLower(verb)]['parameters'];
// parameters = replaceRefs(parameters);
let headers = _.filter(parameters, ['in', 'header'])
const result = []
_.forEach(headers, function(header) {
result.push({
key: header.name,
type: header.schema.type,
required : header.required,
value: getExamples(header)
});
});
return result
};

function getExamples(header) {
if (header.example) {
return header.example
}
else {
if (header.hasOwnProperty('examples')) {
const value = header.examples[Object.keys(header.examples)[0]];
return value[Object.keys(value)[0]];
}
return header.example;
}
}

}()