Skip to content

Commit

Permalink
[Go]URLEncode path parameters (#3643)
Browse files Browse the repository at this point in the history
* URLEncode path parameters

* update samples

* Use correct module naming
  • Loading branch information
kraney authored and wing328 committed Aug 16, 2019
1 parent 5182955 commit b83fe0c
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}

// create path and map variables
localVarPath := a.client.cfg.BasePath + "{{{path}}}"{{#pathParams}}
localVarPath = strings.Replace(localVarPath, "{"+"{{baseName}}"+"}", fmt.Sprintf("%v", {{paramName}}), -1){{/pathParams}}
localVarPath = strings.Replace(localVarPath, "{"+"{{baseName}}"+"}", url.QueryEscape(fmt.Sprintf("%v", {{paramName}})), -1){{/pathParams}}

localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx _context.Context{{#hasParams

// create path and map variables
localVarPath := a.client.cfg.BasePath + "{{{path}}}"{{#pathParams}}
localVarPath = strings.Replace(localVarPath, "{"+"{{baseName}}"+"}", fmt.Sprintf("%v", {{paramName}}), -1){{/pathParams}}
localVarPath = strings.Replace(localVarPath, "{"+"{{baseName}}"+"}", _neturl.QueryEscape(fmt.Sprintf("%v", {{paramName}})), -1){{/pathParams}}

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
Expand Down
10 changes: 5 additions & 5 deletions samples/client/petstore/go/go-petstore-withXml/api_pet.go

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

4 changes: 2 additions & 2 deletions samples/client/petstore/go/go-petstore-withXml/api_store.go

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

6 changes: 3 additions & 3 deletions samples/client/petstore/go/go-petstore-withXml/api_user.go

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

10 changes: 5 additions & 5 deletions samples/client/petstore/go/go-petstore/api_pet.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (a *PetApiService) DeletePet(ctx _context.Context, petId int64, localVarOpt

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/pet/{petId}"
localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", _neturl.QueryEscape(fmt.Sprintf("%v", petId)), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
Expand Down Expand Up @@ -365,7 +365,7 @@ func (a *PetApiService) GetPetById(ctx _context.Context, petId int64) (Pet, *_ne

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/pet/{petId}"
localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", _neturl.QueryEscape(fmt.Sprintf("%v", petId)), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
Expand Down Expand Up @@ -538,7 +538,7 @@ func (a *PetApiService) UpdatePetWithForm(ctx _context.Context, petId int64, loc

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/pet/{petId}"
localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", _neturl.QueryEscape(fmt.Sprintf("%v", petId)), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
Expand Down Expand Up @@ -621,7 +621,7 @@ func (a *PetApiService) UploadFile(ctx _context.Context, petId int64, localVarOp

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/pet/{petId}/uploadImage"
localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", _neturl.QueryEscape(fmt.Sprintf("%v", petId)), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
Expand Down Expand Up @@ -734,7 +734,7 @@ func (a *PetApiService) UploadFileWithRequiredFile(ctx _context.Context, petId i

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/fake/{petId}/uploadImageWithRequiredFile"
localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", _neturl.QueryEscape(fmt.Sprintf("%v", petId)), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/go/go-petstore/api_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (a *StoreApiService) DeleteOrder(ctx _context.Context, orderId string) (*_n

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/store/order/{order_id}"
localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", fmt.Sprintf("%v", orderId), -1)
localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", _neturl.QueryEscape(fmt.Sprintf("%v", orderId)), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
Expand Down Expand Up @@ -209,7 +209,7 @@ func (a *StoreApiService) GetOrderById(ctx _context.Context, orderId int64) (Ord

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/store/order/{order_id}"
localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", fmt.Sprintf("%v", orderId), -1)
localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", _neturl.QueryEscape(fmt.Sprintf("%v", orderId)), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
Expand Down
6 changes: 3 additions & 3 deletions samples/client/petstore/go/go-petstore/api_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (a *UserApiService) DeleteUser(ctx _context.Context, username string) (*_ne

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/user/{username}"
localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", _neturl.QueryEscape(fmt.Sprintf("%v", username)), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
Expand Down Expand Up @@ -312,7 +312,7 @@ func (a *UserApiService) GetUserByName(ctx _context.Context, username string) (U

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/user/{username}"
localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", _neturl.QueryEscape(fmt.Sprintf("%v", username)), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
Expand Down Expand Up @@ -552,7 +552,7 @@ func (a *UserApiService) UpdateUser(ctx _context.Context, username string, body

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/user/{username}"
localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", _neturl.QueryEscape(fmt.Sprintf("%v", username)), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
Expand Down

0 comments on commit b83fe0c

Please sign in to comment.