@penkov/swagger-code-gen 1.7.7 → 1.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,7 @@
13
13
  *********************************************************/
14
14
  <% if (targetNode) {%>
15
15
  import fetch, {Request, Response, BodyInit} from 'node-fetch';
16
+ import FormData from 'form-data';
16
17
  <% } %>
17
18
  <% if (scats) {%>
18
19
  import {option, Option, Collection, Try, TryLike, none} from 'scats';
@@ -51,17 +52,25 @@ function valueToString(value: any): string {
51
52
  */
52
53
  function objectToForm(o: Record<string, any>): FormData {
53
54
  const res = new FormData();
55
+
56
+ const addProp = (name: string, value: any) => {
57
+ if (value instanceof File) {
58
+ res.append(name, value);
59
+ } else {
60
+ res.append(name, valueToString(value));
61
+ }
62
+ };
63
+
64
+
54
65
  Object.keys(o)
55
66
  .filter(k => o[k] !== undefined && o[k] !== null)
56
67
  .forEach(k => {
57
68
  if (Array.isArray(o[k])) {
58
69
  o[k].forEach(e => {
59
- res.append(k, valueToString(e));
60
- })
61
- } else if (o[k] instanceof File) {
62
- res.append(k, o[k]);
70
+ addProp(k, e);
71
+ });
63
72
  } else {
64
- res.append(k, valueToString(o[k]));
73
+ addProp(k, o[k]);
65
74
  }
66
75
  });
67
76
  return res;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@penkov/swagger-code-gen",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "generate-client": "./dist/cli.mjs"