diff --git a/jsonrpc/scripts/build.js b/jsonrpc/scripts/build.js index 6f17c8c1..3677f8da 100644 --- a/jsonrpc/scripts/build.js +++ b/jsonrpc/scripts/build.js @@ -43,6 +43,19 @@ contentFiles.forEach(file => { }; }); +let errors = {}; +let errorBase = "src/errors/" +let errorFiles = fs.readdirSync(errorBase) +errorFiles.forEach(file => { + console.log(file); + let raw = fs.readFileSync(errorBase + file); + let parsed = JSON.parse(raw); + errors = { + ...errors, + ...parsed, + }; +}); + let spec = await parseOpenRPCDocument({ openrpc: "1.2.4", info: { @@ -57,7 +70,8 @@ let spec = await parseOpenRPCDocument({ methods: methods, components: { contentDescriptors: content, - schemas: schemas + schemas: schemas, + errors: errors } }, {dereference: false}) diff --git a/jsonrpc/scripts/debug.sh b/jsonrpc/scripts/debug.sh index 7e4d76b6..7cdd5387 100755 --- a/jsonrpc/scripts/debug.sh +++ b/jsonrpc/scripts/debug.sh @@ -2,6 +2,6 @@ set -o xtrace curl -s http://localhost:8545 -H 'Content-Type: application/json' -d '{"method":"'$1'","id":1,"jsonrpc":"2.0", "params":['$2']}' | jq '.["result"]' > data.json 2>&1 -cat openrpc.json | jq '.["methods"][] | select(.name == "'$1'") | .["result"]["schema"]' > schema.json +cat openrpc.json | jq '.["methods"][] | select(.name == "'$1'") | .["result"]["schema"]["errors"]' > schema.json ajv validate -s schema.json -d data.json # rm schema.json data.json