vovk 3.0.0-draft.367 → 3.0.0-draft.369
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.
|
@@ -61,9 +61,9 @@ function generateTypeScriptCode({ handlerName, rpcName, packageName, queryValida
|
|
|
61
61
|
};
|
|
62
62
|
const getBody = (schema) => {
|
|
63
63
|
if (schema['x-isForm']) {
|
|
64
|
-
return
|
|
64
|
+
return 'form';
|
|
65
65
|
}
|
|
66
|
-
return
|
|
66
|
+
return getTsFormSample(schema);
|
|
67
67
|
};
|
|
68
68
|
const tsArgs = hasArg
|
|
69
69
|
? `{
|
|
@@ -111,21 +111,21 @@ function generatePythonCode({ handlerName, rpcName, packageName, queryValidation
|
|
|
111
111
|
const getFileTouple = (schema) => {
|
|
112
112
|
return `('name.ext', BytesIO(${isTextFormat(schema.contentMediaType) ? '"text_content".encode("utf-8")' : 'binary_data'}${schema.contentMediaType ? `"${schema.contentMediaType}"` : ''}))`;
|
|
113
113
|
};
|
|
114
|
-
const getPyFiles = (schema
|
|
114
|
+
const getPyFiles = (schema) => {
|
|
115
115
|
return Object.entries(schema.properties ?? {}).reduce((acc, [key, prop]) => {
|
|
116
116
|
const target = prop.oneOf?.[0] || prop.anyOf?.[0] || prop.allOf?.[0] || prop;
|
|
117
117
|
if (target.format === 'binary') {
|
|
118
118
|
acc.push(`('${key}', ${getFileTouple(target)})`);
|
|
119
119
|
}
|
|
120
120
|
else if (target.type === 'array' && target.items?.format === 'binary') {
|
|
121
|
-
const val = `${getIndentSpaces(
|
|
121
|
+
const val = `${getIndentSpaces(8)}('${key}', ${getFileTouple(target.items)})`;
|
|
122
122
|
acc.push(val, val);
|
|
123
123
|
}
|
|
124
124
|
return acc;
|
|
125
125
|
}, []);
|
|
126
126
|
};
|
|
127
127
|
const pyFiles = bodyValidation ? getPyFiles(bodyValidation) : null;
|
|
128
|
-
const pyFilesArg = pyFiles ?
|
|
128
|
+
const pyFilesArg = pyFiles?.length ? `${getIndentSpaces(4)}files=[\n${pyFiles.join(', ')}\n]` : null;
|
|
129
129
|
const PY_CODE = `from ${packageName} import ${rpcName}
|
|
130
130
|
|
|
131
131
|
response = ${rpcName}.${handlerNameSnake}(${hasArg
|
|
@@ -180,7 +180,7 @@ function generateRustCode({ handlerName, rpcName, packageName, queryValidation,
|
|
|
180
180
|
else {
|
|
181
181
|
sampleValue = `"${(0, getJSONSchemaExample_1.getSampleValue)(target)}"`;
|
|
182
182
|
}
|
|
183
|
-
formSample += `\n${getIndentSpaces(
|
|
183
|
+
formSample += `\n${getIndentSpaces(4)}.part("${key}", ${sampleValue});`;
|
|
184
184
|
}
|
|
185
185
|
return formSample;
|
|
186
186
|
};
|
|
@@ -61,9 +61,9 @@ function generateTypeScriptCode({ handlerName, rpcName, packageName, queryValida
|
|
|
61
61
|
};
|
|
62
62
|
const getBody = (schema) => {
|
|
63
63
|
if (schema['x-isForm']) {
|
|
64
|
-
return
|
|
64
|
+
return 'form';
|
|
65
65
|
}
|
|
66
|
-
return
|
|
66
|
+
return getTsFormSample(schema);
|
|
67
67
|
};
|
|
68
68
|
const tsArgs = hasArg
|
|
69
69
|
? `{
|
|
@@ -111,21 +111,21 @@ function generatePythonCode({ handlerName, rpcName, packageName, queryValidation
|
|
|
111
111
|
const getFileTouple = (schema) => {
|
|
112
112
|
return `('name.ext', BytesIO(${isTextFormat(schema.contentMediaType) ? '"text_content".encode("utf-8")' : 'binary_data'}${schema.contentMediaType ? `"${schema.contentMediaType}"` : ''}))`;
|
|
113
113
|
};
|
|
114
|
-
const getPyFiles = (schema
|
|
114
|
+
const getPyFiles = (schema) => {
|
|
115
115
|
return Object.entries(schema.properties ?? {}).reduce((acc, [key, prop]) => {
|
|
116
116
|
const target = prop.oneOf?.[0] || prop.anyOf?.[0] || prop.allOf?.[0] || prop;
|
|
117
117
|
if (target.format === 'binary') {
|
|
118
118
|
acc.push(`('${key}', ${getFileTouple(target)})`);
|
|
119
119
|
}
|
|
120
120
|
else if (target.type === 'array' && target.items?.format === 'binary') {
|
|
121
|
-
const val = `${getIndentSpaces(
|
|
121
|
+
const val = `${getIndentSpaces(8)}('${key}', ${getFileTouple(target.items)})`;
|
|
122
122
|
acc.push(val, val);
|
|
123
123
|
}
|
|
124
124
|
return acc;
|
|
125
125
|
}, []);
|
|
126
126
|
};
|
|
127
127
|
const pyFiles = bodyValidation ? getPyFiles(bodyValidation) : null;
|
|
128
|
-
const pyFilesArg = pyFiles ?
|
|
128
|
+
const pyFilesArg = pyFiles?.length ? `${getIndentSpaces(4)}files=[\n${pyFiles.join(', ')}\n]` : null;
|
|
129
129
|
const PY_CODE = `from ${packageName} import ${rpcName}
|
|
130
130
|
|
|
131
131
|
response = ${rpcName}.${handlerNameSnake}(${hasArg
|
|
@@ -180,7 +180,7 @@ function generateRustCode({ handlerName, rpcName, packageName, queryValidation,
|
|
|
180
180
|
else {
|
|
181
181
|
sampleValue = `"${(0, getJSONSchemaExample_1.getSampleValue)(target)}"`;
|
|
182
182
|
}
|
|
183
|
-
formSample += `\n${getIndentSpaces(
|
|
183
|
+
formSample += `\n${getIndentSpaces(4)}.part("${key}", ${sampleValue});`;
|
|
184
184
|
}
|
|
185
185
|
return formSample;
|
|
186
186
|
};
|