tatethurston / TwirpScript

A protobuf RPC framework for JavaScript and TypeScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSON Object is not generated correctly for nested proto message

yiplee opened this issue · comments

haberdasher.proto

syntax = "proto3";

// Haberdasher service makes hats for clients.
service Haberdasher {
  // MakeHat produces a hat of mysterious, randomly-selected color!
  rpc MakeHat(Req.MakeHat) returns (Hat);
}

// Size of a Hat, in inches.
message Req {
    message MakeHat {
        int32 inches = 1; // must be > 0
    }
}

// A Hat is a piece of headwear made by a Haberdasher.
message Hat {
  int32 inches = 1;
  string color = 2; // anything but "invisible"
  string name = 3; // i.e. "bowler"
}

haberdasher.pb.js

/**
 * MakeHat produces a hat of mysterious, randomly-selected color!
 */
export async function MakeHatJSON(makeHat, config) {
  const response = await JSONrequest(
    "/Haberdasher/MakeHat",
    Req.MakeHatJSON.encode(makeHat),
    config
  );
  return HatJSON.decode(response);
}

Req.MakeHatJSON is missing from the generated file.

Hey @yiplee, thanks for reporting this. I've fixed the issue in #178 and published v0.0.59