-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also does a major refactor. This changes the way that Messages are discovered and breaks the generation step down from a monoloithic task into a much easier to test set. Also parses paths and adjusts them so that they match what swagger expects.
- Loading branch information
Showing
8 changed files
with
708 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
syntax = "proto3"; | ||
option go_package = "examplepb"; | ||
package gengo.grpc.gateway.examples.examplepb; | ||
|
||
import "google/api/annotations.proto"; | ||
import "examples/sub/message.proto"; | ||
|
||
message ABitOfEverything { | ||
message Nested { | ||
string name = 1; | ||
uint32 amount = 2; | ||
} | ||
|
||
string uuid = 1; | ||
repeated Nested nested = 2; | ||
float float_value = 3; | ||
double double_value = 4; | ||
int64 int64_value = 5; | ||
uint64 uint64_value = 6; | ||
int32 int32_value = 7; | ||
fixed64 fixed64_value = 8; | ||
fixed32 fixed32_value = 9; | ||
bool bool_value = 10; | ||
string string_value = 11; | ||
// TODO(yugui) add bytes_value | ||
uint32 uint32_value = 13; | ||
// TODO(yugui) add enum_value | ||
sfixed32 sfixed32_value = 15; | ||
sfixed64 sfixed64_value = 16; | ||
sint32 sint32_value = 17; | ||
sint64 sint64_value = 18; | ||
} | ||
|
||
message EmptyMessage { | ||
} | ||
|
||
message IdMessage { | ||
string uuid = 1; | ||
} | ||
|
||
service ABitOfEverythingService { | ||
rpc Create(ABitOfEverything) returns (ABitOfEverything) { | ||
option (google.api.http) = { | ||
post: "/v1/example/a_bit_of_everything/{float_value}/{double_value}/{int64_value}/separator/{uint64_value}/{int32_value}/{fixed64_value}/{fixed32_value}/{bool_value}/{string_value=strprefix/*}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}" | ||
}; | ||
} | ||
rpc CreateBody(ABitOfEverything) returns (ABitOfEverything) { | ||
option (google.api.http) = { | ||
post: "/v1/example/a_bit_of_everything" | ||
body: "*" | ||
}; | ||
} | ||
// TODO: Refering to an empty message breaks the swagger editor right now. Tracking bug: https://github.com/swagger-api/swagger-spec/issues/452 | ||
//rpc BulkCreate(ABitOfEverything) returns (EmptyMessage) { | ||
// option (google.api.http) = { | ||
// post: "/v1/example/a_bit_of_everything/bulk" | ||
// body: "*" | ||
// }; | ||
//} | ||
rpc Lookup(IdMessage) returns (ABitOfEverything) { | ||
option (google.api.http) = { | ||
get: "/v1/example/a_bit_of_everything/{uuid}" | ||
}; | ||
} | ||
rpc List(EmptyMessage) returns (ABitOfEverything) { | ||
option (google.api.http) = { | ||
get: "/v1/example/a_bit_of_everything" | ||
}; | ||
} | ||
rpc Update(ABitOfEverything) returns (EmptyMessage) { | ||
option (google.api.http) = { | ||
put: "/v1/example/a_bit_of_everything/{uuid}" | ||
body: "*" | ||
}; | ||
} | ||
rpc Delete(IdMessage) returns (EmptyMessage) { | ||
option (google.api.http) = { | ||
delete: "/v1/example/a_bit_of_everything/{uuid}" | ||
}; | ||
} | ||
rpc Echo(gengo.grpc.gateway.examples.sub.StringMessage) returns (gengo.grpc.gateway.examples.sub.StringMessage) { | ||
option (google.api.http) = { | ||
get: "/v1/example/a_bit_of_everything/echo/{value}" | ||
//additional_bindings { | ||
// post: "/v2/example/echo" | ||
// body: "value" | ||
//} | ||
//additional_bindings { | ||
// get: "/v2/example/echo" | ||
//} | ||
}; | ||
} | ||
rpc BulkEcho(gengo.grpc.gateway.examples.sub.StringMessage) returns (gengo.grpc.gateway.examples.sub.StringMessage) { | ||
option (google.api.http) = { | ||
post: "/v1/example/a_bit_of_everything/echo" | ||
body: "*" | ||
}; | ||
} | ||
} |
Oops, something went wrong.