mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Handling missing body properties
This commit is contained in:
@@ -15,7 +15,7 @@ function Node (options) {
|
|||||||
// stores all direct folder descendants of this node
|
// stores all direct folder descendants of this node
|
||||||
this.children = {};
|
this.children = {};
|
||||||
|
|
||||||
this.requests = options ? options.requests : []; // request will be an array of objects
|
this.requests = []; // request will always be an array of objects
|
||||||
|
|
||||||
this.addChildren = function (child, value) {
|
this.addChildren = function (child, value) {
|
||||||
this.children[child] = value;
|
this.children[child] = value;
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ module.exports = {
|
|||||||
// https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#pathItemObject
|
// https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#pathItemObject
|
||||||
getPathMethods = function(pathKeys) {
|
getPathMethods = function(pathKeys) {
|
||||||
var methods = [];
|
var methods = [];
|
||||||
pathKeys.forEach(function(element) {
|
pathKeys && pathKeys.forEach(function(element) {
|
||||||
if (METHODS.includes(element)) {
|
if (METHODS.includes(element)) {
|
||||||
methods.push(element);
|
methods.push(element);
|
||||||
}
|
}
|
||||||
@@ -321,8 +321,6 @@ module.exports = {
|
|||||||
currentNode.addChildren(currentPath[i], new Node({
|
currentNode.addChildren(currentPath[i], new Node({
|
||||||
name: currentPath[i],
|
name: currentPath[i],
|
||||||
requestCount: 0,
|
requestCount: 0,
|
||||||
requests: [],
|
|
||||||
children: {},
|
|
||||||
type: 'item-group'
|
type: 'item-group'
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -1012,7 +1010,7 @@ module.exports = {
|
|||||||
type: typeof value
|
type: typeof value
|
||||||
};
|
};
|
||||||
params = this.convertParamsWithStyle(encoding[key], value);
|
params = this.convertParamsWithStyle(encoding[key], value);
|
||||||
params.forEach((element) => {
|
params && params.forEach((element) => {
|
||||||
if (typeof element.value === 'object') { element.value = JSON.stringify(element.value); }
|
if (typeof element.value === 'object') { element.value = JSON.stringify(element.value); }
|
||||||
// element.value = JSON.stringify(element.value);
|
// element.value = JSON.stringify(element.value);
|
||||||
delete element.description;
|
delete element.description;
|
||||||
@@ -1387,7 +1385,7 @@ module.exports = {
|
|||||||
item.request.body = pmBody.body;
|
item.request.body = pmBody.body;
|
||||||
item.request.addHeader(pmBody.contentHeader);
|
item.request.addHeader(pmBody.contentHeader);
|
||||||
// extra form headers if encoding is present in request Body.
|
// extra form headers if encoding is present in request Body.
|
||||||
pmBody.formHeaders.forEach((element) => {
|
pmBody.formHeaders && pmBody.formHeaders.forEach((element) => {
|
||||||
item.request.addHeader(element);
|
item.request.addHeader(element);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
20
test/data/valid_openapi/wrong-body.yaml
Normal file
20
test/data/valid_openapi/wrong-body.yaml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
openapi: 3.0.0
|
||||||
|
info:
|
||||||
|
description:
|
||||||
|
Test Service
|
||||||
|
version: 0.1
|
||||||
|
title: Test Service Name
|
||||||
|
servers:
|
||||||
|
- url: https://test.com
|
||||||
|
description: Test API
|
||||||
|
paths:
|
||||||
|
/entity:
|
||||||
|
put:
|
||||||
|
summary: Update entity
|
||||||
|
operationId: updateEntity
|
||||||
|
requestBody:
|
||||||
|
schema: object # This is wrong,
|
||||||
|
# but the converter should just ignore the formHeaders if not present
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: 200 OK
|
||||||
@@ -24,9 +24,10 @@ describe('The converter must generate a collection conforming to the schema', fu
|
|||||||
expect(err).to.be.null;
|
expect(err).to.be.null;
|
||||||
|
|
||||||
let collection = conversionResult.output[0].data;
|
let collection = conversionResult.output[0].data;
|
||||||
// eslint-disable-next-line no-console
|
fs.writeFileSync(
|
||||||
// console.log(JSON.stringify(collection, null, 2));
|
path.join(__dirname, '../data/.temp/temp-collection.json'),
|
||||||
fs.writeFileSync('./temp/temp-collection.json', JSON.stringify(collection, null, 2));
|
JSON.stringify(collection, null, 2)
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user