Skip to content

Commit

Permalink
Added new rpc to bit of everything service to demonstrate missing mes…
Browse files Browse the repository at this point in the history
…sage issue
  • Loading branch information
warmans committed Dec 18, 2017
1 parent e3aeda3 commit 00e5a4f
Show file tree
Hide file tree
Showing 9 changed files with 377 additions and 103 deletions.
64 changes: 64 additions & 0 deletions examples/clients/abe/a_bit_of_everything_service_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,70 @@ func (a ABitOfEverythingServiceApi) Echo3(value string) (*SubStringMessage, *API
return successPayload, localVarAPIResponse, err
}

/**
*
*
* @param id
* @param body
* @return *ProtobufEmpty
*/
func (a ABitOfEverythingServiceApi) GetMessageWithBody(id string, body ExamplepbBody) (*ProtobufEmpty, *APIResponse, error) {

var localVarHttpMethod = strings.ToUpper("Post")
// create path and map variables
localVarPath := a.Configuration.BasePath + "/v2/example/withbody/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := make(map[string]string)
var localVarPostBody interface{}
var localVarFileName string
var localVarFileBytes []byte
// add default headers if any
for key := range a.Configuration.DefaultHeader {
localVarHeaderParams[key] = a.Configuration.DefaultHeader[key]
}

// to determine the Content-Type header
localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", }

// set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string{
"application/json",
"application/x-foo-mime",
}

// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}
// body params
localVarPostBody = &body
var successPayload = new(ProtobufEmpty)
localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)

var localVarURL, _ = url.Parse(localVarPath)
localVarURL.RawQuery = localVarQueryParams.Encode()
var localVarAPIResponse = &APIResponse{Operation: "GetMessageWithBody", Method: localVarHttpMethod, RequestURL: localVarURL.String()}
if localVarHttpResponse != nil {
localVarAPIResponse.Response = localVarHttpResponse.RawResponse
localVarAPIResponse.Payload = localVarHttpResponse.Body()
}

if err != nil {
return successPayload, localVarAPIResponse, err
}
err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload)
return successPayload, localVarAPIResponse, err
}

/**
*
*
Expand Down
2 changes: 1 addition & 1 deletion examples/clients/abe/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"strings"
"net/url"
"io/ioutil"
"github.com/go-resty/resty"
"gopkg.in/go-resty/resty.v0"
)

type APIClient struct {
Expand Down
16 changes: 16 additions & 0 deletions examples/clients/abe/examplepb_body.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* A Bit of Everything
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 1.0
* Contact: [email protected]
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/

package abe

type ExamplepbBody struct {

Name string `json:"name,omitempty"`
}
2 changes: 1 addition & 1 deletion examples/clients/echo/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"strings"
"net/url"
"io/ioutil"
"github.com/go-resty/resty"
"gopkg.in/go-resty/resty.v0"
)

type APIClient struct {
Expand Down
282 changes: 181 additions & 101 deletions examples/examplepb/a_bit_of_everything.pb.go

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions examples/examplepb/a_bit_of_everything.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions examples/examplepb/a_bit_of_everything.proto
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ message ABitOfEverything {
repeated NumericEnum repeated_enum_value = 28;
}

message Body {
string name = 1;
}

message MessageWithBody {
string id = 1;
Body data = 2;
}


// NumericEnum is one or zero.
enum NumericEnum {
// ZERO means 0
Expand Down Expand Up @@ -194,6 +204,12 @@ service ABitOfEverythingService {
get: "/v2/example/timeout",
};
}
rpc GetMessageWithBody(MessageWithBody) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/v2/example/withbody/{id}",
body: "data"
};
}
}

service AnotherServiceWithNoBindings {
Expand Down
32 changes: 32 additions & 0 deletions examples/examplepb/a_bit_of_everything.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,38 @@
"ABitOfEverythingService"
]
}
},
"/v2/example/withbody/{id}": {
"post": {
"operationId": "GetMessageWithBody",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/protobufEmpty"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/examplepbBody"
}
}
],
"tags": [
"ABitOfEverythingService"
]
}
}
},
"definitions": {
Expand Down
2 changes: 2 additions & 0 deletions examples/examplepb/echo_service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 00e5a4f

Please sign in to comment.