vovk 3.0.0-draft.379 → 3.0.0-draft.381
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.
|
@@ -36,12 +36,13 @@ function generateTypeScriptCode({ handlerName, rpcName, packageName, queryValida
|
|
|
36
36
|
let formSample = 'const formData = new FormData();';
|
|
37
37
|
for (const [key, prop] of Object.entries(schema.properties || {})) {
|
|
38
38
|
const target = prop.oneOf?.[0] || prop.anyOf?.[0] || prop.allOf?.[0] || prop;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
formSample += getTsFormAppend(target, key);
|
|
39
|
+
const desc = target.description ?? prop.description ?? undefined;
|
|
40
|
+
if (target.type === 'array' && target.items) {
|
|
41
|
+
formSample += getTsFormAppend(target.items, key, desc);
|
|
42
|
+
formSample += getTsFormAppend(target.items, key, desc);
|
|
42
43
|
}
|
|
43
44
|
else {
|
|
44
|
-
formSample += getTsFormAppend(target, key);
|
|
45
|
+
formSample += getTsFormAppend(target, key, desc);
|
|
45
46
|
}
|
|
46
47
|
/* if (target.type === 'string' && target.format === 'binary') {
|
|
47
48
|
sampleValue = `new Blob(${isTextFormat(target.contentMediaType) ? '["text_content"]' : '[binary_data]'}${
|
|
@@ -64,7 +65,7 @@ function generateTypeScriptCode({ handlerName, rpcName, packageName, queryValida
|
|
|
64
65
|
}
|
|
65
66
|
return formSample;
|
|
66
67
|
};
|
|
67
|
-
const getTsFormAppend = (schema, key) => {
|
|
68
|
+
const getTsFormAppend = (schema, key, description) => {
|
|
68
69
|
let sampleValue;
|
|
69
70
|
if (schema.type === 'string' && schema.format === 'binary') {
|
|
70
71
|
sampleValue = `new Blob(${isTextFormat(schema.contentMediaType) ? '["text_content"]' : '[binary_data]'}${schema.contentMediaType ? `, { type: "${schema.contentMediaType}" }` : ''})`;
|
|
@@ -75,7 +76,8 @@ function generateTypeScriptCode({ handlerName, rpcName, packageName, queryValida
|
|
|
75
76
|
else {
|
|
76
77
|
sampleValue = `"${(0, getJSONSchemaExample_1.getSampleValue)(schema)}"`;
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
+
const desc = schema.description ?? description;
|
|
80
|
+
return `\nformData.append("${key}", ${sampleValue});${desc ? ` // ${desc}` : ''}`;
|
|
79
81
|
};
|
|
80
82
|
const tsArgs = hasArg
|
|
81
83
|
? `{
|
|
@@ -36,12 +36,13 @@ function generateTypeScriptCode({ handlerName, rpcName, packageName, queryValida
|
|
|
36
36
|
let formSample = 'const formData = new FormData();';
|
|
37
37
|
for (const [key, prop] of Object.entries(schema.properties || {})) {
|
|
38
38
|
const target = prop.oneOf?.[0] || prop.anyOf?.[0] || prop.allOf?.[0] || prop;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
formSample += getTsFormAppend(target, key);
|
|
39
|
+
const desc = target.description ?? prop.description ?? undefined;
|
|
40
|
+
if (target.type === 'array' && target.items) {
|
|
41
|
+
formSample += getTsFormAppend(target.items, key, desc);
|
|
42
|
+
formSample += getTsFormAppend(target.items, key, desc);
|
|
42
43
|
}
|
|
43
44
|
else {
|
|
44
|
-
formSample += getTsFormAppend(target, key);
|
|
45
|
+
formSample += getTsFormAppend(target, key, desc);
|
|
45
46
|
}
|
|
46
47
|
/* if (target.type === 'string' && target.format === 'binary') {
|
|
47
48
|
sampleValue = `new Blob(${isTextFormat(target.contentMediaType) ? '["text_content"]' : '[binary_data]'}${
|
|
@@ -64,7 +65,7 @@ function generateTypeScriptCode({ handlerName, rpcName, packageName, queryValida
|
|
|
64
65
|
}
|
|
65
66
|
return formSample;
|
|
66
67
|
};
|
|
67
|
-
const getTsFormAppend = (schema, key) => {
|
|
68
|
+
const getTsFormAppend = (schema, key, description) => {
|
|
68
69
|
let sampleValue;
|
|
69
70
|
if (schema.type === 'string' && schema.format === 'binary') {
|
|
70
71
|
sampleValue = `new Blob(${isTextFormat(schema.contentMediaType) ? '["text_content"]' : '[binary_data]'}${schema.contentMediaType ? `, { type: "${schema.contentMediaType}" }` : ''})`;
|
|
@@ -75,7 +76,8 @@ function generateTypeScriptCode({ handlerName, rpcName, packageName, queryValida
|
|
|
75
76
|
else {
|
|
76
77
|
sampleValue = `"${(0, getJSONSchemaExample_1.getSampleValue)(schema)}"`;
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
+
const desc = schema.description ?? description;
|
|
80
|
+
return `\nformData.append("${key}", ${sampleValue});${desc ? ` // ${desc}` : ''}`;
|
|
79
81
|
};
|
|
80
82
|
const tsArgs = hasArg
|
|
81
83
|
? `{
|