vovk 3.0.0-draft.386 → 3.0.0-draft.387

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.
@@ -99,7 +99,10 @@ function generatePythonCode({ handlerName, rpcName, packageName, queryValidation
99
99
  const noFileSchema = {
100
100
  ...schema,
101
101
  properties: schema.properties
102
- ? Object.fromEntries(Object.entries(schema.properties).filter(([, prop]) => prop.format !== 'binary' || prop.items?.format !== 'binary'))
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
+ }))
103
106
  : {},
104
107
  };
105
108
  return getPySample(noFileSchema);
@@ -110,8 +113,8 @@ function generatePythonCode({ handlerName, rpcName, packageName, queryValidation
110
113
  const getPyFiles = (schema) => {
111
114
  return Object.entries(schema.properties ?? {}).reduce((acc, [key, prop]) => {
112
115
  const target = prop.oneOf?.[0] || prop.anyOf?.[0] || prop.allOf?.[0] || prop;
113
- if (target.format === 'binary') {
114
- acc.push(`('${key}', ${getFileTouple(target)})`);
116
+ if (target.type === 'string' && target.format === 'binary') {
117
+ acc.push(`${getIndentSpaces(8)}('${key}', ${getFileTouple(target)})`);
115
118
  }
116
119
  else if (target.type === 'array' && target.items?.format === 'binary') {
117
120
  const val = `${getIndentSpaces(8)}('${key}', ${getFileTouple(target.items)})`;
@@ -121,7 +124,9 @@ function generatePythonCode({ handlerName, rpcName, packageName, queryValidation
121
124
  }, []);
122
125
  };
123
126
  const pyFiles = bodyValidation ? getPyFiles(bodyValidation) : null;
124
- const pyFilesArg = pyFiles?.length ? `${getIndentSpaces(4)}files=[\n${pyFiles.join(',\n')}\n]` : null;
127
+ const pyFilesArg = pyFiles?.length
128
+ ? `${getIndentSpaces(4)}files=[\n${pyFiles.join(',\n')}${getIndentSpaces(4)}\n]`
129
+ : null;
125
130
  const PY_CODE = `from ${packageName} import ${rpcName}
126
131
 
127
132
  response = ${rpcName}.${handlerNameSnake}(${hasArg
@@ -99,7 +99,10 @@ function generatePythonCode({ handlerName, rpcName, packageName, queryValidation
99
99
  const noFileSchema = {
100
100
  ...schema,
101
101
  properties: schema.properties
102
- ? Object.fromEntries(Object.entries(schema.properties).filter(([, prop]) => prop.format !== 'binary' || prop.items?.format !== 'binary'))
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
+ }))
103
106
  : {},
104
107
  };
105
108
  return getPySample(noFileSchema);
@@ -110,8 +113,8 @@ function generatePythonCode({ handlerName, rpcName, packageName, queryValidation
110
113
  const getPyFiles = (schema) => {
111
114
  return Object.entries(schema.properties ?? {}).reduce((acc, [key, prop]) => {
112
115
  const target = prop.oneOf?.[0] || prop.anyOf?.[0] || prop.allOf?.[0] || prop;
113
- if (target.format === 'binary') {
114
- acc.push(`('${key}', ${getFileTouple(target)})`);
116
+ if (target.type === 'string' && target.format === 'binary') {
117
+ acc.push(`${getIndentSpaces(8)}('${key}', ${getFileTouple(target)})`);
115
118
  }
116
119
  else if (target.type === 'array' && target.items?.format === 'binary') {
117
120
  const val = `${getIndentSpaces(8)}('${key}', ${getFileTouple(target.items)})`;
@@ -121,7 +124,9 @@ function generatePythonCode({ handlerName, rpcName, packageName, queryValidation
121
124
  }, []);
122
125
  };
123
126
  const pyFiles = bodyValidation ? getPyFiles(bodyValidation) : null;
124
- const pyFilesArg = pyFiles?.length ? `${getIndentSpaces(4)}files=[\n${pyFiles.join(',\n')}\n]` : null;
127
+ const pyFilesArg = pyFiles?.length
128
+ ? `${getIndentSpaces(4)}files=[\n${pyFiles.join(',\n')}${getIndentSpaces(4)}\n]`
129
+ : null;
125
130
  const PY_CODE = `from ${packageName} import ${rpcName}
126
131
 
127
132
  response = ${rpcName}.${handlerNameSnake}(${hasArg
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "3.0.0-draft.386",
3
+ "version": "3.0.0-draft.387",
4
4
  "main": "./cjs/index.js",
5
5
  "module": "./mjs/index.js",
6
6
  "types": "./mjs/index.d.ts",