40ants / 40ants/openrpc

Support parsing `oneof` and `anyof` in params.schema

Offen
#33 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Common Lisp
Sterne
34
Forks
5
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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: https://github.com/40ants/openrpc/blob/d951a3f3d08c02aeb9a33f8e7282266dad5b0b70/client/core.lisp#L131

It would be nice to support paring it. Thanks!

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

The issue points to client/core.lisp line 131 where schema-to-type method is missing. Look at the OpenRPC spec for 'oneOf' and 'anyOf' handling. The task is to extend the schema parsing logic to support these keywords, likely modifying the type generation. Check existing tests for schema parsing to understand the pattern and add new ones for the union types.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
json
Bereich
api, backend-api-design
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.