Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
wip: add jsonrpc schema
Browse files Browse the repository at this point in the history
  • Loading branch information
joemphilips committed Feb 26, 2023
1 parent 6a75de7 commit 2438ba7
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 0 deletions.
14 changes: 14 additions & 0 deletions schema/consignment.get.request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"additionalProperties": false,
"required": [
"blinded_utxo"
],
"properties": {
"blinded_utxo": {
"type": "string",
"description": "the blinded UTXO for which we want to download consignment data"
}
}
}
14 changes: 14 additions & 0 deletions schema/consignment.get.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"additionalProperties": false,
"required": [
"result"
],
"properties": {
"result": {
"type": "string",
"description": "`true` when first successful upload. `false` when the same file was already uploaded before."
}
}
}
14 changes: 14 additions & 0 deletions schema/consignment.post.request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"additionalProperties": false,
"required": [
"blinded_utxo"
],
"properties": {
"blinded_utxo": {
"type": "string",
"description": "the blinded UTXO for which we want to upload consingment file"
}
}
}
14 changes: 14 additions & 0 deletions schema/consignment.post.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"additionalProperties": false,
"required": [
"result"
],
"properties": {
"result": {
"type": "boolean",
"description": "`true` when first successful upload. `false` when the same file was already uploaded before."
}
}
}
145 changes: 145 additions & 0 deletions schema/openrpc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@

{
"methods": [
{
"name": "server.info",
"summary": "get server info",
"description": "get server info",
"params": [],
"result": {
"$ref": "server.info.schema.json"
}
},
{
"name": "consignment.post",
"summary": "Upload consignment info",
"description": "In addition to json-rpc request, the media file needs to be attached under \"file\" name via multipart form",
"params": [
{
"$ref": "consignment.post.request.json"
}
],
"result": {
"$ref": "consignment.post.schema.json"
},
"errors": [
{
"$ref": "#/components/errors/CANNOT_CHANGE_ACK"
},
{
"$ref": "#/components/errors/INVALID_BLINDED_UTXO"
},
{
"$ref": "#/components/errors/MISSING_BLINDED_UTXO"
},
{
"$ref": "#/components/errors/MISSING_FILE"
}
]
},
{
"name": "consignment.get",
"summary": "get previously uploaded consignment",
"params": [
{
"$ref": "consignment.get.request.json"
}
],
"result": {
"$ref": "consignment.get.schema.json"
},
"errors": [
{
"$ref": "#/components/errors/INVALID_BLINDED_UTXO"
},
{
"$ref": "#/components/errors/MISSING_BLINDED_UTXO"
},
{
"$ref": "#/components/errors/CONSIGNMENT_FILE_NOT_FOUND"
}
]
}
],
"components": {
"errors": {
"CANNOT_CHANGE_ACK": {
"code": -100,
"message": "Cannot change ACK",
"data": {
"type": "object"
}
},
"CANNOT_CHANGE_FILES": {
"code": -101,
"message": "Cannot change uploaded files",
"data": {
"type": "object"
}
},
"INVALID_ACK": {
"code": -200,
"message": "Invalid ACK",
"data": {
"type": "object"
}
},
"INVALID_ATTACHMENT_ID": {
"code": -201,
"message": "Invalid ACK",
"data": {
"type": "object"
}
},
"INVALID_BLINDED_UTXO": {
"code": -202,
"message": "Invalid blinded utxo",
"data": {
"type": "object"
}
},
"MISSING_ACK": {
"code": -300,
"message": "Missing ACK",
"data": {
"type": "object"
}
},
"MISSING_ATTACHMENT_ID": {
"code": -301,
"message": "Missing attachment id",
"data": {
"type": "object"
}
},
"MISSING_BLINDED_UTXO": {
"code": -302,
"message": "Missing blinded utxo",
"data": {
"type": "object"
}
},
"MISSING_FILE": {
"code": -303,
"message": "Missing file",
"data": {
"type": "object"
}
},
"CONSIGNMENT_FILE_NOT_FOUND": {
"code": -400,
"message": "Consignment file not found",
"data": {
"type": "object"
}
},
"MEDIA_FILE_NOT_FOUND": {
"code": -400,
"message": "Media file not found",
"data": {
"type": "object"
}
}
}
}
}
23 changes: 23 additions & 0 deletions schema/server.info.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"additionalProperties": false,
"required": [
"protocol_version",
"version"
],
"properties": {
"protocol_version": {
"type": "string",
"description": "version of the JSON-RPC protocol"
},
"version": {
"type": "string",
"description": "node software version"
},
"uptime": {
"type": "integer",
"description": "how long the server has been run (in seconds)."
}
}
}

0 comments on commit 2438ba7

Please sign in to comment.