vovk-rust 0.0.1 → 0.0.2
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.
- package/README.md +2 -0
- package/client-templates/rsSrc/lib.rs.ejs +4 -3
- package/index.js +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
<br>
|
|
10
10
|
<strong>Back-end Framework for Next.js App Router</strong>
|
|
11
11
|
<br />
|
|
12
|
+
<em>One codebase → type-safe clients, OpenAPI, and AI tools</em>
|
|
13
|
+
<br />
|
|
12
14
|
<a href="https://vovk.dev/">Documentation</a>
|
|
13
15
|
|
|
14
16
|
<a href="https://vovk.dev/quick-install">Quick Start</a>
|
|
@@ -30,9 +30,10 @@ vars.convertJSONSchemasToRustTypes({
|
|
|
30
30
|
body: validation?.body,
|
|
31
31
|
query: validation?.query,
|
|
32
32
|
params: validation?.params,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
// Re-attach deduped $defs so Rust resolves refs as before (no-op for non-mixin).
|
|
34
|
+
output: t.reattachMixinDefs(validation?.output, segment),
|
|
35
|
+
iteration: t.reattachMixinDefs(validation?.iteration, segment)
|
|
36
|
+
},
|
|
36
37
|
rootName: handlerName,
|
|
37
38
|
pad: 4
|
|
38
39
|
})
|
package/index.js
CHANGED
|
@@ -103,7 +103,7 @@ export function resolveRef(ref, rootSchema) {
|
|
|
103
103
|
current = current[part];
|
|
104
104
|
}
|
|
105
105
|
// If the resolved schema also has a $ref, resolve it recursively
|
|
106
|
-
if (current
|
|
106
|
+
if (current?.$ref) {
|
|
107
107
|
return resolveRef(current.$ref, rootSchema);
|
|
108
108
|
}
|
|
109
109
|
processedRefs.delete(ref);
|
|
@@ -115,7 +115,7 @@ export function getModulePath(path) {
|
|
|
115
115
|
return path[0];
|
|
116
116
|
let result = '';
|
|
117
117
|
for (let i = 0; i < path.length - 1; i++) {
|
|
118
|
-
result += path[i]
|
|
118
|
+
result += `${path[i]}_::`;
|
|
119
119
|
}
|
|
120
120
|
result += path[path.length - 1];
|
|
121
121
|
return result;
|
|
@@ -363,7 +363,7 @@ export function processObject(schema, path, level, rootSchema = schema, pad = 0)
|
|
|
363
363
|
code += `${indentFn(level)}pub struct ${currentName} {\n`;
|
|
364
364
|
// Generate struct fields
|
|
365
365
|
Object.entries(schema.properties).forEach(([propName, propSchema]) => {
|
|
366
|
-
const isRequired = schema.required
|
|
366
|
+
const isRequired = schema.required?.includes(propName);
|
|
367
367
|
// Handle $ref in property
|
|
368
368
|
if (propSchema.$ref) {
|
|
369
369
|
const resolvedSchema = resolveRef(propSchema.$ref, rootSchema);
|
|
@@ -456,11 +456,11 @@ export function processObject(schema, path, level, rootSchema = schema, pad = 0)
|
|
|
456
456
|
if (propSchema.items.$ref) {
|
|
457
457
|
const resolved = resolveRef(propSchema.items.$ref, rootSchema);
|
|
458
458
|
if (resolved && (resolved.type === 'object' || resolved.properties)) {
|
|
459
|
-
code += processObject(resolved, [...path, propName
|
|
459
|
+
code += processObject(resolved, [...path, `${propName}Item`], level + 1, rootSchema, pad);
|
|
460
460
|
}
|
|
461
461
|
}
|
|
462
462
|
else if (propSchema.items.type === 'object' || propSchema.items.properties) {
|
|
463
|
-
code += processObject(propSchema.items, [...path, propName
|
|
463
|
+
code += processObject(propSchema.items, [...path, `${propName}Item`], level + 1, rootSchema, pad);
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
466
|
// Handle anyOf/oneOf/allOf schemas
|