vovk-cli 0.0.1-draft.226 → 0.0.1-draft.227
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.
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import type { VovkClientFetcher } from 'vovk';
|
|
4
4
|
import type { fetcher } from '<%= t.imports.module.fetcher %>';
|
|
5
5
|
import type { createRPC } from '<%= t.imports.module.createRPC %>';
|
|
6
|
-
|
|
7
6
|
<% Object.values(t.schema.segments).filter((segment) => segment.emitSchema).forEach((segment, i) => { if(segment.segmentName !== t.EXTENSIONS_SEGMENT_NAME) { %>
|
|
8
7
|
import type { Controllers as Controllers<%= i %> } from "<%= t.segmentMeta[segment.segmentName].segmentImportPath %>";
|
|
9
8
|
<% } else { %>
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export function convertJSONSchemaToTypeScriptDef(schema) {
|
|
2
2
|
if (!schema)
|
|
3
3
|
return null;
|
|
4
|
+
// Helper function to escape single quotes in string literals
|
|
5
|
+
const escapeStringLiteral = (str) => {
|
|
6
|
+
return str.replace(/'/g, "\\'");
|
|
7
|
+
};
|
|
4
8
|
// Helper function to resolve $ref references
|
|
5
9
|
const resolveRef = (ref) => {
|
|
6
10
|
if (!ref.startsWith('#/'))
|
|
@@ -47,7 +51,7 @@ export function convertJSONSchemaToTypeScriptDef(schema) {
|
|
|
47
51
|
return schema.enum
|
|
48
52
|
.map((value) => {
|
|
49
53
|
if (typeof value === 'string') {
|
|
50
|
-
return `'${value}'`;
|
|
54
|
+
return `'${escapeStringLiteral(value)}'`;
|
|
51
55
|
}
|
|
52
56
|
else if (value === null) {
|
|
53
57
|
return 'null';
|
|
@@ -60,7 +64,7 @@ export function convertJSONSchemaToTypeScriptDef(schema) {
|
|
|
60
64
|
}
|
|
61
65
|
if (schema.const !== undefined) {
|
|
62
66
|
if (typeof schema.const === 'string') {
|
|
63
|
-
return `'${schema.const}'`;
|
|
67
|
+
return `'${escapeStringLiteral(schema.const)}'`;
|
|
64
68
|
}
|
|
65
69
|
else if (schema.const === null) {
|
|
66
70
|
return 'null';
|