Skip to content

Support parsing oneof and anyof in params.schema #33

@imnisen

Description

@imnisen

Hi, I am trying to use (generate-client *some-symbol* "/path/to/execution-apis/openrpc.json") (where the api is from https://ethereum.github.io/execution-apis/api-documentation/) to generate a client, but failed because there is oneOf keyword in schema of method's params, such as:

{
			"name": "debug_getRawBlock",
			"summary": "Returns an RLP-encoded block.",
			"params": [
				{
					"name": "Block",
					"required": true,
					"schema": {
						"title": "Block number or tag",
						"oneOf": [
							{
								"title": "Block number",
								"type": "string",
								"pattern": "^0x(0|[1-9a-f][0-9a-f]*)$"
							},
							{
								"title": "Block tag",
								"type": "string",
								"enum": [
									"earliest",
									"finalized",
									"safe",
									"latest",
									"pending"
								],
								"description": "xxxxxxx"
							}
						]
					}
				}
			],
			"result": {
				"name": "Block RLP",
				"schema": {
					"title": "hex encoded bytes",
					"type": "string",
					"pattern": "^0x[0-9a-f]*$"
				}
			},
			"examples": [
				{
					"name": "debug_getRawBlock example",
					"params": [
						{
							"name": "Block",
							"value": "0x32026E"
						}
					],
					"result": {
						"name": "Block RLP",
						"value": "xxxxxxx"
					}
				}
			]
		},

I found it missing schema-to-type method in client/core.lisp, it defaults to get "type" of scheme:

(let ((type (gethash "type" schema))

It would be nice to support paring it. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions