ethereum / execution-apis

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

Can't generate a source code using open-rpc-generator #166

Closed odanado closed 2 years ago

odanado commented 2 years ago

I tried to use the @open-rpc/generator to generate the source code for the client. As a result, I got the following error.

$ yarn open-rpc-generator generate -d execution-apis/openrpc.json -t client -l typescript 
yarn run v1.22.17
$ /Users/odan/source/github.com/odan-sandbox/ethereum-open-rpc-generator-sandbox/node_modules/.bin/open-rpc-generator generate -d execution-apis/openrpc.json -t client -l typescript
There was error at generator runtime:
Error: the Subschemas of the schema must use $ref. Inline subschemas are not allowed.
the schema in question: 
{"title":"from","type":"string","pattern":"^0x[0-9,a-f,A-F]{40}$"}
    at Typescript.CodeGen.refToTitle (/Users/odan/source/github.com/odan-sandbox/ethereum-open-rpc-generator-sandbox/node_modules/@json-schema-tools/transpiler/build/codegens/codegen.js:87:19)
    at /Users/odan/source/github.com/odan-sandbox/ethereum-open-rpc-generator-sandbox/node_modules/@json-schema-tools/transpiler/build/codegens/typescript.js:118:50
    at Array.reduce (<anonymous>)
    at Typescript.handleObject (/Users/odan/source/github.com/odan-sandbox/ethereum-open-rpc-generator-sandbox/node_modules/@json-schema-tools/transpiler/build/codegens/typescript.js:112:51)
    at Typescript.CodeGen.toIR (/Users/odan/source/github.com/odan-sandbox/ethereum-open-rpc-generator-sandbox/node_modules/@json-schema-tools/transpiler/build/codegens/codegen.js:136:29)
    at /Users/odan/source/github.com/odan-sandbox/ethereum-open-rpc-generator-sandbox/node_modules/@json-schema-tools/transpiler/build/codegens/codegen.js:49:32
    at Array.forEach (<anonymous>)
    at Typescript.CodeGen.transpile (/Users/odan/source/github.com/odan-sandbox/ethereum-open-rpc-generator-sandbox/node_modules/@json-schema-tools/transpiler/build/codegens/codegen.js:47:18)
    at Transpiler.transpile (/Users/odan/source/github.com/odan-sandbox/ethereum-open-rpc-generator-sandbox/node_modules/@json-schema-tools/transpiler/build/index.js:140:28)
    at Transpiler.toTypescript (/Users/odan/source/github.com/odan-sandbox/ethereum-open-rpc-generator-sandbox/node_modules/@json-schema-tools/transpiler/build/index.js:49:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Reproduction repository: https://github.com/odan-sandbox/ethereum-open-rpc-generator-sandbox

lightclient commented 2 years ago

The specs have changed quite a bit since this issue, and we now have some CI checks using some open-rpc tools to verify the spec. If you're still having a problem, please open a new issue.

jfkfrb commented 9 months ago

i just ran into this...

  ~/Code/node/api   main !3 ?1 ❯ open-rpc-generator generate -t server  -l typescript -n eth-node -d execution-apis/openrpc.json -o ./generated-server         14:56:31
(node:17436) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
[
  'One of the provided schemas is using an array for the field type. This is not',
  'advisable, as oneOf is the equivalent. In (far) future releases, type as an array',
  'support will be deprecated.'
]
[
  'One of the provided schemas is using an array for the field type. This is not',
  'advisable, as oneOf is the equivalent. In (far) future releases, type as an array',
  'support will be deprecated.'
]
There was error at generator runtime:
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/l1jxk15/.config/yarn/global/node_modules/@json-schema-tools/transpiler/build/codegens/codegen.js:91:19)
    at /Users/l1jxk15/.config/yarn/global/node_modules/@json-schema-tools/transpiler/build/codegens/typescript.js:122:50
    at Array.reduce (<anonymous>)
    at Typescript.handleObject (/Users/l1jxk15/.config/yarn/global/node_modules/@json-schema-tools/transpiler/build/codegens/typescript.js:116:51)
    at CodeGen.toIR (/Users/l1jxk15/.config/yarn/global/node_modules/@json-schema-tools/transpiler/build/codegens/codegen.js:140:29)
    at /Users/l1jxk15/.config/yarn/global/node_modules/@json-schema-tools/transpiler/build/codegens/codegen.js:53:32
    at Array.forEach (<anonymous>)
    at CodeGen.transpile (/Users/l1jxk15/.config/yarn/global/node_modules/@json-schema-tools/transpiler/build/codegens/codegen.js:51:18)
    at Transpiler.transpile (/Users/l1jxk15/.config/yarn/global/node_modules/@json-schema-tools/transpiler/build/index.js:140:28)
    at Transpiler.toTypescript (/Users/l1jxk15/.config/yarn/global/node_modules/@json-schema-tools/transpiler/build/index.js:49:21)