Skip to content

Commit

Permalink
863 adding swagger annotation support for enum, repeated enum, nested…
Browse files Browse the repository at this point in the history
… object, repeated nested object and repeated primitive fields
  • Loading branch information
fahernandez authored and achew22 committed Feb 14, 2019
1 parent c3923b1 commit 1afb80b
Show file tree
Hide file tree
Showing 15 changed files with 602 additions and 234 deletions.
30 changes: 27 additions & 3 deletions examples/clients/abe/a_bit_of_everything_service_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ func NewABitOfEverythingServiceApiWithBasePath(basePath string) *ABitOfEverythin
* @param enumValue
* @param pathEnumValue
* @param nestedPathEnumValue
* @param repeatedEnumValue repeated enum value. it is comma-separated in query
* @param repeatedEnumValueAnnotation Repeated numeric enum description.
* @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) (*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, repeatedEnumValue []string, repeatedEnumValueAnnotation []string, enumValueAnnotation string, repeatedStringAnnotation []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}"
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}/{repeated_enum_value_annotation}/{enum_value_annotation}/{repeated_string_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 @@ -85,6 +89,10 @@ 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, "{"+"repeated_enum_value_annotation"+"}", fmt.Sprintf("%v", repeatedEnumValueAnnotation), -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 Expand Up @@ -547,9 +555,15 @@ func (a ABitOfEverythingServiceApi) GetMessageWithBody(id string, body Examplepb
* @param nonConventionalNameValue
* @param timestampValue
* @param repeatedEnumValue repeated enum value. it is comma-separated in query. - ZERO: ZERO means 0 - ONE: ONE means 1
* @param repeatedEnumValueAnnotation Repeated numeric enum title. Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1
* @param enumValueAnnotation Numeric enum title. Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1
* @param repeatedStringAnnotation Repeated string title. Repeated string description.
* @param nestedAnnotationName name is nested field.
* @param nestedAnnotationAmount
* @param nestedAnnotationOk - FALSE: FALSE is false. - TRUE: TRUE is true.
* @return *interface{}
*/
func (a ABitOfEverythingServiceApi) GetQuery(uuid string, floatValue float32, singleNestedName string, singleNestedAmount int64, singleNestedOk string, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, bytesValue string, uint32Value int64, enumValue string, pathEnumValue string, nestedPathEnumValue string, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, repeatedStringValue []string, oneofString string, nonConventionalNameValue string, timestampValue time.Time, repeatedEnumValue []string) (*interface{}, *APIResponse, error) {
func (a ABitOfEverythingServiceApi) GetQuery(uuid string, floatValue float32, singleNestedName string, singleNestedAmount int64, singleNestedOk string, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, bytesValue string, uint32Value int64, enumValue string, pathEnumValue string, nestedPathEnumValue string, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, repeatedStringValue []string, oneofString string, nonConventionalNameValue string, timestampValue time.Time, repeatedEnumValue []string, repeatedEnumValueAnnotation []string, enumValueAnnotation string, repeatedStringAnnotation []string, nestedAnnotationName string, nestedAnnotationAmount int64, nestedAnnotationOk string) (*interface{}, *APIResponse, error) {

var localVarHttpMethod = strings.ToUpper("Get")
// create path and map variables
Expand Down Expand Up @@ -596,6 +610,16 @@ func (a ABitOfEverythingServiceApi) GetQuery(uuid string, floatValue float32, si
var repeatedEnumValueCollectionFormat = "csv"
localVarQueryParams.Add("repeated_enum_value", a.Configuration.APIClient.ParameterToString(repeatedEnumValue, repeatedEnumValueCollectionFormat))

var repeatedEnumValueAnnotationCollectionFormat = "csv"
localVarQueryParams.Add("repeated_enum_value_annotation", a.Configuration.APIClient.ParameterToString(repeatedEnumValueAnnotation, repeatedEnumValueAnnotationCollectionFormat))

localVarQueryParams.Add("enum_value_annotation", a.Configuration.APIClient.ParameterToString(enumValueAnnotation, ""))
var repeatedStringAnnotationCollectionFormat = "csv"
localVarQueryParams.Add("repeated_string_annotation", a.Configuration.APIClient.ParameterToString(repeatedStringAnnotation, repeatedStringAnnotationCollectionFormat))

localVarQueryParams.Add("nested_annotation.name", a.Configuration.APIClient.ParameterToString(nestedAnnotationName, ""))
localVarQueryParams.Add("nested_annotation.amount", a.Configuration.APIClient.ParameterToString(nestedAnnotationAmount, ""))
localVarQueryParams.Add("nested_annotation.ok", a.Configuration.APIClient.ParameterToString(nestedAnnotationOk, ""))

// to determine the Content-Type header
localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", }
Expand Down
15 changes: 15 additions & 0 deletions examples/clients/abe/examplepb_a_bit_of_everything.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,19 @@ type ExamplepbABitOfEverything struct {
TimestampValue time.Time `json:"timestamp_value,omitempty"`

RepeatedEnumValue []ExamplepbNumericEnum `json:"repeated_enum_value,omitempty"`

// Repeated numeric enum description.
RepeatedEnumValueAnnotation []ExamplepbNumericEnum `json:"repeated_enum_value_annotation,omitempty"`

// Numeric enum description.
EnumValueAnnotation ExamplepbNumericEnum `json:"enum_value_annotation,omitempty"`

// Repeated string description.
RepeatedStringAnnotation []string `json:"repeated_string_annotation,omitempty"`

// Repeated nested object description.
RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeated_nested_annotation,omitempty"`

// Nested object description.
NestedAnnotation ABitOfEverythingNested `json:"nested_annotation,omitempty"`
}
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 @@
/*
* Echo Service
* examples/proto/examplepb/echo_service.proto
*
* 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 @@
/*
* Echo Service
* examples/proto/examplepb/echo_service.proto
*
* 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 @@
/*
* Echo Service
* examples/proto/examplepb/echo_service.proto
*
* 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 @@
/*
* Echo Service
* examples/proto/examplepb/echo_service.proto
*
* 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 @@
/*
* Echo Service
* examples/proto/examplepb/echo_service.proto
*
* 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 @@
/*
* Echo Service
* examples/proto/examplepb/echo_service.proto
*
* Echo Service API consists of a single service which returns a message.
*
Expand Down
Loading

0 comments on commit 1afb80b

Please sign in to comment.