Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit 1a6f132

Browse files
committed
fix(oas2): use forOwn to iterate over objects
`forEach` will treat object as an array if it contains a property `length`
1 parent 58a2003 commit 1a6f132

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

packages/fury-adapter-swagger/lib/generator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const bodyFromSchema = (schema, payload, parser, contentType = 'application/json
5656
const boundary = parseBoundary(contentType);
5757
let content = '';
5858

59-
_.forEach(body, (value, key) => {
59+
_.forOwn(body, (value, key) => {
6060
content += `--${boundary}\r\n`;
6161
content += `Content-Disposition: form-data; name="${key}"\r\n\r\n`;
6262
content += `${value}\r\n`;

packages/fury-adapter-swagger/lib/json-schema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ const convertSchemaDefinitions = (definitions) => {
379379
const jsonSchemaDefinitions = {};
380380

381381
if (definitions) {
382-
_.forEach(definitions, (schema, key) => {
382+
_.forOwn(definitions, (schema, key) => {
383383
jsonSchemaDefinitions[key] = convertSchema(schema, { definitions }, { definitions }, false);
384384
});
385385
}

packages/fury-adapter-swagger/lib/parser.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class Parser {
192192

193193
const paths = _.omitBy(swagger.paths, isExtension);
194194

195-
_.forEach(paths, (pathValue, href) => {
195+
_.forOwn(paths, (pathValue, href) => {
196196
this.handleSwaggerPath(pathValue, href);
197197
});
198198

@@ -631,7 +631,7 @@ class Parser {
631631
const dataStructures = new Category();
632632
dataStructures.classes.push('dataStructures');
633633

634-
_.forEach(definitions, (schema, key) => {
634+
_.forOwn(definitions, (schema, key) => {
635635
this.withPath(key, () => {
636636
try {
637637
const dataStructure = generator.generateDataStructure(schema);
@@ -718,7 +718,7 @@ class Parser {
718718
.value();
719719

720720
// Each path is an object with methods as properties
721-
_.forEach(relevantMethods, (methodValue, method) => {
721+
_.forOwn(relevantMethods, (methodValue, method) => {
722722
this.handleSwaggerMethod(resource, href, pathObjectParameters, methodValue, method);
723723
});
724724

@@ -839,7 +839,7 @@ class Parser {
839839
}
840840

841841
// Transactions are created for each response in the document
842-
_.forEach(relevantResponses, (responseValue, statusCode) => {
842+
_.forOwn(relevantResponses, (responseValue, statusCode) => {
843843
this.handleSwaggerResponse(
844844
transition, method, methodValue,
845845
transitionParams, responseValue, statusCode,

0 commit comments

Comments
 (0)