zenrpc
zenrpc copied to clipboard
Write SMD schema to file
It is a bit inconvenient to expose SMD schema only as an http endpoint.
For example, you might have other tools that work with SMD schema and you could not use them automatically with zenrpc without SMD schema in a file.
Its can done manually ,I implemented a cli subcmd to generate the smd file manaually though cobra for ci usage
simplified version
rpc := zenrpc.NewServer(zenrpc.Options{ExposeSMD: true})
rpc.Register("user", UserService{})
rpc.Register("data", DataService{})
data, err := json.MarshalIndent(rpcServer.SMD(), "", "\t")
if err != nil {
panic(err)
return
}
err = ioutil.WriteFile("smd.json", data, 0644)
if err != nil {
panic(err)
return
}