Files
herolib/lib/schemas/openrpc/factory.v
Mahmoud-Emad e4101351aa feat: generate dynamic API docs from OpenRPC spec
- Implement dynamic doc generation from OpenRPC methods
- Generate example calls and responses from schemas
- Improve OpenRPC and JSON Schema decoders for full parsing
- Add example value generation based on schema type
- Add tests for schema decoding with examples
2025-09-17 17:50:43 +03:00

32 lines
572 B
V

module openrpc
import os
import json
@[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)!
}