core-geth icon indicating copy to clipboard operation
core-geth copied to clipboard

typed rpc responses

Open meowsbits opened this issue 5 years ago • 1 comments
trafficstars

Rel #66

  • [ ] Cases where the return type is ambiguous, like map[string]interface{}, can only get reflected to very basic schema types, like object, 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:

image

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

meowsbits avatar Mar 30 '20 14:03 meowsbits

Rel #90

meowsbits avatar Apr 10 '20 22:04 meowsbits