Skip to content

Commit

Permalink
863 fixing swagger generation test
Browse files Browse the repository at this point in the history
  • Loading branch information
fahernandez authored and achew22 committed Feb 14, 2019
1 parent 46533c5 commit 2908bf0
Show file tree
Hide file tree
Showing 15 changed files with 289 additions and 292 deletions.
8 changes: 2 additions & 6 deletions examples/clients/abe/a_bit_of_everything_service_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,14 @@ func NewABitOfEverythingServiceApiWithBasePath(basePath string) *ABitOfEverythin
* @param enumValue
* @param pathEnumValue
* @param nestedPathEnumValue
* @param repeatedEnumValue repeated enum value. it is comma-separated in query
* @param enumValueAnnotation Numeric enum description.
* @param repeatedStringAnnotation Repeated string description.
* @return *ExamplepbABitOfEverything
*/
func (a ABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, uint32Value int64, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, nonConventionalNameValue string, enumValue string, pathEnumValue string, nestedPathEnumValue string, repeatedEnumValue []string, enumValueAnnotation string, repeatedStringAnnotation []string) (*ExamplepbABitOfEverything, *APIResponse, error) {
func (a ABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, uint32Value int64, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, nonConventionalNameValue string, enumValue string, pathEnumValue string, nestedPathEnumValue string, enumValueAnnotation string) (*ExamplepbABitOfEverything, *APIResponse, error) {

var localVarHttpMethod = strings.ToUpper("Post")
// create path and map variables
localVarPath := a.Configuration.BasePath + "/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}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{nonConventionalNameValue}/{enum_value}/{path_enum_value}/{nested_path_enum_value}/{repeated_enum_value}/{enum_value_annotation}/{repeated_string_annotation}"
localVarPath := a.Configuration.BasePath + "/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}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{nonConventionalNameValue}/{enum_value}/{path_enum_value}/{nested_path_enum_value}/{enum_value_annotation}"
localVarPath = strings.Replace(localVarPath, "{"+"float_value"+"}", fmt.Sprintf("%v", floatValue), -1)
localVarPath = strings.Replace(localVarPath, "{"+"double_value"+"}", fmt.Sprintf("%v", doubleValue), -1)
localVarPath = strings.Replace(localVarPath, "{"+"int64_value"+"}", fmt.Sprintf("%v", int64Value), -1)
Expand All @@ -88,9 +86,7 @@ func (a ABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float
localVarPath = strings.Replace(localVarPath, "{"+"enum_value"+"}", fmt.Sprintf("%v", enumValue), -1)
localVarPath = strings.Replace(localVarPath, "{"+"path_enum_value"+"}", fmt.Sprintf("%v", pathEnumValue), -1)
localVarPath = strings.Replace(localVarPath, "{"+"nested_path_enum_value"+"}", fmt.Sprintf("%v", nestedPathEnumValue), -1)
localVarPath = strings.Replace(localVarPath, "{"+"repeated_enum_value"+"}", fmt.Sprintf("%v", repeatedEnumValue), -1)
localVarPath = strings.Replace(localVarPath, "{"+"enum_value_annotation"+"}", fmt.Sprintf("%v", enumValueAnnotation), -1)
localVarPath = strings.Replace(localVarPath, "{"+"repeated_string_annotation"+"}", fmt.Sprintf("%v", repeatedStringAnnotation), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
Expand Down
2 changes: 1 addition & 1 deletion examples/clients/echo/api_client.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* examples/proto/examplepb/echo_service.proto
* Echo Service
*
* Echo Service API consists of a single service which returns a message.
*
Expand Down
2 changes: 1 addition & 1 deletion examples/clients/echo/api_response.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* examples/proto/examplepb/echo_service.proto
* Echo Service
*
* Echo Service API consists of a single service which returns a message.
*
Expand Down
2 changes: 1 addition & 1 deletion examples/clients/echo/configuration.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* examples/proto/examplepb/echo_service.proto
* Echo Service
*
* Echo Service API consists of a single service which returns a message.
*
Expand Down
2 changes: 1 addition & 1 deletion examples/clients/echo/echo_service_api.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* examples/proto/examplepb/echo_service.proto
* Echo Service
*
* Echo Service API consists of a single service which returns a message.
*
Expand Down
2 changes: 1 addition & 1 deletion examples/clients/echo/examplepb_embedded.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* examples/proto/examplepb/echo_service.proto
* Echo Service
*
* Echo Service API consists of a single service which returns a message.
*
Expand Down
2 changes: 1 addition & 1 deletion examples/clients/echo/examplepb_simple_message.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* examples/proto/examplepb/echo_service.proto
* Echo Service
*
* Echo Service API consists of a single service which returns a message.
*
Expand Down
2 changes: 2 additions & 0 deletions examples/integration/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func testABEClientCreate(t *testing.T, cl *abe.ABitOfEverythingServiceApi) {
EnumValue: abe.ExamplepbNumericEnum{},
PathEnumValue: abe.PathenumPathEnum{},
NestedPathEnumValue: abe.MessagePathEnumNestedPathEnum{},
EnumValueAnnotation: abe.ExamplepbNumericEnum{},
}
resp, _, err := cl.Create(
want.FloatValue,
Expand All @@ -96,6 +97,7 @@ func testABEClientCreate(t *testing.T, cl *abe.ABitOfEverythingServiceApi) {
want.EnumValue.String(),
want.PathEnumValue.String(),
want.NestedPathEnumValue.String(),
want.EnumValueAnnotation.String(),
)
if err != nil {
t.Errorf("cl.Create(%#v) failed with %v; want success", want, err)
Expand Down
49 changes: 48 additions & 1 deletion examples/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,9 @@ func testABECreate(t *testing.T, port int) {
EnumValue: gw.NumericEnum_ZERO,
PathEnumValue: pathenum.PathEnum_DEF,
NestedPathEnumValue: pathenum.MessagePathEnum_JKL,
EnumValueAnnotation: gw.NumericEnum_ONE,
}
url := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/%f/%f/%d/separator/%d/%d/%d/%d/%v/%s/%d/%d/%d/%d/%d/%s/%s/%s/%s", port, want.FloatValue, want.DoubleValue, want.Int64Value, want.Uint64Value, want.Int32Value, want.Fixed64Value, want.Fixed32Value, want.BoolValue, want.StringValue, want.Uint32Value, want.Sfixed32Value, want.Sfixed64Value, want.Sint32Value, want.Sint64Value, want.NonConventionalNameValue, want.EnumValue, want.PathEnumValue, want.NestedPathEnumValue)
url := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/%f/%f/%d/separator/%d/%d/%d/%d/%v/%s/%d/%d/%d/%d/%d/%s/%s/%s/%s/%s", port, want.FloatValue, want.DoubleValue, want.Int64Value, want.Uint64Value, want.Int32Value, want.Fixed64Value, want.Fixed32Value, want.BoolValue, want.StringValue, want.Uint32Value, want.Sfixed32Value, want.Sfixed64Value, want.Sint32Value, want.Sint64Value, want.NonConventionalNameValue, want.EnumValue, want.PathEnumValue, want.NestedPathEnumValue, want.EnumValueAnnotation)

resp, err := http.Post(url, "application/json", strings.NewReader("{}"))
if err != nil {
Expand Down Expand Up @@ -372,6 +373,29 @@ func testABECreateBody(t *testing.T, port int) {
"a": {Name: "x", Amount: 1},
"b": {Name: "y", Amount: 2},
},
RepeatedEnumAnnotation: []gw.NumericEnum{
gw.NumericEnum_ONE,
gw.NumericEnum_ZERO,
},
EnumValueAnnotation: gw.NumericEnum_ONE,
RepeatedStringAnnotation: []string{
"a",
"b",
},
RepeatedNestedAnnotation: []*gw.ABitOfEverything_Nested{
{
Name: "hoge",
Amount: 10,
},
{
Name: "fuga",
Amount: 20,
},
},
NestedAnnotation: &gw.ABitOfEverything_Nested{
Name: "hoge",
Amount: 10,
},
}
url := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything", port)
var m jsonpb.Marshaler
Expand Down Expand Up @@ -453,6 +477,29 @@ func testABEBulkCreate(t *testing.T, port int) {
Amount: 20,
},
},
RepeatedEnumAnnotation: []gw.NumericEnum{
gw.NumericEnum_ONE,
gw.NumericEnum_ZERO,
},
EnumValueAnnotation: gw.NumericEnum_ONE,
RepeatedStringAnnotation: []string{
"a",
"b",
},
RepeatedNestedAnnotation: []*gw.ABitOfEverything_Nested{
{
Name: "hoge",
Amount: 10,
},
{
Name: "fuga",
Amount: 20,
},
},
NestedAnnotation: &gw.ABitOfEverything_Nested{
Name: "hoge",
Amount: 10,
},
}
var m jsonpb.Marshaler
if err := m.Marshal(w, &want); err != nil {
Expand Down
Loading

0 comments on commit 2908bf0

Please sign in to comment.