vovk 3.0.0-draft.390 → 3.0.0-draft.392

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.
@@ -93,20 +93,8 @@ for await (const item of response) {
93
93
  return TS_CODE.trim();
94
94
  }
95
95
  function generatePythonCode({ handlerName, rpcName, packageName, queryValidation, bodyValidation, paramsValidation, outputValidation, iterationValidation, hasArg, }) {
96
- const getPySample = (schema, indent) => (0, getJSONSchemaExample_1.getJSONSchemaExample)(schema, { stripQuotes: false, indent: indent ?? 4, comment: '#' });
96
+ const getPySample = (schema, indent) => (0, getJSONSchemaExample_1.getJSONSchemaExample)(schema, { stripQuotes: false, indent: indent ?? 4, comment: '#', ignoreBinary: true });
97
97
  const handlerNameSnake = toSnakeCase(handlerName);
98
- const getPyData = (schema) => {
99
- const noFileSchema = {
100
- ...schema,
101
- properties: schema.properties
102
- ? Object.fromEntries(Object.entries(schema.properties).filter(([, prop]) => {
103
- const target = prop.oneOf?.[0] || prop.anyOf?.[0] || prop.allOf?.[0] || prop;
104
- return target.format !== 'binary' || target.items?.format !== 'binary';
105
- }))
106
- : {},
107
- };
108
- return getPySample(noFileSchema);
109
- };
110
98
  const getFileTouple = (schema) => {
111
99
  return `('name.ext', BytesIO(${isTextFormat(schema.contentMediaType) ? '"text_content".encode("utf-8")' : 'binary_data'}${schema.contentMediaType ? `, "${schema.contentMediaType}"` : ''}))`;
112
100
  };
@@ -126,14 +114,14 @@ function generatePythonCode({ handlerName, rpcName, packageName, queryValidation
126
114
  };
127
115
  const pyFiles = bodyValidation ? getPyFiles(bodyValidation) : null;
128
116
  const pyFilesArg = pyFiles?.length
129
- ? `${getIndentSpaces(4)}files=[\n${pyFiles.join(',\n')}${getIndentSpaces(4)}\n],`
117
+ ? `${getIndentSpaces(4)}files=[\n${pyFiles.join(',\n')}\n${getIndentSpaces(4)}],`
130
118
  : null;
131
119
  const PY_CODE = `from ${packageName} import ${rpcName}
132
120
 
133
121
  response = ${rpcName}.${handlerNameSnake}(${hasArg
134
122
  ? '\n' +
135
123
  [
136
- bodyValidation ? ` body=${getPyData(bodyValidation)},` : null,
124
+ bodyValidation ? ` body=${getPySample(bodyValidation)},` : null,
137
125
  pyFilesArg,
138
126
  queryValidation ? ` query=${getPySample(queryValidation)},` : null,
139
127
  paramsValidation ? ` params=${getPySample(paramsValidation)},` : null,
@@ -3,7 +3,8 @@ interface SamplerOptions {
3
3
  comment?: '//' | '#';
4
4
  stripQuotes?: boolean;
5
5
  indent?: number;
6
+ ignoreBinary?: boolean;
6
7
  }
7
8
  export declare function getJSONSchemaExample(schema: VovkSimpleJSONSchema, options: SamplerOptions, rootSchema?: VovkSimpleJSONSchema): string;
8
- export declare function getSampleValue(schema: VovkSimpleJSONSchema, rootSchema?: VovkSimpleJSONSchema): KnownAny;
9
+ export declare function getSampleValue(schema: VovkSimpleJSONSchema, rootSchema?: VovkSimpleJSONSchema, ignoreBinary?: boolean): KnownAny;
9
10
  export {};
@@ -3,20 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getJSONSchemaExample = getJSONSchemaExample;
4
4
  exports.getSampleValue = getSampleValue;
5
5
  function getJSONSchemaExample(schema, options, rootSchema) {
6
- const { comment = '//', stripQuotes = false, indent = 0 } = options;
6
+ const { comment = '//', stripQuotes = false, indent = 0, ignoreBinary = false } = options;
7
7
  if (!schema || typeof schema !== 'object')
8
8
  return 'null';
9
9
  // Use the input schema as the root if not provided
10
10
  rootSchema = rootSchema || schema;
11
11
  // Get the sample value
12
- const sampleValue = getSampleValue(schema, rootSchema);
12
+ const sampleValue = getSampleValue(schema, rootSchema, ignoreBinary);
13
13
  // Format the output with descriptions
14
- return formatWithDescriptions(sampleValue, schema, rootSchema, comment, stripQuotes, indent);
14
+ return formatWithDescriptions(sampleValue, schema, rootSchema, comment, stripQuotes, indent, ignoreBinary);
15
15
  }
16
- function getSampleValue(schema, rootSchema) {
16
+ function getSampleValue(schema, rootSchema, ignoreBinary) {
17
17
  if (!schema || typeof schema !== 'object')
18
18
  return null;
19
19
  rootSchema = rootSchema || schema;
20
+ // Check if this is a binary string schema and should be ignored
21
+ if (ignoreBinary && schema.type === 'string' && schema.format === 'binary') {
22
+ return undefined;
23
+ }
20
24
  // If there's an example, use it
21
25
  if (schema.example !== undefined) {
22
26
  return schema.example;
@@ -31,7 +35,7 @@ function getSampleValue(schema, rootSchema) {
31
35
  }
32
36
  // Handle $ref if present
33
37
  if (schema.$ref) {
34
- return handleRef(schema.$ref, rootSchema);
38
+ return handleRef(schema.$ref, rootSchema, ignoreBinary);
35
39
  }
36
40
  // Handle enum if present
37
41
  if (schema.enum && schema.enum.length > 0) {
@@ -39,15 +43,15 @@ function getSampleValue(schema, rootSchema) {
39
43
  }
40
44
  // Handle oneOf, anyOf, allOf
41
45
  if (schema.oneOf && schema.oneOf.length > 0) {
42
- return getSampleValue(schema.oneOf[0], rootSchema);
46
+ return getSampleValue(schema.oneOf[0], rootSchema, ignoreBinary);
43
47
  }
44
48
  if (schema.anyOf && schema.anyOf.length > 0) {
45
- return getSampleValue(schema.anyOf[0], rootSchema);
49
+ return getSampleValue(schema.anyOf[0], rootSchema, ignoreBinary);
46
50
  }
47
51
  if (schema.allOf && schema.allOf.length > 0) {
48
52
  // Merge all schemas in allOf
49
53
  const mergedSchema = schema.allOf.reduce((acc, s) => ({ ...acc, ...s }), {});
50
- return getSampleValue(mergedSchema, rootSchema);
54
+ return getSampleValue(mergedSchema, rootSchema, ignoreBinary);
51
55
  }
52
56
  // Handle different types
53
57
  if (schema.type) {
@@ -60,9 +64,9 @@ function getSampleValue(schema, rootSchema) {
60
64
  case 'boolean':
61
65
  return handleBoolean();
62
66
  case 'object':
63
- return handleObject(schema, rootSchema);
67
+ return handleObject(schema, rootSchema, ignoreBinary);
64
68
  case 'array':
65
- return handleArray(schema, rootSchema);
69
+ return handleArray(schema, rootSchema, ignoreBinary);
66
70
  case 'null':
67
71
  return null;
68
72
  default:
@@ -71,13 +75,17 @@ function getSampleValue(schema, rootSchema) {
71
75
  }
72
76
  // If type is not specified but properties are, treat it as an object
73
77
  if (schema.properties) {
74
- return handleObject(schema, rootSchema);
78
+ return handleObject(schema, rootSchema, ignoreBinary);
75
79
  }
76
80
  // Default fallback
77
81
  return null;
78
82
  }
79
- function formatWithDescriptions(value, schema, rootSchema, comment, stripQuotes, indent) {
83
+ function formatWithDescriptions(value, schema, rootSchema, comment, stripQuotes, indent, ignoreBinary) {
80
84
  const indentStr = ' '.repeat(indent);
85
+ // Handle undefined (for ignored binary fields)
86
+ if (value === undefined) {
87
+ return '';
88
+ }
81
89
  // Handle null
82
90
  if (value === null) {
83
91
  return 'null';
@@ -92,7 +100,7 @@ function formatWithDescriptions(value, schema, rootSchema, comment, stripQuotes,
92
100
  return '[]';
93
101
  const items = value.map((item) => {
94
102
  const itemSchema = schema.items || {};
95
- const formattedItem = formatWithDescriptions(item, itemSchema, rootSchema, comment, stripQuotes, indent + 4);
103
+ const formattedItem = formatWithDescriptions(item, itemSchema, rootSchema, comment, stripQuotes, indent + 4, ignoreBinary);
96
104
  return `${indentStr} ${formattedItem}`;
97
105
  });
98
106
  return `[\n${items.join(',\n')}\n${indentStr}]`;
@@ -130,7 +138,7 @@ function formatWithDescriptions(value, schema, rootSchema, comment, stripQuotes,
130
138
  // Format the key
131
139
  const formattedKey = stripQuotes && /^[A-Za-z_$][0-9A-Za-z_$]*$/.test(key) ? key : JSON.stringify(key);
132
140
  // Format the value
133
- const formattedValue = formatWithDescriptions(val, resolvedPropSchema, rootSchema, comment, stripQuotes, indent + 4);
141
+ const formattedValue = formatWithDescriptions(val, resolvedPropSchema, rootSchema, comment, stripQuotes, indent + 4, ignoreBinary);
134
142
  formattedEntries.push(`${indentStr} ${formattedKey}: ${formattedValue}${index < entries.length - 1 ? ',' : ''}`);
135
143
  });
136
144
  return `{\n${formattedEntries.join('\n')}\n${indentStr}}`;
@@ -148,9 +156,9 @@ function resolveRef(ref, rootSchema) {
148
156
  }
149
157
  return current;
150
158
  }
151
- function handleRef(ref, rootSchema) {
159
+ function handleRef(ref, rootSchema, ignoreBinary) {
152
160
  const resolved = resolveRef(ref, rootSchema);
153
- return getSampleValue(resolved, rootSchema);
161
+ return getSampleValue(resolved, rootSchema, ignoreBinary);
154
162
  }
155
163
  function handleString(schema) {
156
164
  if (schema.format) {
@@ -186,6 +194,8 @@ function handleString(schema) {
186
194
  return '+123-456-7890';
187
195
  case 'password':
188
196
  return '******';
197
+ case 'binary':
198
+ return 'binary-data';
189
199
  default:
190
200
  return 'string';
191
201
  }
@@ -210,27 +220,43 @@ function handleNumber(schema) {
210
220
  function handleBoolean() {
211
221
  return true;
212
222
  }
213
- function handleObject(schema, rootSchema) {
223
+ function handleObject(schema, rootSchema, ignoreBinary) {
214
224
  const result = {};
215
225
  if (schema.properties) {
216
226
  const required = schema.required || [];
217
227
  for (const [key, propSchema] of Object.entries(schema.properties)) {
218
228
  if (required.includes(key) || required.length === 0) {
219
- result[key] = getSampleValue(propSchema, rootSchema);
229
+ const value = getSampleValue(propSchema, rootSchema, ignoreBinary);
230
+ // Only add the property if it's not undefined (which happens when ignoreBinary is true and it's a binary field)
231
+ if (value !== undefined) {
232
+ result[key] = value;
233
+ }
220
234
  }
221
235
  }
222
236
  }
223
237
  if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {
224
- result['additionalProp'] = getSampleValue(schema.additionalProperties, rootSchema);
238
+ const value = getSampleValue(schema.additionalProperties, rootSchema, ignoreBinary);
239
+ if (value !== undefined) {
240
+ result['additionalProp'] = value;
241
+ }
225
242
  }
226
243
  return result;
227
244
  }
228
- function handleArray(schema, rootSchema) {
245
+ function handleArray(schema, rootSchema, ignoreBinary) {
229
246
  if (schema.items) {
230
247
  const itemSchema = schema.items;
248
+ // Check if the items are binary strings that should be ignored
249
+ if (ignoreBinary && itemSchema.type === 'string' && itemSchema.format === 'binary') {
250
+ return undefined;
251
+ }
231
252
  const minItems = schema.minItems || 1;
232
253
  const numItems = Math.min(minItems, 3);
233
- return Array.from({ length: numItems }, () => getSampleValue(itemSchema, rootSchema));
254
+ const items = Array.from({ length: numItems }, () => getSampleValue(itemSchema, rootSchema, ignoreBinary)).filter((item) => item !== undefined); // Filter out undefined values from ignored binary items
255
+ // If all items were filtered out (e.g., all were binary), return undefined instead of empty array
256
+ if (items.length === 0 && numItems > 0) {
257
+ return undefined;
258
+ }
259
+ return items;
234
260
  }
235
261
  return [];
236
262
  }
@@ -93,20 +93,8 @@ for await (const item of response) {
93
93
  return TS_CODE.trim();
94
94
  }
95
95
  function generatePythonCode({ handlerName, rpcName, packageName, queryValidation, bodyValidation, paramsValidation, outputValidation, iterationValidation, hasArg, }) {
96
- const getPySample = (schema, indent) => (0, getJSONSchemaExample_1.getJSONSchemaExample)(schema, { stripQuotes: false, indent: indent ?? 4, comment: '#' });
96
+ const getPySample = (schema, indent) => (0, getJSONSchemaExample_1.getJSONSchemaExample)(schema, { stripQuotes: false, indent: indent ?? 4, comment: '#', ignoreBinary: true });
97
97
  const handlerNameSnake = toSnakeCase(handlerName);
98
- const getPyData = (schema) => {
99
- const noFileSchema = {
100
- ...schema,
101
- properties: schema.properties
102
- ? Object.fromEntries(Object.entries(schema.properties).filter(([, prop]) => {
103
- const target = prop.oneOf?.[0] || prop.anyOf?.[0] || prop.allOf?.[0] || prop;
104
- return target.format !== 'binary' || target.items?.format !== 'binary';
105
- }))
106
- : {},
107
- };
108
- return getPySample(noFileSchema);
109
- };
110
98
  const getFileTouple = (schema) => {
111
99
  return `('name.ext', BytesIO(${isTextFormat(schema.contentMediaType) ? '"text_content".encode("utf-8")' : 'binary_data'}${schema.contentMediaType ? `, "${schema.contentMediaType}"` : ''}))`;
112
100
  };
@@ -126,14 +114,14 @@ function generatePythonCode({ handlerName, rpcName, packageName, queryValidation
126
114
  };
127
115
  const pyFiles = bodyValidation ? getPyFiles(bodyValidation) : null;
128
116
  const pyFilesArg = pyFiles?.length
129
- ? `${getIndentSpaces(4)}files=[\n${pyFiles.join(',\n')}${getIndentSpaces(4)}\n],`
117
+ ? `${getIndentSpaces(4)}files=[\n${pyFiles.join(',\n')}\n${getIndentSpaces(4)}],`
130
118
  : null;
131
119
  const PY_CODE = `from ${packageName} import ${rpcName}
132
120
 
133
121
  response = ${rpcName}.${handlerNameSnake}(${hasArg
134
122
  ? '\n' +
135
123
  [
136
- bodyValidation ? ` body=${getPyData(bodyValidation)},` : null,
124
+ bodyValidation ? ` body=${getPySample(bodyValidation)},` : null,
137
125
  pyFilesArg,
138
126
  queryValidation ? ` query=${getPySample(queryValidation)},` : null,
139
127
  paramsValidation ? ` params=${getPySample(paramsValidation)},` : null,
@@ -3,7 +3,8 @@ interface SamplerOptions {
3
3
  comment?: '//' | '#';
4
4
  stripQuotes?: boolean;
5
5
  indent?: number;
6
+ ignoreBinary?: boolean;
6
7
  }
7
8
  export declare function getJSONSchemaExample(schema: VovkSimpleJSONSchema, options: SamplerOptions, rootSchema?: VovkSimpleJSONSchema): string;
8
- export declare function getSampleValue(schema: VovkSimpleJSONSchema, rootSchema?: VovkSimpleJSONSchema): KnownAny;
9
+ export declare function getSampleValue(schema: VovkSimpleJSONSchema, rootSchema?: VovkSimpleJSONSchema, ignoreBinary?: boolean): KnownAny;
9
10
  export {};
@@ -3,20 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getJSONSchemaExample = getJSONSchemaExample;
4
4
  exports.getSampleValue = getSampleValue;
5
5
  function getJSONSchemaExample(schema, options, rootSchema) {
6
- const { comment = '//', stripQuotes = false, indent = 0 } = options;
6
+ const { comment = '//', stripQuotes = false, indent = 0, ignoreBinary = false } = options;
7
7
  if (!schema || typeof schema !== 'object')
8
8
  return 'null';
9
9
  // Use the input schema as the root if not provided
10
10
  rootSchema = rootSchema || schema;
11
11
  // Get the sample value
12
- const sampleValue = getSampleValue(schema, rootSchema);
12
+ const sampleValue = getSampleValue(schema, rootSchema, ignoreBinary);
13
13
  // Format the output with descriptions
14
- return formatWithDescriptions(sampleValue, schema, rootSchema, comment, stripQuotes, indent);
14
+ return formatWithDescriptions(sampleValue, schema, rootSchema, comment, stripQuotes, indent, ignoreBinary);
15
15
  }
16
- function getSampleValue(schema, rootSchema) {
16
+ function getSampleValue(schema, rootSchema, ignoreBinary) {
17
17
  if (!schema || typeof schema !== 'object')
18
18
  return null;
19
19
  rootSchema = rootSchema || schema;
20
+ // Check if this is a binary string schema and should be ignored
21
+ if (ignoreBinary && schema.type === 'string' && schema.format === 'binary') {
22
+ return undefined;
23
+ }
20
24
  // If there's an example, use it
21
25
  if (schema.example !== undefined) {
22
26
  return schema.example;
@@ -31,7 +35,7 @@ function getSampleValue(schema, rootSchema) {
31
35
  }
32
36
  // Handle $ref if present
33
37
  if (schema.$ref) {
34
- return handleRef(schema.$ref, rootSchema);
38
+ return handleRef(schema.$ref, rootSchema, ignoreBinary);
35
39
  }
36
40
  // Handle enum if present
37
41
  if (schema.enum && schema.enum.length > 0) {
@@ -39,15 +43,15 @@ function getSampleValue(schema, rootSchema) {
39
43
  }
40
44
  // Handle oneOf, anyOf, allOf
41
45
  if (schema.oneOf && schema.oneOf.length > 0) {
42
- return getSampleValue(schema.oneOf[0], rootSchema);
46
+ return getSampleValue(schema.oneOf[0], rootSchema, ignoreBinary);
43
47
  }
44
48
  if (schema.anyOf && schema.anyOf.length > 0) {
45
- return getSampleValue(schema.anyOf[0], rootSchema);
49
+ return getSampleValue(schema.anyOf[0], rootSchema, ignoreBinary);
46
50
  }
47
51
  if (schema.allOf && schema.allOf.length > 0) {
48
52
  // Merge all schemas in allOf
49
53
  const mergedSchema = schema.allOf.reduce((acc, s) => ({ ...acc, ...s }), {});
50
- return getSampleValue(mergedSchema, rootSchema);
54
+ return getSampleValue(mergedSchema, rootSchema, ignoreBinary);
51
55
  }
52
56
  // Handle different types
53
57
  if (schema.type) {
@@ -60,9 +64,9 @@ function getSampleValue(schema, rootSchema) {
60
64
  case 'boolean':
61
65
  return handleBoolean();
62
66
  case 'object':
63
- return handleObject(schema, rootSchema);
67
+ return handleObject(schema, rootSchema, ignoreBinary);
64
68
  case 'array':
65
- return handleArray(schema, rootSchema);
69
+ return handleArray(schema, rootSchema, ignoreBinary);
66
70
  case 'null':
67
71
  return null;
68
72
  default:
@@ -71,13 +75,17 @@ function getSampleValue(schema, rootSchema) {
71
75
  }
72
76
  // If type is not specified but properties are, treat it as an object
73
77
  if (schema.properties) {
74
- return handleObject(schema, rootSchema);
78
+ return handleObject(schema, rootSchema, ignoreBinary);
75
79
  }
76
80
  // Default fallback
77
81
  return null;
78
82
  }
79
- function formatWithDescriptions(value, schema, rootSchema, comment, stripQuotes, indent) {
83
+ function formatWithDescriptions(value, schema, rootSchema, comment, stripQuotes, indent, ignoreBinary) {
80
84
  const indentStr = ' '.repeat(indent);
85
+ // Handle undefined (for ignored binary fields)
86
+ if (value === undefined) {
87
+ return '';
88
+ }
81
89
  // Handle null
82
90
  if (value === null) {
83
91
  return 'null';
@@ -92,7 +100,7 @@ function formatWithDescriptions(value, schema, rootSchema, comment, stripQuotes,
92
100
  return '[]';
93
101
  const items = value.map((item) => {
94
102
  const itemSchema = schema.items || {};
95
- const formattedItem = formatWithDescriptions(item, itemSchema, rootSchema, comment, stripQuotes, indent + 4);
103
+ const formattedItem = formatWithDescriptions(item, itemSchema, rootSchema, comment, stripQuotes, indent + 4, ignoreBinary);
96
104
  return `${indentStr} ${formattedItem}`;
97
105
  });
98
106
  return `[\n${items.join(',\n')}\n${indentStr}]`;
@@ -130,7 +138,7 @@ function formatWithDescriptions(value, schema, rootSchema, comment, stripQuotes,
130
138
  // Format the key
131
139
  const formattedKey = stripQuotes && /^[A-Za-z_$][0-9A-Za-z_$]*$/.test(key) ? key : JSON.stringify(key);
132
140
  // Format the value
133
- const formattedValue = formatWithDescriptions(val, resolvedPropSchema, rootSchema, comment, stripQuotes, indent + 4);
141
+ const formattedValue = formatWithDescriptions(val, resolvedPropSchema, rootSchema, comment, stripQuotes, indent + 4, ignoreBinary);
134
142
  formattedEntries.push(`${indentStr} ${formattedKey}: ${formattedValue}${index < entries.length - 1 ? ',' : ''}`);
135
143
  });
136
144
  return `{\n${formattedEntries.join('\n')}\n${indentStr}}`;
@@ -148,9 +156,9 @@ function resolveRef(ref, rootSchema) {
148
156
  }
149
157
  return current;
150
158
  }
151
- function handleRef(ref, rootSchema) {
159
+ function handleRef(ref, rootSchema, ignoreBinary) {
152
160
  const resolved = resolveRef(ref, rootSchema);
153
- return getSampleValue(resolved, rootSchema);
161
+ return getSampleValue(resolved, rootSchema, ignoreBinary);
154
162
  }
155
163
  function handleString(schema) {
156
164
  if (schema.format) {
@@ -186,6 +194,8 @@ function handleString(schema) {
186
194
  return '+123-456-7890';
187
195
  case 'password':
188
196
  return '******';
197
+ case 'binary':
198
+ return 'binary-data';
189
199
  default:
190
200
  return 'string';
191
201
  }
@@ -210,27 +220,43 @@ function handleNumber(schema) {
210
220
  function handleBoolean() {
211
221
  return true;
212
222
  }
213
- function handleObject(schema, rootSchema) {
223
+ function handleObject(schema, rootSchema, ignoreBinary) {
214
224
  const result = {};
215
225
  if (schema.properties) {
216
226
  const required = schema.required || [];
217
227
  for (const [key, propSchema] of Object.entries(schema.properties)) {
218
228
  if (required.includes(key) || required.length === 0) {
219
- result[key] = getSampleValue(propSchema, rootSchema);
229
+ const value = getSampleValue(propSchema, rootSchema, ignoreBinary);
230
+ // Only add the property if it's not undefined (which happens when ignoreBinary is true and it's a binary field)
231
+ if (value !== undefined) {
232
+ result[key] = value;
233
+ }
220
234
  }
221
235
  }
222
236
  }
223
237
  if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {
224
- result['additionalProp'] = getSampleValue(schema.additionalProperties, rootSchema);
238
+ const value = getSampleValue(schema.additionalProperties, rootSchema, ignoreBinary);
239
+ if (value !== undefined) {
240
+ result['additionalProp'] = value;
241
+ }
225
242
  }
226
243
  return result;
227
244
  }
228
- function handleArray(schema, rootSchema) {
245
+ function handleArray(schema, rootSchema, ignoreBinary) {
229
246
  if (schema.items) {
230
247
  const itemSchema = schema.items;
248
+ // Check if the items are binary strings that should be ignored
249
+ if (ignoreBinary && itemSchema.type === 'string' && itemSchema.format === 'binary') {
250
+ return undefined;
251
+ }
231
252
  const minItems = schema.minItems || 1;
232
253
  const numItems = Math.min(minItems, 3);
233
- return Array.from({ length: numItems }, () => getSampleValue(itemSchema, rootSchema));
254
+ const items = Array.from({ length: numItems }, () => getSampleValue(itemSchema, rootSchema, ignoreBinary)).filter((item) => item !== undefined); // Filter out undefined values from ignored binary items
255
+ // If all items were filtered out (e.g., all were binary), return undefined instead of empty array
256
+ if (items.length === 0 && numItems > 0) {
257
+ return undefined;
258
+ }
259
+ return items;
234
260
  }
235
261
  return [];
236
262
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "3.0.0-draft.390",
3
+ "version": "3.0.0-draft.392",
4
4
  "main": "./cjs/index.js",
5
5
  "module": "./mjs/index.js",
6
6
  "types": "./mjs/index.d.ts",