Skip to content

Commit

Permalink
Add errors component to build and debug
Browse files Browse the repository at this point in the history
  • Loading branch information
acolytec3 committed Sep 26, 2024
1 parent f71e977 commit a993048
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion jsonrpc/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -57,7 +70,8 @@ let spec = await parseOpenRPCDocument({
methods: methods,
components: {
contentDescriptors: content,
schemas: schemas
schemas: schemas,
errors: errors
}
},
{dereference: false})
Expand Down
2 changes: 1 addition & 1 deletion jsonrpc/scripts/debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a993048

Please sign in to comment.