forked from loafle/openapi-generator-original
Merge branch 'master' of https://github.com/swagger-api/swagger-codegen into issue2535
# Conflicts: # modules/swagger-codegen/src/main/resources/go/configuration.mustache # samples/client/petstore/go/swagger/Configuration.go
This commit is contained in:
commit
7fda8699b1
@ -565,7 +565,7 @@ You can also use the codegen to generate a server for a couple different framewo
|
||||
```
|
||||
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
||||
-i http://petstore.swagger.io/v2/swagger.json \
|
||||
-l nodejs \
|
||||
-l nodejs-server \
|
||||
-o samples/server/petstore/nodejs
|
||||
```
|
||||
|
||||
|
@ -65,6 +65,11 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
{{#hasQueryParams}} type QueryParams struct {
|
||||
{{#queryParams}}{{paramName}} {{dataType}} `url:"{{baseName}},omitempty"`
|
||||
{{/queryParams}}
|
||||
|
@ -16,16 +16,23 @@ type Configuration struct {
|
||||
Host string `json:"host,omitempty"`
|
||||
Scheme string `json:"scheme,omitempty"`
|
||||
AccessToken string `json:"accessToken,omitempty"`
|
||||
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
||||
}
|
||||
|
||||
func NewConfiguration() *Configuration {
|
||||
defaultHeader := make(map[string]string)
|
||||
return &Configuration{
|
||||
BasePath: "{{basePath}}",
|
||||
UserName: "",
|
||||
Debug: false,
|
||||
DefaultHeader: defaultHeader,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Configuration) GetBasicAuthEncodedString() string {
|
||||
return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password))
|
||||
}
|
||||
|
||||
func (c *Configuration) AddDefaultHeader(key string, value string) {
|
||||
c.DefaultHeader[key] = value
|
||||
}
|
@ -7,8 +7,10 @@ import (
|
||||
)
|
||||
|
||||
{{#model}}
|
||||
{{#description}}// {{{description}}}{{/description}}
|
||||
type {{classname}} struct {
|
||||
{{#vars}}
|
||||
{{#description}}// {{{description}}}{{/description}}
|
||||
{{name}} {{{datatype}}} `json:"{{baseName}},omitempty"`
|
||||
{{/vars}}
|
||||
}
|
||||
|
@ -3,8 +3,12 @@ package swagger
|
||||
import (
|
||||
)
|
||||
|
||||
|
||||
type ApiResponse struct {
|
||||
|
||||
Code int32 `json:"code,omitempty"`
|
||||
|
||||
Type_ string `json:"type,omitempty"`
|
||||
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
@ -3,7 +3,10 @@ package swagger
|
||||
import (
|
||||
)
|
||||
|
||||
|
||||
type Category struct {
|
||||
|
||||
Id int64 `json:"id,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
@ -16,16 +16,23 @@ type Configuration struct {
|
||||
Host string `json:"host,omitempty"`
|
||||
Scheme string `json:"scheme,omitempty"`
|
||||
AccessToken string `json:"accessToken,omitempty"`
|
||||
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
||||
}
|
||||
|
||||
func NewConfiguration() *Configuration {
|
||||
defaultHeader := make(map[string]string)
|
||||
return &Configuration{
|
||||
BasePath: "http://petstore.swagger.io/v2",
|
||||
UserName: "",
|
||||
Debug: false,
|
||||
DefaultHeader: defaultHeader,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Configuration) GetBasicAuthEncodedString() string {
|
||||
return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password))
|
||||
}
|
||||
|
||||
func (c *Configuration) AddDefaultHeader(key string, value string) {
|
||||
c.DefaultHeader[key] = value
|
||||
}
|
@ -4,11 +4,18 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
type Order struct {
|
||||
|
||||
Id int64 `json:"id,omitempty"`
|
||||
|
||||
PetId int64 `json:"petId,omitempty"`
|
||||
|
||||
Quantity int32 `json:"quantity,omitempty"`
|
||||
|
||||
ShipDate time.Time `json:"shipDate,omitempty"`
|
||||
// Order Status
|
||||
Status string `json:"status,omitempty"`
|
||||
|
||||
Complete bool `json:"complete,omitempty"`
|
||||
}
|
||||
|
@ -3,11 +3,18 @@ package swagger
|
||||
import (
|
||||
)
|
||||
|
||||
|
||||
type Pet struct {
|
||||
|
||||
Id int64 `json:"id,omitempty"`
|
||||
|
||||
Category Category `json:"category,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
PhotoUrls []string `json:"photoUrls,omitempty"`
|
||||
|
||||
Tags []Tag `json:"tags,omitempty"`
|
||||
// pet status in the store
|
||||
Status string `json:"status,omitempty"`
|
||||
}
|
||||
|
@ -51,6 +51,11 @@ func (a PetApi) AddPet (body Pet) (error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
@ -119,6 +124,11 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
@ -185,6 +195,11 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
type QueryParams struct {
|
||||
status []string `url:"status,omitempty"`
|
||||
}
|
||||
@ -253,6 +268,11 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
type QueryParams struct {
|
||||
tags []string `url:"tags,omitempty"`
|
||||
}
|
||||
@ -318,6 +338,11 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
@ -382,6 +407,11 @@ func (a PetApi) UpdatePet (body Pet) (error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
@ -451,6 +481,11 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
@ -523,6 +558,11 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json" }
|
||||
for key := range accepts {
|
||||
|
@ -46,6 +46,11 @@ func (a StoreApi) DeleteOrder (orderId string) (error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
@ -105,6 +110,11 @@ func (a StoreApi) GetInventory () (map[string]int32, error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json" }
|
||||
for key := range accepts {
|
||||
@ -165,6 +175,11 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
@ -224,6 +239,11 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
|
@ -3,7 +3,10 @@ package swagger
|
||||
import (
|
||||
)
|
||||
|
||||
|
||||
type Tag struct {
|
||||
|
||||
Id int64 `json:"id,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
@ -3,13 +3,22 @@ package swagger
|
||||
import (
|
||||
)
|
||||
|
||||
|
||||
type User struct {
|
||||
|
||||
Id int64 `json:"id,omitempty"`
|
||||
|
||||
Username string `json:"username,omitempty"`
|
||||
|
||||
FirstName string `json:"firstName,omitempty"`
|
||||
|
||||
LastName string `json:"lastName,omitempty"`
|
||||
|
||||
Email string `json:"email,omitempty"`
|
||||
|
||||
Password string `json:"password,omitempty"`
|
||||
|
||||
Phone string `json:"phone,omitempty"`
|
||||
// User Status
|
||||
UserStatus int32 `json:"userStatus,omitempty"`
|
||||
}
|
||||
|
@ -45,6 +45,11 @@ func (a UserApi) CreateUser (body User) (error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
@ -106,6 +111,11 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
@ -167,6 +177,11 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
@ -229,6 +244,11 @@ func (a UserApi) DeleteUser (username string) (error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
@ -289,6 +309,11 @@ func (a UserApi) GetUserByName (username string) (User, error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
@ -349,6 +374,11 @@ func (a UserApi) LoginUser (username string, password string) (string, error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
type QueryParams struct {
|
||||
username string `url:"username,omitempty"`
|
||||
password string `url:"password,omitempty"`
|
||||
@ -412,6 +442,11 @@ func (a UserApi) LogoutUser () (error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
@ -473,6 +508,11 @@ func (a UserApi) UpdateUser (username string, body User) (error) {
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
|
||||
}
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
|
Loading…
x
Reference in New Issue
Block a user