ethereum / execution-apis

Collection of APIs provided by Ethereum execution layer clients
Creative Commons Zero v1.0 Universal
955 stars 377 forks source link

open-rpc-generator client build error #572

Closed igor-lukyanov closed 2 months ago

igor-lukyanov commented 2 months ago

Though the config in open-rpc-generator-config.json works fine (it builds target docs) when I run open-rpc-generator generate -t client -l typescript -d openrpc.json -o ./generated-client it returns the following error:

Error: the Subschemas of the schema must use $ref. Inline subschemas are not allowed.
the schema in question: 
{"title":"block hash","type":"string","pattern":"^0x[0-9a-f]{64}$"}
    at CodeGen.refToTitle (/Users/igor/.npm-packages/lib/node_modules/@open-rpc/generator/node_modules/@json-schema-tools/transpiler/build/codegens/codegen.js:91:19)
    at /Users/igor/.npm-packages/lib/node_modules/@open-rpc/generator/node_modules/@json-schema-tools/transpiler/build/codegens/typescript.js:122:50
    at Array.reduce (<anonymous>)
    at Typescript.handleObject (/Users/igor/.npm-packages/lib/node_modules/@open-rpc/generator/node_modules/@json-schema-tools/transpiler/build/codegens/typescript.js:116:51)
    at CodeGen.toIR (/Users/igor/.npm-packages/lib/node_modules/@open-rpc/generator/node_modules/@json-schema-tools/transpiler/build/codegens/codegen.js:140:29)
    at /Users/igor/.npm-packages/lib/node_modules/@open-rpc/generator/node_modules/@json-schema-tools/transpiler/build/codegens/codegen.js:53:32
    at Array.forEach (<anonymous>)
    at CodeGen.transpile (/Users/igor/.npm-packages/lib/node_modules/@open-rpc/generator/node_modules/@json-schema-tools/transpiler/build/codegens/codegen.js:51:18)
    at Transpiler.transpile (/Users/igor/.npm-packages/lib/node_modules/@open-rpc/generator/node_modules/@json-schema-tools/transpiler/build/index.js:140:28)
    at Transpiler.toTypescript (/Users/igor/.npm-packages/lib/node_modules/@open-rpc/generator/node_modules/@json-schema-tools/transpiler/build/index.js:49:21)

Is the spec intended to produce working client/server code? Does anyone use the spec that way? Thanks.

zhelvis commented 2 months ago

@igor-lukyanov just use the generated refs-openrpc.json instead of openrpc.json

igor-lukyanov commented 2 months ago

Thanks @zhelvis, works fine with refs-openrpc.json