@trayio/tray-openapi 4.13.0 → 4.15.0

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.
@@ -27,9 +27,24 @@ exports.generateHandlerTest = void 0;
27
27
  const E = __importStar(require("fp-ts/Either"));
28
28
  const O = __importStar(require("fp-ts/Option"));
29
29
  const function_1 = require("fp-ts/function");
30
- const getDefaultValue = (prop) => (0, function_1.pipe)(prop.default, O.fold(() => O.fold(() => `'test_value'`, (type) => {
30
+ const getDefaultValue = (prop) => (0, function_1.pipe)(prop.default, O.fold(() => O.fold(() => {
31
+ if (O.isSome(prop.oneOf)) {
32
+ const oneOfProp = O.getOrElse(() => [])(prop.oneOf);
33
+ if (oneOfProp.length > 0) {
34
+ return getDefaultValue(oneOfProp[0]);
35
+ }
36
+ }
37
+ return `'test_value'`;
38
+ }, (type) => {
31
39
  switch (type) {
32
40
  case 'string':
41
+ const isEnum = O.isSome(prop.enum);
42
+ if (isEnum) {
43
+ const enumValues = O.getOrElse(() => ['test'])(prop.enum);
44
+ if (enumValues.length > 0) {
45
+ return `'${enumValues[0]}'`;
46
+ }
47
+ }
33
48
  return `'test'`;
34
49
  case 'number':
35
50
  case 'integer':
@@ -51,7 +66,7 @@ const getDefaultValue = (prop) => (0, function_1.pipe)(prop.default, O.fold(() =
51
66
  if (defaultEntry.length === 0) {
52
67
  return getDefaultValue({ ...prop, default: O.none });
53
68
  }
54
- return defaultEntry[0];
69
+ return `'${defaultEntry[0]}'`;
55
70
  }
56
71
  switch (typeof defaultEntry) {
57
72
  case 'string':