Skip to content

Commit

Permalink
[Golang] Allow retrieving the underlying configuration for APIClient (#…
Browse files Browse the repository at this point in the history
…3976)

* Allow retrieving the underlying configuration for APIClient

  - Needed for dynamically changing the underlying implementations and
    for testing
  - Fixes #1321 and #3412

* Added go-petstore-withXml changes suggested by circleci

* Add caution note about modifying configuration while live
  • Loading branch information
arvindth authored and wing328 committed Oct 21, 2019
1 parent fefa327 commit 893f16a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ func (c *APIClient) ChangeBasePath(path string) {
c.cfg.BasePath = path
}

// Allow modification of underlying config for alternate implementations and testing
// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior
func (c *APIClient) GetConfig() *Configuration {
return c.cfg
}

// prepareRequest build the request
func (c *APIClient) prepareRequest(
ctx context.Context,
Expand Down
6 changes: 6 additions & 0 deletions samples/client/petstore/go/go-petstore-withXml/client.go

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

6 changes: 6 additions & 0 deletions samples/client/petstore/go/go-petstore/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ func (c *APIClient) ChangeBasePath(path string) {
c.cfg.BasePath = path
}

// Allow modification of underlying config for alternate implementations and testing
// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior
func (c *APIClient) GetConfig() *Configuration {
return c.cfg
}

// prepareRequest build the request
func (c *APIClient) prepareRequest(
ctx context.Context,
Expand Down
6 changes: 6 additions & 0 deletions samples/openapi3/client/petstore/go/go-petstore/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ func (c *APIClient) ChangeBasePath(path string) {
c.cfg.BasePath = path
}

// Allow modification of underlying config for alternate implementations and testing
// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior
func (c *APIClient) GetConfig() *Configuration {
return c.cfg
}

// prepareRequest build the request
func (c *APIClient) prepareRequest(
ctx context.Context,
Expand Down

0 comments on commit 893f16a

Please sign in to comment.