vovk 3.0.0-draft.393 → 3.0.0-draft.395
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,10 +93,16 @@ 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, {
|
|
96
|
+
const getPySample = (schema, indent) => (0, getJSONSchemaExample_1.getJSONSchemaExample)(schema, {
|
|
97
|
+
stripQuotes: false,
|
|
98
|
+
indent: indent ?? 4,
|
|
99
|
+
comment: '#',
|
|
100
|
+
ignoreBinary: true,
|
|
101
|
+
nestingIndent: 4,
|
|
102
|
+
});
|
|
97
103
|
const handlerNameSnake = toSnakeCase(handlerName);
|
|
98
104
|
const getFileTouple = (schema) => {
|
|
99
|
-
return `('name.ext', BytesIO(${isTextFormat(schema.contentMediaType) ? '"text_content".encode("utf-8")' : 'binary_data'}${schema.contentMediaType ? `, "${schema.contentMediaType}"` : ''})
|
|
105
|
+
return `('name.ext', BytesIO(${isTextFormat(schema.contentMediaType) ? '"text_content".encode("utf-8")' : 'binary_data'})${schema.contentMediaType ? `, "${schema.contentMediaType}"` : ''})`;
|
|
100
106
|
};
|
|
101
107
|
const getPyFiles = (schema) => {
|
|
102
108
|
return Object.entries(schema.properties ?? {}).reduce((acc, [key, prop]) => {
|
|
@@ -117,7 +123,7 @@ function generatePythonCode({ handlerName, rpcName, packageName, queryValidation
|
|
|
117
123
|
? `${getIndentSpaces(4)}files=[\n${pyFiles.join(',\n')}\n${getIndentSpaces(4)}],`
|
|
118
124
|
: null;
|
|
119
125
|
const PY_CODE = `from ${packageName} import ${rpcName}
|
|
120
|
-
|
|
126
|
+
${bodyValidation?.['x-isForm'] ? 'from io import BytesIO\n' : ''}
|
|
121
127
|
response = ${rpcName}.${handlerNameSnake}(${hasArg
|
|
122
128
|
? '\n' +
|
|
123
129
|
[
|
|
@@ -3,8 +3,7 @@ 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, nestingIndent = 4,
|
|
7
|
-
ignoreBinary = false, } = options;
|
|
6
|
+
const { comment = '//', stripQuotes = false, indent = 0, nestingIndent = 4, ignoreBinary = false } = options;
|
|
8
7
|
if (!schema || typeof schema !== 'object')
|
|
9
8
|
return 'null';
|
|
10
9
|
// Use the input schema as the root if not provided
|
|
@@ -142,8 +141,7 @@ ignoreBinary) {
|
|
|
142
141
|
// Format the key
|
|
143
142
|
const formattedKey = stripQuotes && /^[A-Za-z_$][0-9A-Za-z_$]*$/.test(key) ? key : JSON.stringify(key);
|
|
144
143
|
// Format the value
|
|
145
|
-
const formattedValue = formatWithDescriptions(val, resolvedPropSchema, rootSchema, comment, stripQuotes, indent + nestingIndent,
|
|
146
|
-
nestingIndent, ignoreBinary);
|
|
144
|
+
const formattedValue = formatWithDescriptions(val, resolvedPropSchema, rootSchema, comment, stripQuotes, indent + nestingIndent, nestingIndent, ignoreBinary);
|
|
147
145
|
formattedEntries.push(`${indentStr}${nestIndentStr}${formattedKey}: ${formattedValue}${index < entries.length - 1 ? ',' : ''}`);
|
|
148
146
|
});
|
|
149
147
|
return `{\n${formattedEntries.join('\n')}\n${indentStr}}`;
|
|
@@ -93,10 +93,16 @@ 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, {
|
|
96
|
+
const getPySample = (schema, indent) => (0, getJSONSchemaExample_1.getJSONSchemaExample)(schema, {
|
|
97
|
+
stripQuotes: false,
|
|
98
|
+
indent: indent ?? 4,
|
|
99
|
+
comment: '#',
|
|
100
|
+
ignoreBinary: true,
|
|
101
|
+
nestingIndent: 4,
|
|
102
|
+
});
|
|
97
103
|
const handlerNameSnake = toSnakeCase(handlerName);
|
|
98
104
|
const getFileTouple = (schema) => {
|
|
99
|
-
return `('name.ext', BytesIO(${isTextFormat(schema.contentMediaType) ? '"text_content".encode("utf-8")' : 'binary_data'}${schema.contentMediaType ? `, "${schema.contentMediaType}"` : ''})
|
|
105
|
+
return `('name.ext', BytesIO(${isTextFormat(schema.contentMediaType) ? '"text_content".encode("utf-8")' : 'binary_data'})${schema.contentMediaType ? `, "${schema.contentMediaType}"` : ''})`;
|
|
100
106
|
};
|
|
101
107
|
const getPyFiles = (schema) => {
|
|
102
108
|
return Object.entries(schema.properties ?? {}).reduce((acc, [key, prop]) => {
|
|
@@ -117,7 +123,7 @@ function generatePythonCode({ handlerName, rpcName, packageName, queryValidation
|
|
|
117
123
|
? `${getIndentSpaces(4)}files=[\n${pyFiles.join(',\n')}\n${getIndentSpaces(4)}],`
|
|
118
124
|
: null;
|
|
119
125
|
const PY_CODE = `from ${packageName} import ${rpcName}
|
|
120
|
-
|
|
126
|
+
${bodyValidation?.['x-isForm'] ? 'from io import BytesIO\n' : ''}
|
|
121
127
|
response = ${rpcName}.${handlerNameSnake}(${hasArg
|
|
122
128
|
? '\n' +
|
|
123
129
|
[
|
|
@@ -3,8 +3,7 @@ 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, nestingIndent = 4,
|
|
7
|
-
ignoreBinary = false, } = options;
|
|
6
|
+
const { comment = '//', stripQuotes = false, indent = 0, nestingIndent = 4, ignoreBinary = false } = options;
|
|
8
7
|
if (!schema || typeof schema !== 'object')
|
|
9
8
|
return 'null';
|
|
10
9
|
// Use the input schema as the root if not provided
|
|
@@ -142,8 +141,7 @@ ignoreBinary) {
|
|
|
142
141
|
// Format the key
|
|
143
142
|
const formattedKey = stripQuotes && /^[A-Za-z_$][0-9A-Za-z_$]*$/.test(key) ? key : JSON.stringify(key);
|
|
144
143
|
// Format the value
|
|
145
|
-
const formattedValue = formatWithDescriptions(val, resolvedPropSchema, rootSchema, comment, stripQuotes, indent + nestingIndent,
|
|
146
|
-
nestingIndent, ignoreBinary);
|
|
144
|
+
const formattedValue = formatWithDescriptions(val, resolvedPropSchema, rootSchema, comment, stripQuotes, indent + nestingIndent, nestingIndent, ignoreBinary);
|
|
147
145
|
formattedEntries.push(`${indentStr}${nestIndentStr}${formattedKey}: ${formattedValue}${index < entries.length - 1 ? ',' : ''}`);
|
|
148
146
|
});
|
|
149
147
|
return `{\n${formattedEntries.join('\n')}\n${indentStr}}`;
|