mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-08 08:30:56 +00:00
added Configuration struct for GO
This commit is contained in:
parent
d84f848831
commit
316c2cb136
@ -131,6 +131,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
supportingFiles.add(new SupportingFile("configuration.mustache", packageName, "Configuration.go"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,18 +12,22 @@ import (
|
||||
)
|
||||
|
||||
type {{classname}} struct {
|
||||
basePath string
|
||||
Configuration Configuration
|
||||
}
|
||||
|
||||
func New{{classname}}() *{{classname}}{
|
||||
configuration := NewConfiguration()
|
||||
return &{{classname}} {
|
||||
basePath: "{{basePath}}",
|
||||
Configuration: *configuration,
|
||||
}
|
||||
}
|
||||
|
||||
func New{{classname}}WithBasePath(basePath string) *{{classname}}{
|
||||
configuration := NewConfiguration()
|
||||
configuration.BasePath = basePath
|
||||
|
||||
return &{{classname}} {
|
||||
basePath: basePath,
|
||||
Configuration: *configuration,
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +41,7 @@ func New{{classname}}WithBasePath(basePath string) *{{classname}}{
|
||||
//func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) {
|
||||
func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) {
|
||||
|
||||
_sling := sling.New().{{httpMethod}}(a.basePath)
|
||||
_sling := sling.New().{{httpMethod}}(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "{{basePathWithoutHost}}{{path}}"
|
||||
|
@ -0,0 +1,25 @@
|
||||
package {{packageName}}
|
||||
|
||||
import (
|
||||
|
||||
)
|
||||
|
||||
type Configuration struct {
|
||||
UserName string `json:"userName,omitempty"`
|
||||
ApiKey string `json:"apiKey,omitempty"`
|
||||
Debug bool `json:"debug,omitempty"`
|
||||
DebugFile string `json:"debugFile,omitempty"`
|
||||
OAuthToken string `json:"oAuthToken,omitempty"`
|
||||
Timeout int `json:"timeout,omitempty"`
|
||||
BasePath string `json:"basePath,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Scheme string `json:"scheme,omitempty"`
|
||||
}
|
||||
|
||||
func NewConfiguration() *Configuration {
|
||||
return &Configuration{
|
||||
BasePath: "{{basePath}}",
|
||||
UserName: "",
|
||||
Debug: false,
|
||||
}
|
||||
}
|
25
samples/client/petstore/go/swagger/Configuration.go
Normal file
25
samples/client/petstore/go/swagger/Configuration.go
Normal file
@ -0,0 +1,25 @@
|
||||
package swagger
|
||||
|
||||
import (
|
||||
|
||||
)
|
||||
|
||||
type Configuration struct {
|
||||
UserName string `json:"userName,omitempty"`
|
||||
ApiKey string `json:"apiKey,omitempty"`
|
||||
Debug bool `json:"debug,omitempty"`
|
||||
DebugFile string `json:"debugFile,omitempty"`
|
||||
OAuthToken string `json:"oAuthToken,omitempty"`
|
||||
Timeout int `json:"timeout,omitempty"`
|
||||
BasePath string `json:"basePath,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Scheme string `json:"scheme,omitempty"`
|
||||
}
|
||||
|
||||
func NewConfiguration() *Configuration {
|
||||
return &Configuration{
|
||||
BasePath: "http://petstore.swagger.io/v2",
|
||||
UserName: "",
|
||||
Debug: false,
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user