Skip to content

Commit

Permalink
node: fix discovery external docs URL
Browse files Browse the repository at this point in the history
Merge pull request #309 from etclabscore/fix/discovery-externaldocs-url
  • Loading branch information
meowsbits authored Jan 20, 2021
2 parents f63ac82 + 735fd88 commit c3a0b59
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion node/openrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ var sharedMetaRegisterer = &go_openrpc_reflect.MetaT{
return info
},
GetExternalDocsFn: func() (exdocs *meta_schema.ExternalDocumentationObject) {
return nil // FIXME
exdocs = &meta_schema.ExternalDocumentationObject{}
description := "ETC Labs Documentation"
exdocs.Description = (*meta_schema.ExternalDocumentationObjectDescription)(&description)
url := "https://etclabscore.github.io/core-geth/"
exdocs.Url = (*meta_schema.ExternalDocumentationObjectUrl)(&url)
return exdocs
},
}

Expand Down Expand Up @@ -182,6 +187,21 @@ func newOpenRPCDocument() *go_openrpc_reflect.Document {
return go_openrpc_reflect.EthereumReflector.GetContentDescriptorRequired(r, m, field)
}

appReflector.FnGetMethodExternalDocs = func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.ExternalDocumentationObject, error) {
standard := go_openrpc_reflect.StandardReflector
got, err := standard.GetMethodExternalDocs(r, m, funcDecl)
if err != nil {
return nil, err
}
if got.Url == nil {
return got, nil
}
// Replace links to go-ethereum repo with current core-geth one
newLink := meta_schema.ExternalDocumentationObjectUrl(strings.Replace(string(*got.Url), "github.com/ethereum/go-ethereum", "github.com/etclabscore/core-geth", 1))
got.Url = &newLink
return got, nil
}

// Finally, register the configured reflector to the document.
d.WithReflector(appReflector)
return d
Expand Down

0 comments on commit c3a0b59

Please sign in to comment.