diff --git a/lib/hero/herofs/fs.v b/lib/hero/herofs/fs.v index 74b12bd2..8b583264 100644 --- a/lib/hero/herofs/fs.v +++ b/lib/hero/herofs/fs.v @@ -22,7 +22,7 @@ pub mut: pub struct DBFs { pub mut: db &db.DB @[skip; str: skip] - factory &ModelsFactory = unsafe { nil } @[skip; str: skip] + factory &FSFactory = unsafe { nil } @[skip; str: skip] } pub fn (self Fs) type_name() string { @@ -268,7 +268,7 @@ pub fn (mut self DBFs) check_quota(id u32, additional_bytes u64) !bool { return (fs.used_bytes + additional_bytes) <= fs.quota_bytes } -pub fn fs_handle(mut f ModelsFactory, rpcid int, servercontext map[string]string, userref UserRef, method string, params string) !Response { +pub fn fs_handle(mut f FSFactory, rpcid int, servercontext map[string]string, userref UserRef, method string, params string) !Response { match method { 'get' { id := db.decode_u32(params)! diff --git a/lib/hero/herofs/fs_blob_membership.v b/lib/hero/herofs/fs_blob_membership.v index 437d4c08..672cd735 100644 --- a/lib/hero/herofs/fs_blob_membership.v +++ b/lib/hero/herofs/fs_blob_membership.v @@ -19,7 +19,7 @@ pub mut: pub struct DBFsBlobMembership { pub mut: db &db.DB @[skip; str: skip] - factory &ModelsFactory = unsafe { nil } @[skip; str: skip] + factory &FSFactory = unsafe { nil } @[skip; str: skip] } pub fn (self FsBlobMembership) type_name() string { @@ -257,7 +257,7 @@ pub fn (self FsBlobMembership) example(methodname string) (string, string) { } } -pub fn fs_blob_membership_handle(mut f ModelsFactory, rpcid int, servercontext map[string]string, userref UserRef, method string, params string) !Response { +pub fn fs_blob_membership_handle(mut f FSFactory, rpcid int, servercontext map[string]string, userref UserRef, method string, params string) !Response { match method { 'get' { hash := db.decode_string(params)! diff --git a/lib/hero/herofs/fs_dir.v b/lib/hero/herofs/fs_dir.v index 3106fea7..463b481b 100644 --- a/lib/hero/herofs/fs_dir.v +++ b/lib/hero/herofs/fs_dir.v @@ -23,7 +23,7 @@ pub mut: pub struct DBFsDir { pub mut: db &db.DB @[skip; str: skip] - factory &ModelsFactory = unsafe { nil } @[skip; str: skip] + factory &FSFactory = unsafe { nil } @[skip; str: skip] } pub fn (self FsDir) type_name() string { @@ -330,7 +330,7 @@ pub fn (self FsDir) example(methodname string) (string, string) { } } -pub fn fs_dir_handle(mut f ModelsFactory, rpcid int, servercontext map[string]string, userref UserRef, method string, params string) !Response { +pub fn fs_dir_handle(mut f FSFactory, rpcid int, servercontext map[string]string, userref UserRef, method string, params string) !Response { match method { 'get' { id := db.decode_u32(params)! diff --git a/lib/hero/herofs/fs_symlink.v b/lib/hero/herofs/fs_symlink.v index 1f299ffa..9544a1ae 100644 --- a/lib/hero/herofs/fs_symlink.v +++ b/lib/hero/herofs/fs_symlink.v @@ -27,7 +27,7 @@ pub enum SymlinkTargetType { pub struct DBFsSymlink { pub mut: db &db.DB @[skip; str: skip] - factory &ModelsFactory = unsafe { nil } @[skip; str: skip] + factory &FSFactory = unsafe { nil } @[skip; str: skip] } pub fn (self FsSymlink) type_name() string { @@ -212,7 +212,7 @@ pub fn (self FsSymlink) example(methodname string) (string, string) { } } -pub fn fs_symlink_handle(mut f ModelsFactory, rpcid int, servercontext map[string]string, userref UserRef, method string, params string) !Response { +pub fn fs_symlink_handle(mut f FSFactory, rpcid int, servercontext map[string]string, userref UserRef, method string, params string) !Response { match method { 'get' { id := db.decode_u32(params)! diff --git a/lib/hero/typescriptgenerator/intermediate_model.v b/lib/hero/typescriptgenerator/intermediate_model.v index 9de6b326..aa5e1475 100644 --- a/lib/hero/typescriptgenerator/intermediate_model.v +++ b/lib/hero/typescriptgenerator/intermediate_model.v @@ -61,10 +61,13 @@ pub fn from_openrpc(openrpc_spec openrpc.OpenRPC, config IntermediateConfig) !In return error('handler_type cannot be empty') } + // Process schemas + mut schemas_map := process_schemas(openrpc_spec.components.schemas)! + mut intermediate_spec := IntermediateSpec{ info: openrpc_spec.info methods: []IntermediateMethod{} - schemas: process_schemas(openrpc_spec.components.schemas)! + schemas: schemas_map base_url: config.base_url } @@ -183,7 +186,10 @@ fn extract_type_from_schema(schema_ref jsonschema.SchemaRef) string { fn process_schemas(schemas map[string]jsonschema.SchemaRef) !map[string]IntermediateSchema { + // Initialize the map with a known size if possible mut intermediate_schemas := map[string]IntermediateSchema{} + + // Process each schema in the map for name, schema_ref in schemas { if schema_ref is jsonschema.Schema { schema := schema_ref as jsonschema.Schema