Comments (9)
the issues involved here:
- Generated code's return value is sometimes missing its generic type.
- Tries to add derive/serialize to foreign types
- multiple duplicate
use
statements
from generator.
Looked into the generated code, so here are some more specifics:
Multiple duplicate use statements
use $path
gets generated in the header for every use of the $path
in the type definitions, i.e for every sub-schema.
Multiple definitions of the same type:
pub enum TransactionElement {
String(String),
TransactionClass(TransactionClass),
}
/* ... */
pub enum TransactionElement {
String(String),
TransactionClass(TransactionClass),
}
Seems like the same issue as above, but with some types being regenerated if used twice in different methods?
Possible solution 1: deduplicate typings if they're the same
Possible solution 2: threat the whole schema as the whole when generating typings
Possible solution 3 (hacky): prefix the types with the method they relate to, or enclose them in modules like
pub mod method_name {
/* method types */
}
Though the solution 3 is very dirty in terms of resulting API, as types related to different methods aren't compatible out of the box.
Tries to add derive/serialize to foreign types
Not present after fixing other errors
Generated code's return value is sometimes missing its generic type.
For the following result
schemas the generator fails to derive the correct return type:
"result": {
"name": "",
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Log"
}
}
}
"result": {
"name": "",
"schema": {
"$ref": "#/components/schemas/BlockRLP"
}
}
"result": {
"name": "",
"schema": {
"description": "",
"$ref": "#/components/schemas/Bytes"
}
}
The common issue here is the "name": ""
which is causing troubles, as far as `I can see.
Possible solution: fallback to the schema name if name's not present?
Missing types
EndHash
type isn't present in type definitions, and it's a pretty problematic type as in different methods it has different characteristics, even though it is named identically.
Possible solutions: prefix the method name to the ambiguous types, no idea why there's no definition at all though, maybe generator couldn't decide which one of the multiple variants of EndHash
to generate.
Tests mis-generation for types with common prefix
There's the following list of functions:
pub fn debug_traceBlock(&mut self, blockRLP: BlockRlp) -> RpcRequest<StackTrace>;
pub fn debug_traceBlockByHash(&mut self, blockHash: BlockHash) -> RpcRequest<Trace>;
pub fn debug_traceBlockByNumber(&mut self, blockNumber: BlockNumber) -> RpcRequest<Trace>;
pub fn debug_traceBlockFromFile(&mut self, filename: Filename) -> RpcRequest<Bytes>;
The generated test for debug_traceBlock
tries to pass 4 arguments (BlockRlp
, BlockHash
, BlockNumber
, Filename
) as the arguments.
Seems like arguments list for foo
contains all arguments for any foo*
combined.
from generator.
Actually about the Generated code's return value is sometimes missing its generic type.
I'd propose not using the name
at all, if the schema is defined as just a single ref
statement.
It cripples the API a lot: two identical structs with just different names wouldn't be interchangeable in Rust, so say there are 2 methods:
fn one() -> SameType1
fn two(arg: SameType2)
The SameType1
and SameType2
have common schema and different names, therefore user wouldn't be able to do two(one())
call without manually converting the same type into another same type:
let st1 = one();
let st2 = SameType2 {
a: st1.a,
b: st1.b,
c: st1.c,
...
};
two(st2);
from generator.
@mersinvald names shouldn't be empty, I'll fix that up in the openrpc.json
for multi-geth
from generator.
@mersinvald the openrpc.json
is all fixed up and filled out, latest is here: https://raw.githubusercontent.com/etclabscore/multi-geth/feat/openrpc-discover/rpc/openrpc.json
from generator.
related to #169
from generator.
@shanejonas 404 at https://raw.githubusercontent.com/etclabscore/multi-geth/feat/openrpc-discover/rpc/openrpc.json
from generator.
this openrpc file lives here now
https://github.com/etclabscore/ethereum-json-rpc-specification
from generator.
fixed!
from generator.
Related Issues (20)
- error on npm install HOT 1
- Broken typescript generated, when using dots in method names HOT 6
- Error building generated gatsby docs HOT 1
- Configurable clients HOT 5
- Update generated JS client to latest npm packages & node LTS HOT 1
- Update dependencies and node version on docs generator HOT 1
- Error when using generator wtih: open-rpc-generator generate HOT 1
- Add explicit outputDir options per component HOT 2
- Running open-rpc-generator generate -c overwrites package.json HOT 1
- params by-name keys are incorrectly mapped HOT 1
- Additional Properties Typing specificity HOT 1
- FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory HOT 6
- New Language Support: Markdown
- Option to only include api playground in generated docs
- Add java client generator
- Add python client (modern using typing)
- Allow injection or configuration of transport client HOT 1
- Lean Clients
- "RangeError: Maximum call stack size exceeded" when adding rpc.discover method HOT 1
- Think about adding a github discussion board
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from generator.