core-geth
core-geth copied to clipboard
typed rpc responses
trafficstars
Rel #66
- [ ] Cases where the return type is ambiguous, like
map[string]interface{}, can only get reflected to very basic schema types, likeobject, which doesn't provide much value for API definition consumers. Sometimes this is done as a way to get desired json marshaling properties. A good example of this is as follows.
// GetHeaderByHash returns the requested header by hash.
func (s *PublicBlockChainAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) map[string]interface{} {
header, _ := s.b.HeaderByHash(ctx, hash)
if header != nil {
return s.rpcMarshalHeader(header)
}
return nil
}
which implements eth_getHeaderByHash, and generates sparse documentation like:

This can be fixed by implementing a type/marshaling sheme for these structures that can be parsed by the jsonschema package.
Rel #90