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
17 changes: 14 additions & 3 deletions forward_engineering/helpers/componentsHelpers/parametersHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,21 @@ function getContent(data, isParentActivated) {
return;
}

return Object.keys(data.properties).reduce((acc, key) => {
const result = Object.keys(data.properties).reduce((acc, key) => {
const properties = get(data, `properties[${key}].properties`);
if (!properties) {
return;
return acc;
}
const schemaKeyword = getSchemaKeyword(properties);

if (!schemaKeyword) {
return acc;
}

const isSchemaEmpty = properties[schemaKeyword] && get(properties, [schemaKeyword, 'type']) === 'object' && !get(properties, [schemaKeyword, 'properties']);
const isExamplesEmpty = !get(properties, 'examples.properties');
if (isSchemaEmpty && isExamplesEmpty) {
return;
return acc;
}
const isActivated = data.properties[key].isActivated;
acc[key] = commentDeactivatedItemInner(
Expand All @@ -121,6 +126,12 @@ function getContent(data, isParentActivated) {
);
return acc;
}, {});

if (!Object.keys(result).length) {
return;
}

return result;
}

function mapMediaTypeObject(data, isParentActivated = false) {
Expand Down
17 changes: 12 additions & 5 deletions forward_engineering/helpers/pathHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function getRequestData(collections, containers, containerId, containersPath = [
.map(data => {
const isRequestActivated = data.isActivated && isPathActivated;
const requestBodyPropKeyword = getRequestBodyPropKeyword(data.properties);
const request = {
let request = {
tags: commonHelper.mapArrayFieldByName(data.tags, 'tag'),
summary: data.summary,
description: data.description,
Expand All @@ -58,12 +58,20 @@ function getRequestData(collections, containers, containerId, containersPath = [
parameters: mapRequestParameters(
get(data, 'properties.parameters'),
isRequestActivated
),
requestBody: mapRequestBody(
)
};
const extensions = getExtensions(data.scopesExtensions);

if (!['get', 'delete'].includes(String(data.collectionName).toLowerCase())) {
request.requestBody = mapRequestBody(
get(data.properties, requestBodyPropKeyword),
get(data, 'required', []).includes(requestBodyPropKeyword),
isRequestActivated
),
);
}

request = {
...request,
responses: mapResponses(
collections,
data.GUID,
Expand All @@ -81,7 +89,6 @@ function getRequestData(collections, containers, containerId, containersPath = [
methodName: data.collectionName,
isActivated: data.isActivated,
};
const extensions = getExtensions(data.scopesExtensions);

return Object.assign({}, request, extensions);
})
Expand Down
3 changes: 2 additions & 1 deletion reverse_engineering/helpers/dataHelper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

const commonHelper = require('./commonHelper');
const propertiesConfig = require('../propertiesConfig');
const jsonComment = require('comment-json');

const REQUEST = 'request';
const RESPONSE = 'response';
Expand Down Expand Up @@ -868,7 +869,7 @@ const getModelContent = (pathData, fieldOrder, callbacksComponent) => {

const getOpenAPIJsonSchema = (data, fileName, extension) => {
const schema = extension !== '.json' ? commonHelper.convertYamlToJson(data) : data;
const openAPISchema = typeof schema === 'string' ? JSON.parse(schema) : schema;
const openAPISchema = typeof schema === 'string' ? jsonComment.parse(schema.replace(/^\s*#.+$/mg, '')) : schema;
const updatedOpenApiSchema = copyPathItemLevelParametersToOperationObject(openAPISchema);
const openAPISchemaWithModelName = Object.assign({}, updatedOpenApiSchema, {
modelName: fileName
Expand Down
21 changes: 21 additions & 0 deletions reverse_engineering/node_modules/array-timsort/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading