Files
herolib/lib/schemas/openrpc/factory.v
Mahmoud-Emad 61487902d6 chore: Remove unused imports
- Remove 'os' import from heromodels
- Remove 'json' and 'x.json2' imports from openrpc
- Remove 'console' import from openrpc
- Remove unused imports in multiple modules
2025-09-28 10:38:45 +03:00

31 lines
560 B
V

module openrpc
import os
@[params]
pub struct Params {
pub:
path string // path to openrpc.json file
text string // content of openrpc specification text
}
pub fn new(params Params) !OpenRPC {
if params.path == '' && params.text == '' {
return OpenRPC{}
}
if params.text != '' && params.path != '' {
return error('Either provide path or text')
}
text := if params.path != '' {
os.read_file(params.path) or {
return error('Could not read openrpc spec file at ${params.path}: ${err}')
}
} else {
params.text
}
return decode(text)!
}