diff --git a/packages/parsers/package.json b/packages/parsers/package.json index 38b88c1e1e..1685372d26 100644 --- a/packages/parsers/package.json +++ b/packages/parsers/package.json @@ -1,6 +1,6 @@ { "name": "@fern-api/docs-parsers", - "version": "0.0.36", + "version": "0.0.37", "repository": { "type": "git", "url": "https://github.com/fern-api/fern-platform.git", diff --git a/packages/parsers/src/examples/generateExampleForJsonSchema.ts b/packages/parsers/src/examples/generateExampleForJsonSchema.ts new file mode 100644 index 0000000000..e157213e89 --- /dev/null +++ b/packages/parsers/src/examples/generateExampleForJsonSchema.ts @@ -0,0 +1,75 @@ +import { JSONSchema } from "@open-rpc/meta-schema"; + +export function generateExampleForJsonSchema(schema: JSONSchema): unknown { + if (typeof schema === "boolean") { + return schema; + } + + if (schema.enum != null && schema.enum.length > 0) { + return schema.enum[0]; + } + + if (schema.const != null) { + return schema.const; + } + + if (schema.examples != null && schema.examples.length > 0) { + return schema.examples[0]; + } + + if (schema.type === "object") { + const example: Record = {}; + if (schema.properties != null) { + for (const [key, value] of Object.entries(schema.properties)) { + example[key] = generateExampleForJsonSchema(value); + } + } + return example; + } + + if (schema.type === "array") { + if (schema.items == null) { + return []; + } + if (Array.isArray(schema.items)) { + return schema.items.map((item) => generateExampleForJsonSchema(item)); + } + return [generateExampleForJsonSchema(schema.items)]; + } + + if (schema.type === "string") { + return schema.default ?? "string"; + } + + if (schema.type === "number" || schema.type === "integer") { + return schema.default ?? 0; + } + + if (schema.type === "boolean") { + return schema.default ?? false; + } + + if (schema.type === "null") { + return null; + } + + if (schema.oneOf?.[0] != null) { + return generateExampleForJsonSchema(schema.oneOf[0]); + } + + if (schema.anyOf?.[0] != null) { + return generateExampleForJsonSchema(schema.anyOf[0]); + } + + if (schema.allOf != null && schema.allOf.length > 0) { + const example: Record = {}; + for (const subSchema of schema.allOf) { + if (subSchema != null) { + Object.assign(example, generateExampleForJsonSchema(subSchema)); + } + } + return example; + } + + return undefined; +} diff --git a/packages/parsers/src/openrpc/1.x/MethodConverter.node.ts b/packages/parsers/src/openrpc/1.x/MethodConverter.node.ts index d61a7e377e..bc766f793b 100644 --- a/packages/parsers/src/openrpc/1.x/MethodConverter.node.ts +++ b/packages/parsers/src/openrpc/1.x/MethodConverter.node.ts @@ -3,6 +3,7 @@ import { MethodObject } from "@open-rpc/meta-schema"; import { camelCase } from "es-toolkit"; import { UnreachableCaseError } from "ts-essentials"; import { FernRegistry } from "../../client/generated"; +import { generateExampleForJsonSchema } from "../../examples/generateExampleForJsonSchema"; import { SchemaConverterNode, ServerObjectConverterNode } from "../../openapi"; import { maybeSingleValueToArray } from "../../openapi/utils/maybeSingleValueToArray"; import { @@ -100,25 +101,8 @@ export class MethodConverterNode extends BaseOpenrpcConverterNode< } : undefined; - // Convert method to HTTP endpoint - // This is a basic implementation that needs to be expanded - return { - id: FernRegistry.EndpointId(this.input.name), - displayName: camelCase(this.input.name), - method: "POST", - path: [{ type: "literal", value: "" }], - auth: undefined, - pathParameters: [], - queryParameters: [], - requests: request != null ? [request] : undefined, - responses: - response != null - ? [ - this.convertToHttpResponse(response, this.input.description), - ].filter(isNonNullish) - : [], - errors: [], - examples: this.method.examples + const examples = + this.method.examples ?.map( ( example @@ -157,7 +141,84 @@ export class MethodConverterNode extends BaseOpenrpcConverterNode< }; } ) - .filter(isNonNullish), + .filter(isNonNullish) ?? []; + + if (examples.length <= 0) { + const example = { + name: "Example", + path: "", + pathParameters: {}, + queryParameters: {}, + headers: {}, + requestBody: { + type: "json" as const, + value: generateExampleForJsonSchema({ + type: "object", + properties: Object.fromEntries( + this.method.params?.map((param) => { + const resolvedParam = resolveContentDescriptorObject( + param, + this.context.openrpc + ); + return [ + resolvedParam?.name ?? "", + resolvedParam?.schema ?? {}, + ]; + }) ?? [] + ), + }), + }, + responseStatusCode: 200, + responseBody: { + type: "json" as const, + value: generateExampleForJsonSchema( + resolveContentDescriptorObject( + this.method.result, + this.context.openrpc + )?.schema ?? {} + ), + }, + snippets: undefined, + description: undefined, + }; + examples.push(example); + } + + const examplesWithJsonRPCMetadata = examples.map((example) => { + const originalRequestBody = example.requestBody?.value; + return { + ...example, + requestBody: { + type: "json" as const, + value: { + id: 1, + jsonrpc: "2.0", + method: this.method.name, + params: originalRequestBody, + }, + }, + }; + }); + + // Convert method to HTTP endpoint + // This is a basic implementation that needs to be expanded + return { + id: FernRegistry.EndpointId(this.input.name), + displayName: camelCase(this.input.name), + method: "POST", + path: [{ type: "literal", value: "" }], + auth: undefined, + pathParameters: [], + queryParameters: [], + requests: request != null ? [request] : undefined, + responses: + response != null + ? [ + this.convertToHttpResponse(response, this.input.description), + ].filter(isNonNullish) + : [], + errors: [], + examples: examplesWithJsonRPCMetadata, description: this.input.description ?? this.input.summary, operationId: this.input.name, defaultEnvironment: undefined, diff --git a/packages/parsers/src/openrpc/__test__/__snapshots__/ethereum.json b/packages/parsers/src/openrpc/__test__/__snapshots__/ethereum.json index 9f672f2ae9..87420958d7 100644 --- a/packages/parsers/src/openrpc/__test__/__snapshots__/ethereum.json +++ b/packages/parsers/src/openrpc/__test__/__snapshots__/ethereum.json @@ -1268,6 +1268,29 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "web3_clientVersion", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": "string" + } + } + ], "description": "Returns the version of the current client", "operationId": "web3_clientVersion", "environments": [], @@ -1335,9 +1358,14 @@ "headers": {}, "requestBody": { "type": "json", - "value": [ - "0x68656c6c6f20776f726c64" - ] + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "web3_sha3", + "params": [ + "0x68656c6c6f20776f726c64" + ] + } }, "responseStatusCode": 200, "responseBody": { @@ -1391,6 +1419,14 @@ "pathParameters": {}, "queryParameters": {}, "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "net_listening" + } + }, "responseStatusCode": 200, "responseBody": { "type": "json", @@ -1436,6 +1472,29 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "net_peerCount", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": "string" + } + } + ], "description": "Returns the number of peers currently connected to this client.", "operationId": "net_peerCount", "environments": [], @@ -1472,6 +1531,29 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "net_version", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": "string" + } + } + ], "description": "Returns the network ID associated with the current network.", "operationId": "net_version", "environments": [], @@ -1504,6 +1586,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_blockNumber", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns the number of most recent block.", "operationId": "eth_blockNumber", "environments": [], @@ -1567,6 +1671,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_call", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Executes a new message call (locally) immediately without creating a transaction on the block chain.", "operationId": "eth_call", "environments": [], @@ -1603,6 +1729,29 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_chainId", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": "string" + } + } + ], "description": "Returns the currently configured chain id, a value used in replay-protected transaction signing as introduced by [EIP-155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md).", "operationId": "eth_chainId", "environments": [], @@ -1635,6 +1784,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_coinbase", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns the client coinbase address.", "operationId": "eth_coinbase", "environments": [], @@ -1688,6 +1859,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_estimateGas", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain. Note that the estimate may be significantly more than the amount of gas actually used by the transaction, for a variety of reasons including EVM mechanics and node performance.", "operationId": "eth_estimateGas", "environments": [], @@ -1720,6 +1913,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_gasPrice", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns the current price per gas in wei", "operationId": "eth_gasPrice", "environments": [], @@ -1785,6 +2000,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getBalance", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns Ether balance of a given or account or contract", "operationId": "eth_getBalance", "environments": [], @@ -1851,6 +2088,30 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getBlockByHash", + "params": { + "includeTransactions": false + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Gets a block for a given hash", "operationId": "eth_getBlockByHash", "environments": [], @@ -1917,6 +2178,30 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getBlockByNumber", + "params": { + "includeTransactions": false + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Gets a block for a given number", "operationId": "eth_getBlockByNumber", "environments": [], @@ -1970,6 +2255,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getBlockTransactionCountByHash", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns the number of transactions in a block from a block matching the given block hash.", "operationId": "eth_getBlockTransactionCountByHash", "environments": [], @@ -2023,6 +2330,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getBlockTransactionCountByNumber", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns the number of transactions in a block from a block matching the given block number.", "operationId": "eth_getBlockTransactionCountByNumber", "environments": [], @@ -2088,6 +2417,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getCode", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns code at a given contract address", "operationId": "eth_getCode", "environments": [], @@ -2147,6 +2498,31 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getFilterChanges", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + null + ] + } + } + ], "description": "Polling method for a filter, which returns an array of logs which occurred since last poll.", "operationId": "eth_getFilterChanges", "environments": [], @@ -2206,6 +2582,31 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getFilterLogs", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + null + ] + } + } + ], "description": "Returns an array of all logs matching filter with given id.", "operationId": "eth_getFilterLogs", "environments": [], @@ -2259,6 +2660,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getRawTransactionByHash", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns raw transaction data of a transaction with the given hash.", "operationId": "eth_getRawTransactionByHash", "environments": [], @@ -2323,6 +2746,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getRawTransactionByBlockHashAndIndex", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns raw transaction data of a transaction with the block hash and index of which it was mined.", "operationId": "eth_getRawTransactionByBlockHashAndIndex", "environments": [], @@ -2387,6 +2832,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getRawTransactionByBlockNumberAndIndex", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns raw transaction data of a transaction with the block number and index of which it was mined.", "operationId": "eth_getRawTransactionByBlockNumberAndIndex", "environments": [], @@ -2485,6 +2952,33 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getLogs", + "params": { + "filter": {} + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + null + ] + } + } + ], "description": "Returns an array of all logs matching a given filter object.", "operationId": "eth_getLogs", "environments": [], @@ -2558,6 +3052,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getStorageAt", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Gets a storage value from a contract address, a position, and an optional blockNumber", "operationId": "eth_getStorageAt", "environments": [], @@ -2631,10 +3147,15 @@ "headers": {}, "requestBody": { "type": "json", - "value": [ - "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", - "0x0" - ] + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getTransactionByBlockHashAndIndex", + "params": [ + "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", + "0x0" + ] + } }, "responseStatusCode": 200, "responseBody": { @@ -2710,6 +3231,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getTransactionByBlockNumberAndIndex", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns the information about a transaction requested by the block number and index of which it was mined.", "operationId": "eth_getTransactionByBlockNumberAndIndex", "environments": [], @@ -2763,6 +3306,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getTransactionByHash", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns the information about a transaction requested by transaction hash.", "operationId": "eth_getTransactionByHash", "environments": [], @@ -2826,6 +3391,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getTransactionCount", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns the number of transactions sent from an address", "operationId": "eth_getTransactionCount", "environments": [], @@ -2879,6 +3466,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getTransactionReceipt", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns the receipt information of a transaction by its hash.", "operationId": "eth_getTransactionReceipt", "environments": [], @@ -2943,6 +3552,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getUncleByBlockHashAndIndex", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns information about a uncle of a block by hash and uncle index position.", "operationId": "eth_getUncleByBlockHashAndIndex", "environments": [], @@ -3016,11 +3647,16 @@ "queryParameters": {}, "headers": {}, "requestBody": { - "type": "json", - "value": [ - "0x0", - "0x0" - ] + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getUncleByBlockNumberAndIndex", + "params": [ + "0x0", + "0x0" + ] + } }, "responseStatusCode": 200, "responseBody": { @@ -3085,6 +3721,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getUncleCountByBlockHash", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns the number of uncles in a block from a block matching the given block hash.", "operationId": "eth_getUncleCountByBlockHash", "environments": [], @@ -3138,6 +3796,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getUncleCountByBlockNumber", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns the number of uncles in a block from a block matching the given block number.", "operationId": "eth_getUncleCountByBlockNumber", "environments": [], @@ -3276,6 +3956,29 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getProof", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": {} + } + } + ], "description": "Returns the account- and storage-values of the specified account including the Merkle-proof.", "operationId": "eth_getProof", "environments": [], @@ -3339,6 +4042,33 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_getWork", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + null, + null, + null + ] + } + } + ], "description": "Returns the hash of the current block, the seedHash, and the boundary condition to be met ('target').", "operationId": "eth_getWork", "environments": [], @@ -3371,6 +4101,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_hashrate", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns the number of hashes per second that the node is mining with.", "operationId": "eth_hashrate", "environments": [], @@ -3405,6 +4157,29 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_mining", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": false + } + } + ], "description": "Returns true if client is actively mining new blocks.", "operationId": "eth_mining", "environments": [], @@ -3437,6 +4212,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_newBlockFilter", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call eth_getFilterChanges.", "operationId": "eth_newBlockFilter", "environments": [], @@ -3529,6 +4326,30 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_newFilter", + "params": { + "filter": {} + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call eth_getFilterChanges.", "operationId": "eth_newFilter", "environments": [], @@ -3561,6 +4382,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_newPendingTransactionFilter", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call eth_getFilterChanges.", "operationId": "eth_newPendingTransactionFilter", "environments": [], @@ -3593,6 +4436,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_pendingTransactions", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns the transactions that are pending in the transaction pool and have a from address that is one of the accounts this node manages.", "operationId": "eth_pendingTransactions", "environments": [], @@ -3625,6 +4490,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_protocolVersion", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Returns the current ethereum protocol version.", "operationId": "eth_protocolVersion", "environments": [], @@ -3679,6 +4566,28 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_sendRawTransaction", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json" + } + } + ], "description": "Creates new message call transaction or a contract creation for signed transactions.", "operationId": "eth_sendRawTransaction", "environments": [], @@ -3745,6 +4654,29 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_submitHashrate", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": false + } + } + ], "description": "Used for submitting mining hashrate.", "operationId": "eth_submitHashrate", "environments": [], @@ -3830,11 +4762,16 @@ "headers": {}, "requestBody": { "type": "json", - "value": [ - "0x0000000000000001", - "0x6bf2cAE0dE3ec3ecA5E194a6C6e02cf42aADfe1C2c4Fff12E5D36C3Cf7297F22", - "0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000" - ] + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_submitWork", + "params": [ + "0x0000000000000001", + "0x6bf2cAE0dE3ec3ecA5E194a6C6e02cf42aADfe1C2c4Fff12E5D36C3Cf7297F22", + "0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000" + ] + } }, "responseStatusCode": 200, "responseBody": { @@ -3933,6 +4870,29 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_syncing", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": {} + } + } + ], "description": "Returns an object with data about the sync status or false.", "operationId": "eth_syncing", "environments": [], @@ -3988,6 +4948,29 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "eth_uninstallFilter", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": false + } + } + ], "description": "Uninstalls a filter with given id. Should always be called when watch is no longer needed. Additionally Filters timeout when they aren't requested with eth_getFilterChanges for a period of time.", "operationId": "eth_uninstallFilter", "environments": [], diff --git a/packages/parsers/src/openrpc/__test__/__snapshots__/petstore.json b/packages/parsers/src/openrpc/__test__/__snapshots__/petstore.json index 1cf09e700a..da58426450 100644 --- a/packages/parsers/src/openrpc/__test__/__snapshots__/petstore.json +++ b/packages/parsers/src/openrpc/__test__/__snapshots__/petstore.json @@ -140,9 +140,14 @@ "headers": {}, "requestBody": { "type": "json", - "value": [ - 1 - ] + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "list_pets", + "params": [ + 1 + ] + } }, "responseStatusCode": 200, "responseBody": { @@ -243,10 +248,15 @@ "headers": {}, "requestBody": { "type": "json", - "value": [ - "fluffy", - "poodle" - ] + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "create_pet", + "params": [ + "fluffy", + "poodle" + ] + } }, "responseStatusCode": 200, "responseBody": { @@ -326,9 +336,14 @@ "headers": {}, "requestBody": { "type": "json", - "value": [ - 7 - ] + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "get_pet", + "params": [ + 7 + ] + } }, "responseStatusCode": 200, "responseBody": { diff --git a/packages/parsers/src/openrpc/__test__/__snapshots__/solana.json b/packages/parsers/src/openrpc/__test__/__snapshots__/solana.json index 7684a34b69..338a0686c9 100644 --- a/packages/parsers/src/openrpc/__test__/__snapshots__/solana.json +++ b/packages/parsers/src/openrpc/__test__/__snapshots__/solana.json @@ -231,6 +231,49 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getAccountInfo", + "params": { + "Pubkey": "string", + "Configuration": { + "commitment": "processed", + "encoding": "base58", + "dataSlice": { + "length": 0, + "offset": 0 + }, + "minContextSlot": 0 + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "lamports": 0, + "owner": "string", + "data": [ + "string" + ], + "executable": false, + "rentEpoch": 0, + "size": 0 + } + } + } + ], "description": "Returns all information associated with the account of provided Pubkey.", "operationId": "getAccountInfo", "environments": [], @@ -330,6 +373,35 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getBalance", + "params": { + "Pubkey": "string", + "Configuration": { + "commitment": "processed", + "minContextSlot": 0 + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": 0 + } + } + ], "description": "Returns the lamport balance of the account of the provided Pubkey.", "operationId": "getBalance", "environments": [], @@ -1391,6 +1463,143 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getBlock", + "params": { + "slot": 0, + "Configuration": { + "commitment": "processed", + "encoding": "json", + "transactionDetails": "full", + "maxSupportedTransactionVersion": 0, + "rewards": true + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "blockhash": "string", + "previousBlockhash": "string", + "parentSlot": 0, + "transactions": [ + { + "slot": 0, + "transaction": { + "signatures": [ + "string" + ], + "message": { + "accountKeys": [ + "string" + ], + "header": { + "numRequiredSignatures": 0, + "numReadonlySignedAccounts": 0, + "numReadonlyUnsignedAccounts": 0 + }, + "instructions": [ + { + "accounts": [ + 0 + ], + "data": "string", + "programIdIndex": 0 + } + ], + "recentBlockhash": "string" + } + }, + "blockTime": 0, + "meta": { + "err": {}, + "fee": 0, + "preBalances": [ + 0 + ], + "postBalances": [ + 0 + ], + "innerInstructions": [ + { + "index": 0, + "instructions": [ + { + "programId": "string", + "accounts": [ + "string" + ], + "data": "string" + } + ] + } + ], + "preTokenBalances": [ + { + "amount": "string", + "decimals": 0, + "uiAmount": 0, + "uiAmountString": "string" + } + ], + "postTokenBalances": [ + { + "amount": "string", + "decimals": 0, + "uiAmount": 0, + "uiAmountString": "string" + } + ], + "logMessages": [ + "string" + ], + "rewards": [ + { + "pubkey": "string", + "lamports": 0, + "postBalance": 0, + "rewardType": "fee", + "commission": 0 + } + ], + "loadedAddresses": {}, + "returnData": {}, + "computeUnitsConsumed": 0 + }, + "version": "string" + } + ], + "signatures": [ + "string" + ], + "rewards": [ + { + "pubkey": "string", + "lamports": 0, + "postBalance": 0, + "rewardType": "fee", + "commission": 0 + } + ], + "blockTime": 0, + "blockHeight": 0 + } + } + } + ], "description": "Returns identity and transaction information about a confirmed block in the ledger.", "operationId": "getBlock", "environments": [], @@ -1478,6 +1687,36 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getBlockCommitment", + "params": { + "block": 0 + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "commitment": [ + 0 + ], + "totalStake": 0 + } + } + } + ], "description": "Returns the commitment for a particular block.", "operationId": "getBlockCommitment", "environments": [], @@ -1564,6 +1803,34 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getBlockHeight", + "params": { + "Configuration": { + "commitment": "processed", + "minContextSlot": 0 + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": 0 + } + } + ], "description": "Returns the current block height of the node.", "operationId": "getBlockHeight", "environments": [], @@ -1751,6 +2018,44 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getBlockProduction", + "params": { + "Configuration": { + "commitment": "processed", + "identity": "string", + "range": { + "firstSlot": 0, + "lastSlot": 0 + } + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "byIdentity": {}, + "range": { + "firstSlot": 0, + "lastSlot": 0 + } + } + } + } + ], "description": "Returns recent block production information from the current or previous epoch.", "operationId": "getBlockProduction", "environments": [], @@ -1857,6 +2162,37 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getBlocks", + "params": { + "start_slot": 0, + "end_slot": 0, + "Configuration": { + "commitment": "processed" + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + 0 + ] + } + } + ], "description": "Returns a list of confirmed blocks between two slots.", "operationId": "getBlocks", "environments": [], @@ -1963,6 +2299,37 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getBlocksWithLimit", + "params": { + "start_slot": 0, + "limit": 0, + "Configuration": { + "commitment": "processed" + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + 0 + ] + } + } + ], "description": "Returns a list of confirmed blocks starting at the given slot.", "operationId": "getBlocksWithLimit", "environments": [], @@ -2031,6 +2398,33 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getBlockTime", + "params": { + "block": { + "block": 0 + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": 0 + } + } + ], "description": "Returns the estimated production time of a block.", "operationId": "getBlockTime", "environments": [], @@ -2195,6 +2589,39 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getClusterNodes", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + { + "pubkey": "string", + "gossip": "string", + "tpu": "string", + "rpc": "string", + "version": "string", + "featureSet": 0, + "shredVersion": 0 + } + ] + } + } + ], "description": "Returns information about all the nodes participating in the cluster.", "operationId": "getClusterNodes", "environments": [], @@ -2362,6 +2789,41 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getEpochInfo", + "params": { + "Configuration": { + "commitment": "processed", + "minContextSlot": 0 + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "absoluteSlot": 0, + "blockHeight": 0, + "epoch": 0, + "slotIndex": 0, + "slotsInEpoch": 0, + "transactionCount": 0 + } + } + } + ], "description": "Returns information about the current epoch.", "operationId": "getEpochInfo", "environments": [], @@ -2458,6 +2920,35 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getEpochSchedule", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "slotsPerEpoch": 0, + "leaderScheduleSlotOffset": 0, + "warmup": false, + "firstNormalEpoch": 0, + "firstNormalSlot": 0 + } + } + } + ], "description": "Returns the epoch schedule information from the cluster's genesis config.", "operationId": "getEpochSchedule", "environments": [], @@ -2573,6 +3064,37 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getFeeForMessage", + "params": { + "Message": { + "Message": "string" + }, + "Configuration": { + "commitment": "processed", + "minContextSlot": 0 + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": 0 + } + } + ], "description": "Get the fee the network will charge for a particular Message.", "operationId": "getFeeForMessage", "environments": [], @@ -2607,6 +3129,29 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getFirstAvailableBlock", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": 0 + } + } + ], "description": "Returns the slot of the lowest confirmed block that has not been purged from the ledger.", "operationId": "getFirstAvailableBlock", "environments": [], @@ -2641,6 +3186,29 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getGenesisHash", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": "string" + } + } + ], "description": "Returns the genesis hash.", "operationId": "getGenesisHash", "environments": [], @@ -2675,6 +3243,29 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getHealth", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": "string" + } + } + ], "description": "Returns the current health of the node.", "operationId": "getHealth", "environments": [], @@ -2738,6 +3329,32 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getHighestSnapshotSlot", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "full": 0, + "incremental": 0 + } + } + } + ], "description": "Returns the highest slot information that the node has snapshots for.", "operationId": "getHighestSnapshotSlot", "environments": [], @@ -2782,6 +3399,31 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getIdentity", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "identity": "string" + } + } + } + ], "description": "Returns the identity pubkey for the current node.", "operationId": "getIdentity", "environments": [], @@ -2930,6 +3572,40 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getInflationGovernor", + "params": { + "Configuration": { + "commitment": "processed", + "minContextSlot": 0 + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "initial": 0, + "terminal": 0, + "taper": 0, + "foundation": 0, + "foundationTerm": 0 + } + } + } + ], "description": "Returns the current inflation governor.", "operationId": "getInflationGovernor", "environments": [], @@ -3013,6 +3689,34 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getInflationRate", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "total": 0, + "validator": 0, + "foundation": 0, + "epoch": 0 + } + } + } + ], "description": "Returns the specific inflation values for the current epoch.", "operationId": "getInflationRate", "environments": [], @@ -3211,6 +3915,46 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getInflationReward", + "params": { + "Addresses": { + "Addresses": [ + "string" + ], + "commitment": "processed", + "epoch": 0, + "minContextSlot": 0 + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + { + "epoch": 0, + "effectiveSlot": 0, + "amount": 0, + "postBalance": 0, + "commission": 0 + } + ] + } + } + ], "description": "Returns the inflation or staking reward for a list of addresses for a specified epoch.", "operationId": "getInflationReward", "environments": [], @@ -3328,6 +4072,39 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getLargestAccounts", + "params": { + "Configuration": { + "commitment": "processed", + "filter": "circulating" + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + { + "address": "string", + "lamports": 0 + } + ] + } + } + ], "description": "Returns the 20 largest accounts, by lamport balance.", "operationId": "getLargestAccounts", "environments": [], @@ -3437,6 +4214,37 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getLatestBlockhash", + "params": { + "Configuration": { + "commitment": "processed", + "minContextSlot": 0 + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "blockhash": "string", + "lastValidBlockHeight": 0 + } + } + } + ], "description": "Returns the latest blockhash.", "operationId": "getLatestBlockhash", "environments": [], @@ -3471,6 +4279,29 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getMaxRetransmitSlot", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": 0 + } + } + ], "description": "Get the max slot seen from the retransmit stage.", "operationId": "getMaxRetransmitSlot", "environments": [], @@ -3505,6 +4336,29 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getMaxShredInsertSlot", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": 0 + } + } + ], "description": "Get the max slot seen from after shred insert.", "operationId": "getMaxShredInsertSlot", "environments": [], @@ -3601,6 +4455,36 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getMinimumBalanceForRentExemption", + "params": { + "Account data length": { + "dataLength": 0 + }, + "Configuration": { + "commitment": "processed" + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": 0 + } + } + ], "description": "Returns the minimum balance required to make an account rent exempt.", "operationId": "getMinimumBalanceForRentExemption", "environments": [], @@ -3850,6 +4734,53 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getMultipleAccounts", + "params": { + "Pubkeys": [ + "string" + ], + "Configuration": { + "commitment": "processed", + "minContextSlot": 0, + "dataSlice": { + "length": 0, + "offset": 0 + }, + "encoding": "base58" + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + { + "lamports": 0, + "owner": "string", + "data": [ + "string" + ], + "executable": false, + "rentEpoch": 0, + "size": 0 + } + ] + } + } + ], "description": "Returns the account information for a list of Pubkeys.", "operationId": "getMultipleAccounts", "environments": [], @@ -4128,6 +5059,56 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getProgramAccounts", + "params": { + "Pubkey": "string", + "Configuration": { + "commitment": "processed", + "minContextSlot": 0, + "withContext": false, + "encoding": "base58", + "dataSlice": { + "length": 0, + "offset": 0 + }, + "filters": [] + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + { + "pubkey": "string", + "account": { + "lamports": 0, + "owner": "string", + "data": [ + "string" + ], + "executable": false, + "rentEpoch": 0, + "size": 0 + } + } + ] + } + } + ], "description": "Returns all accounts owned by the provided program Pubkey.", "operationId": "getProgramAccounts", "environments": [], @@ -4254,6 +5235,39 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getRecentPerformanceSamples", + "params": { + "limit": 0 + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + { + "slot": 0, + "numTransactions": 0, + "numSlots": 0, + "samplePeriodSecs": 0, + "numNonVoteTransactions": 0 + } + ] + } + } + ], "description": "Returns a list of recent performance samples, in reverse slot order.", "operationId": "getRecentPerformanceSamples", "environments": [], @@ -4347,6 +5361,38 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getRecentPrioritizationFees", + "params": { + "Account addresses": [ + "string" + ] + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + { + "slot": 0, + "prioritizationFee": 0 + } + ] + } + } + ], "description": "Returns a list of prioritization fees from recent blocks.", "operationId": "getRecentPrioritizationFees", "environments": [], @@ -4587,6 +5633,47 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getSignaturesForAddress", + "params": { + "Account address": "string", + "Configuration": { + "commitment": "processed", + "minContextSlot": 0, + "limit": 1000, + "before": "string", + "until": "string" + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + { + "signature": "string", + "slot": 0, + "err": {}, + "memo": "string", + "blockTime": 0, + "confirmationStatus": "string" + } + ] + } + } + ], "description": "Returns signatures for confirmed transactions that include the given address.", "operationId": "getSignaturesForAddress", "environments": [], @@ -4752,6 +5839,44 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getSignatureStatuses", + "params": { + "Signatures": [ + "string" + ], + "Configuration": { + "searchTransactionHistory": false + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + { + "slot": 0, + "confirmations": 0, + "err": {}, + "confirmationStatus": "string", + "status": {} + } + ] + } + } + ], "description": "Returns the statuses of a list of transaction signatures.", "operationId": "getSignatureStatuses", "environments": [], @@ -4838,6 +5963,34 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getSlot", + "params": { + "Configuration": { + "commitment": "processed", + "minContextSlot": 0 + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": 0 + } + } + ], "description": "Returns the slot that has reached the given or default commitment level.", "operationId": "getSlot", "environments": [], @@ -4924,6 +6077,34 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getSlotLeader", + "params": { + "Configuration": { + "commitment": "processed", + "minContextSlot": 0 + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": "string" + } + } + ], "description": "Returns the current slot leader.", "operationId": "getSlotLeader", "environments": [], @@ -5001,6 +6182,34 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getSlotLeaders", + "params": { + "Start slot": 0, + "Limit": 0 + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + "string" + ] + } + } + ], "description": "Returns the slot leaders for a given slot range.", "operationId": "getSlotLeaders", "environments": [], @@ -5142,6 +6351,41 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getSupply", + "params": { + "Configuration": { + "commitment": "processed", + "excludeNonCirculatingAccountsList": false + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "total": 0, + "circulating": 0, + "nonCirculating": 0, + "nonCirculatingAccounts": [ + "string" + ] + } + } + } + ], "description": "Returns information about the current supply of lamports.", "operationId": "getSupply", "environments": [], @@ -5283,6 +6527,39 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getTokenAccountBalance", + "params": { + "Token account Pubkey": "string", + "Configuration": { + "commitment": "processed" + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "amount": "string", + "decimals": 0, + "uiAmount": 0, + "uiAmountString": "string" + } + } + } + ], "description": "Returns the token balance of an SPL Token account.", "operationId": "getTokenAccountBalance", "environments": [], @@ -5583,6 +6860,58 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getTokenAccountsByOwner", + "params": { + "Token owner Pubkey": "string", + "Token filter": { + "mint": "string", + "programId": "string" + }, + "Configuration": { + "commitment": "processed", + "minContextSlot": 0, + "dataSlice": { + "length": 0, + "offset": 0 + }, + "encoding": "base58" + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": [ + { + "pubkey": "string", + "account": { + "lamports": 0, + "owner": "string", + "data": [ + "string" + ], + "executable": false, + "rentEpoch": 0, + "size": 0 + } + } + ] + } + } + ], "description": "Returns all SPL Token accounts owned by the specified token owner.", "operationId": "getTokenAccountsByOwner", "environments": [], @@ -5724,6 +7053,39 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getTokenSupply", + "params": { + "Token Mint Pubkey": "string", + "Configuration": { + "commitment": "processed" + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "amount": "string", + "decimals": 0, + "uiAmount": 0, + "uiAmountString": "string" + } + } + } + ], "description": "Returns the total supply of an SPL Token type.", "operationId": "getTokenSupply", "environments": [], @@ -5916,6 +7278,42 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getTransaction", + "params": { + "Transaction signature": "string", + "Configuration": { + "commitment": "processed", + "maxSupportedTransactionVersion": 0, + "encoding": "json" + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "slot": 0, + "transaction": {}, + "blockTime": 0, + "meta": {}, + "version": "string" + } + } + } + ], "description": "Returns transaction details for a confirmed transaction.", "operationId": "getTransaction", "environments": [], @@ -5973,6 +7371,32 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getVersion", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "solana-core": "string", + "feature-set": 0 + } + } + } + ], "description": "Returns the current Solana version running on the node.", "operationId": "getVersion", "environments": [], @@ -6346,6 +7770,69 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "getVoteAccounts", + "params": { + "Configuration": { + "commitment": "processed", + "votePubkey": "string", + "keepUnstakedDelinquents": false, + "delinquentSlotDistance": 0 + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "current": [ + { + "votePubkey": "string", + "nodePubkey": "string", + "activatedStake": 0, + "epochVoteAccount": false, + "commission": 0, + "lastVote": 0, + "epochCredits": [ + [ + 0 + ] + ], + "rootSlot": 0 + } + ], + "delinquent": [ + { + "votePubkey": "string", + "nodePubkey": "string", + "activatedStake": 0, + "epochVoteAccount": false, + "commission": 0, + "lastVote": 0, + "epochCredits": [ + [ + 0 + ] + ], + "rootSlot": 0 + } + ] + } + } + } + ], "description": "Returns the account info and associated stake for all voting accounts in the current bank.", "operationId": "getVoteAccounts", "environments": [], @@ -6458,6 +7945,36 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "isBlockhashValid", + "params": { + "blockhash": "string", + "Configuration": { + "blockhash": "string", + "commitment": "processed", + "minContextSlot": 0 + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": false + } + } + ], "description": "Returns whether a blockhash is still valid or not.", "operationId": "isBlockhashValid", "environments": [], @@ -6492,6 +8009,29 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "minimumLedgerSlot", + "params": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": 0 + } + } + ], "description": "Returns the lowest slot that the node has information about in its ledger.", "operationId": "minimumLedgerSlot", "environments": [], @@ -6591,6 +8131,35 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "requestAirdrop", + "params": { + "Pubkey": "string", + "Lamports": 0, + "Configuration": { + "commitment": "processed" + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": "string" + } + } + ], "description": "Requests an airdrop of lamports to a Pubkey.", "operationId": "requestAirdrop", "environments": [], @@ -6734,6 +8303,38 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "sendTransaction", + "params": { + "Transaction": "string", + "Configuration": { + "encoding": "base58", + "skipPreflight": false, + "preflightCommitment": "processed", + "maxRetries": 0, + "minContextSlot": 0 + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": "string" + } + } + ], "description": "Submits a signed transaction to the cluster for processing.", "operationId": "sendTransaction", "environments": [], @@ -7152,6 +8753,70 @@ } ], "errors": [], + "examples": [ + { + "name": "Example", + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "type": "json", + "value": { + "id": 1, + "jsonrpc": "2.0", + "method": "simulateTransaction", + "params": { + "Transaction": "string", + "Configuration": { + "commitment": "processed", + "sigVerify": false, + "replaceRecentBlockhash": false, + "minContextSlot": 0, + "encoding": "base58", + "innerInstructions": false, + "accounts": { + "addresses": [ + "string" + ], + "encoding": "base58" + } + } + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "type": "json", + "value": { + "err": "string", + "logs": [ + "string" + ], + "accounts": [ + { + "lamports": 0, + "owner": "string", + "data": [ + "string" + ], + "executable": false, + "rentEpoch": 0, + "size": 0 + } + ], + "unitsConsumed": 0, + "returnData": { + "programId": "string", + "data": [ + "string" + ] + }, + "innerInstructions": {} + } + } + } + ], "description": "Simulates sending a transaction.", "operationId": "simulateTransaction", "environments": [],