[go] Fix go client formatting (#7283)

* Fix some go client formatting issues

* Fix go client go imports

* Run `goimports -w .` on examples directory

* Sort imports in api

* Add new line between each property

Before secret feature was used to add new line using two property
declaration in the same line. There should be no new line before
first property. The easiest way is to use `-first` special
property
https://github.com/samskivert/jmustache#-first-and--last

New line are required so `goimports` won't reformat  whitespaces between
property name and type.

* Change whitespaces to tabs

* Fix whitespaces in api_client

There is a new line between each service to prevent `goimports` from
adding whitespaces between types and names

* Fix more whitespaces

There was a need to set special delimeter for formatting in the commit.
Go slices use curly braces and `jmustache` got confused when found
triple curly braces.

* Fix whitespaces in configuration.mustache

* Fix whitespaces for api response

* Support for optional description

Do not add whitespace if description is missing

* Add new lines between enum values to prevent formatting

* Generate go code from current code

- imports are not sorted :(
- there are extra whitespaces for different languages. I don't know why

* Run generate for security tests
This commit is contained in:
Oleksandr Slynko 2018-01-07 03:53:55 +00:00 committed by William Cheng
parent 6afc0e9344
commit 919f867eba
52 changed files with 536 additions and 716 deletions

View File

@ -4,8 +4,8 @@ package {{packageName}}
{{#operations}} {{#operations}}
import ( import (
"io/ioutil" "io/ioutil"
"net/url"
"net/http" "net/http"
"net/url"
"strings" "strings"
"golang.org/x/net/context" "golang.org/x/net/context"
{{#imports}} "{{import}}" {{#imports}} "{{import}}"
@ -18,24 +18,23 @@ var (
) )
type {{classname}}Service service type {{classname}}Service service
{{#operation}} {{#operation}}
/* {{{classname}}}Service {{summary}}{{#notes}} /* {{{classname}}}Service{{#summary}} {{.}}{{/summary}}{{#notes}}
{{notes}}{{/notes}} {{notes}}{{/notes}}
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
{{#allParams}}{{#required}} @param {{paramName}} {{description}} {{#allParams}}{{#required}}@param {{paramName}}{{#description}} {{.}}{{/description}}
{{/required}}{{/allParams}}{{#hasOptionalParams}} @param optional (nil or map[string]interface{}) with one or more of: {{/required}}{{/allParams}}{{#hasOptionalParams}}@param optional (nil or map[string]interface{}) with one or more of:
{{#allParams}}{{^required}} @param "{{paramName}}" ({{dataType}}) {{description}} {{#allParams}}{{^required}} @param "{{paramName}}" ({{dataType}}){{#description}} {{.}}{{/description}}
{{/required}}{{/allParams}}{{/hasOptionalParams}} @return {{#returnType}}{{{returnType}}}{{/returnType}}*/ {{/required}}{{/allParams}}{{/hasOptionalParams}}@return {{#returnType}}{{{returnType}}}{{/returnType}}*/
func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}}, {{/hasParams}}{{#allParams}}{{#required}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}localVarOptionals map[string]interface{}{{/hasOptionalParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}} *http.Response, error) { func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}}, {{/hasParams}}{{#allParams}}{{#required}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}localVarOptionals map[string]interface{}{{/hasOptionalParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("{{httpMethod}}") localVarHttpMethod = strings.ToUpper("{{httpMethod}}")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
{{#returnType}} {{#returnType}}
successPayload {{returnType}} successPayload {{returnType}}
{{/returnType}} {{/returnType}}
) )
@ -46,7 +45,6 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
localVarHeaderParams := make(map[string]string) localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
{{#allParams}} {{#allParams}}
{{^required}} {{^required}}
{{#isPrimitiveType}} {{#isPrimitiveType}}
@ -114,7 +112,9 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
{{/queryParams}} {{/queryParams}}
{{/hasQueryParams}} {{/hasQueryParams}}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ {{#consumes}}"{{{mediaType}}}", {{/consumes}} } {{=<% %>=}}
localVarHttpContentTypes := []string{<%#consumes%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/consumes%>}
<%={{ }}=%>
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -123,11 +123,9 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ {{=<% %>=}}
{{#produces}} localVarHttpHeaderAccepts := []string{<%#produces%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/produces%>}
"{{{mediaType}}}", <%={{ }}=%>
{{/produces}}
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -223,7 +221,6 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
} }
{{/returnType}} {{/returnType}}
return {{#returnType}}successPayload, {{/returnType}}localVarHttpResponse, err return {{#returnType}}successPayload, {{/returnType}}localVarHttpResponse, err
} }
{{/operation}}{{/operations}} {{/operation}}{{/operations}}

View File

@ -5,40 +5,42 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"encoding/xml" "encoding/xml"
"fmt"
"errors" "errors"
"fmt"
"io" "io"
"mime/multipart" "mime/multipart"
"golang.org/x/oauth2"
"golang.org/x/net/context"
"net/http" "net/http"
"net/url" "net/url"
"time"
"os" "os"
"path/filepath" "path/filepath"
"reflect" "reflect"
"regexp" "regexp"
"strings"
"unicode/utf8"
"strconv" "strconv"
"strings"
"time"
"unicode/utf8"
"golang.org/x/net/context"
"golang.org/x/oauth2"
) )
var ( var (
jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") jsonCheck = regexp.MustCompile("(?i:[application|text]/json)")
xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)")
) )
// APIClient manages communication with the {{appName}} API v{{version}} // APIClient manages communication with the {{appName}} API v{{version}}
// In most cases there should be only one, shared, APIClient. // In most cases there should be only one, shared, APIClient.
type APIClient struct { type APIClient struct {
cfg *Configuration cfg *Configuration
common service // Reuse a single struct instead of allocating one for each service on the heap. common service // Reuse a single struct instead of allocating one for each service on the heap.
// API Services // API Services
{{#apiInfo}} {{#apiInfo}}
{{#apis}} {{#apis}}
{{#operations}} {{#operations}}
{{classname}} *{{classname}}Service
{{classname}} *{{classname}}Service
{{/operations}} {{/operations}}
{{/apis}} {{/apis}}
{{/apiInfo}} {{/apiInfo}}
@ -75,7 +77,6 @@ func atoi(in string) (int, error) {
return strconv.Atoi(in) return strconv.Atoi(in)
} }
// selectHeaderContentType select a content type from the available list. // selectHeaderContentType select a content type from the available list.
func selectHeaderContentType(contentTypes []string) string { func selectHeaderContentType(contentTypes []string) string {
if len(contentTypes) == 0 { if len(contentTypes) == 0 {
@ -146,18 +147,18 @@ func parameterToString(obj interface{}, collectionFormat string) string {
return fmt.Sprintf("%v", obj) return fmt.Sprintf("%v", obj)
} }
// callAPI do the request. // callAPI do the request.
func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
return c.cfg.HTTPClient.Do(request) return c.cfg.HTTPClient.Do(request)
} }
// Change base path to allow switching to mocks // Change base path to allow switching to mocks
func (c *APIClient) ChangeBasePath (path string) { func (c *APIClient) ChangeBasePath(path string) {
c.cfg.BasePath = path c.cfg.BasePath = path
} }
// prepareRequest build the request // prepareRequest build the request
func (c *APIClient) prepareRequest ( func (c *APIClient) prepareRequest(
ctx context.Context, ctx context.Context,
path string, method string, path string, method string,
postBody interface{}, postBody interface{},
@ -217,7 +218,7 @@ func (c *APIClient) prepareRequest (
// Set the Boundary in the Content-Type // Set the Boundary in the Content-Type
headerParams["Content-Type"] = w.FormDataContentType() headerParams["Content-Type"] = w.FormDataContentType()
} }
// Set Content-Length // Set Content-Length
headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
w.Close() w.Close()
@ -263,10 +264,9 @@ func (c *APIClient) prepareRequest (
if c.cfg.Host != "" { if c.cfg.Host != "" {
localVarRequest.Host = c.cfg.Host localVarRequest.Host = c.cfg.Host
} }
// Add the user agent to the request. // Add the user agent to the request.
localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent)
if ctx != nil { if ctx != nil {
// add context to the request // add context to the request
@ -292,18 +292,17 @@ func (c *APIClient) prepareRequest (
// AccessToken Authentication // AccessToken Authentication
if auth, ok := ctx.Value(ContextAccessToken).(string); ok { if auth, ok := ctx.Value(ContextAccessToken).(string); ok {
localVarRequest.Header.Add("Authorization", "Bearer " + auth) localVarRequest.Header.Add("Authorization", "Bearer "+auth)
} }
} }
for header, value := range c.cfg.DefaultHeader { for header, value := range c.cfg.DefaultHeader {
localVarRequest.Header.Add(header, value) localVarRequest.Header.Add(header, value)
} }
return localVarRequest, nil return localVarRequest, nil
} }
// Add a file to the multipart request // Add a file to the multipart request
func addFile(w *multipart.Writer, fieldName, path string) error { func addFile(w *multipart.Writer, fieldName, path string) error {
file, err := os.Open(path) file, err := os.Open(path)
@ -322,7 +321,7 @@ func addFile(w *multipart.Writer, fieldName, path string) error {
} }
// Prevent trying to import "fmt" // Prevent trying to import "fmt"
func reportError(format string, a ...interface{}) (error) { func reportError(format string, a ...interface{}) error {
return fmt.Errorf(format, a...) return fmt.Errorf(format, a...)
} }
@ -359,7 +358,7 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
func detectContentType(body interface{}) string { func detectContentType(body interface{}) string {
contentType := "text/plain; charset=utf-8" contentType := "text/plain; charset=utf-8"
kind := reflect.TypeOf(body).Kind() kind := reflect.TypeOf(body).Kind()
switch kind { switch kind {
case reflect.Struct, reflect.Map, reflect.Ptr: case reflect.Struct, reflect.Map, reflect.Ptr:
contentType = "application/json; charset=utf-8" contentType = "application/json; charset=utf-8"
@ -376,7 +375,6 @@ func detectContentType(body interface{}) string {
return contentType return contentType
} }
// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go // Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go
type cacheControl map[string]string type cacheControl map[string]string
@ -399,7 +397,7 @@ func parseCacheControl(headers http.Header) cacheControl {
} }
// CacheExpires helper function to determine remaining time before repeating a request. // CacheExpires helper function to determine remaining time before repeating a request.
func CacheExpires(r *http.Response) (time.Time) { func CacheExpires(r *http.Response) time.Time {
// Figure out when the cache expires. // Figure out when the cache expires.
var expires time.Time var expires time.Time
now, err := time.Parse(time.RFC1123, r.Header.Get("date")) now, err := time.Parse(time.RFC1123, r.Header.Get("date"))
@ -407,7 +405,7 @@ func CacheExpires(r *http.Response) (time.Time) {
return time.Now() return time.Now()
} }
respCacheControl := parseCacheControl(r.Header) respCacheControl := parseCacheControl(r.Header)
if maxAge, ok := respCacheControl["max-age"]; ok { if maxAge, ok := respCacheControl["max-age"]; ok {
lifetime, err := time.ParseDuration(maxAge + "s") lifetime, err := time.ParseDuration(maxAge + "s")
if err != nil { if err != nil {
@ -426,7 +424,6 @@ func CacheExpires(r *http.Response) (time.Time) {
return expires return expires
} }
func strlen(s string) (int) { func strlen(s string) int {
return utf8.RuneCountInString(s) return utf8.RuneCountInString(s)
} }

View File

@ -7,15 +7,15 @@ import (
type APIResponse struct { type APIResponse struct {
*http.Response `json:"-"` *http.Response `json:"-"`
Message string `json:"message,omitempty"` Message string `json:"message,omitempty"`
// Operation is the name of the swagger operation. // Operation is the name of the swagger operation.
Operation string `json:"operation,omitempty"` Operation string `json:"operation,omitempty"`
// RequestURL is the request URL. This value is always available, even if the // RequestURL is the request URL. This value is always available, even if the
// embedded *http.Response is nil. // embedded *http.Response is nil.
RequestURL string `json:"url,omitempty"` RequestURL string `json:"url,omitempty"`
// Method is the HTTP method used for the request. This value is always // Method is the HTTP method used for the request. This value is always
// available, even if the embedded *http.Response is nil. // available, even if the embedded *http.Response is nil.
Method string `json:"method,omitempty"` Method string `json:"method,omitempty"`
// Payload holds the contents of the response body (which may be nil or empty). // Payload holds the contents of the response body (which may be nil or empty).
// This is provided here as the raw response.Body() reader will have already // This is provided here as the raw response.Body() reader will have already
// been drained. // been drained.

View File

@ -17,37 +17,37 @@ func (c contextKey) String() string {
var ( var (
// ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request.
ContextOAuth2 = contextKey("token") ContextOAuth2 = contextKey("token")
// ContextBasicAuth takes BasicAuth as authentication for the request. // ContextBasicAuth takes BasicAuth as authentication for the request.
ContextBasicAuth = contextKey("basic") ContextBasicAuth = contextKey("basic")
// ContextAccessToken takes a string oauth2 access token as authentication for the request. // ContextAccessToken takes a string oauth2 access token as authentication for the request.
ContextAccessToken = contextKey("accesstoken") ContextAccessToken = contextKey("accesstoken")
// ContextAPIKey takes an APIKey as authentication for the request // ContextAPIKey takes an APIKey as authentication for the request
ContextAPIKey = contextKey("apikey") ContextAPIKey = contextKey("apikey")
) )
// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
type BasicAuth struct { type BasicAuth struct {
UserName string `json:"userName,omitempty"` UserName string `json:"userName,omitempty"`
Password string `json:"password,omitempty"` Password string `json:"password,omitempty"`
} }
// APIKey provides API key based authentication to a request passed via context using ContextAPIKey // APIKey provides API key based authentication to a request passed via context using ContextAPIKey
type APIKey struct { type APIKey struct {
Key string Key string
Prefix string Prefix string
} }
type Configuration struct { type Configuration struct {
BasePath string `json:"basePath,omitempty"` BasePath string `json:"basePath,omitempty"`
Host string `json:"host,omitempty"` Host string `json:"host,omitempty"`
Scheme string `json:"scheme,omitempty"` Scheme string `json:"scheme,omitempty"`
DefaultHeader map[string]string `json:"defaultHeader,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
UserAgent string `json:"userAgent,omitempty"` UserAgent string `json:"userAgent,omitempty"`
HTTPClient *http.Client HTTPClient *http.Client
} }
func NewConfiguration() *Configuration { func NewConfiguration() *Configuration {
@ -61,4 +61,4 @@ func NewConfiguration() *Configuration {
func (c *Configuration) AddDefaultHeader(key string, value string) { func (c *Configuration) AddDefaultHeader(key string, value string) {
c.DefaultHeader[key] = value c.DefaultHeader[key] = value
} }

View File

@ -11,14 +11,22 @@ type {{{name}}} {{^format}}{{dataType}}{{/format}}{{#format}}{{{format}}}{{/form
const ( const (
{{#allowableValues}} {{#allowableValues}}
{{#enumVars}} {{#enumVars}}
{{^-first}}
{{/-first}}
{{name}} {{{classname}}} = "{{{value}}}" {{name}} {{{classname}}} = "{{{value}}}"
{{/enumVars}} {{/enumVars}}
{{/allowableValues}} {{/allowableValues}}
){{/isEnum}}{{^isEnum}}{{#description}} ){{/isEnum}}{{^isEnum}}{{#description}}
// {{{description}}}{{/description}} // {{{description}}}{{/description}}
type {{classname}} struct { type {{classname}} struct {
{{#vars}}{{#description}} {{#vars}}
// {{{description}}}{{/description}} {{^-first}}
{{/-first}}
{{#description}}
// {{{description}}}
{{/description}}
{{name}} {{^isEnum}}{{^isPrimitiveType}}{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{/isPrimitiveType}}{{/isEnum}}{{{datatype}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"` {{name}} {{^isEnum}}{{^isPrimitiveType}}{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{/isPrimitiveType}}{{/isEnum}}{{{datatype}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"`
{{/vars}} {{/vars}}
}{{/isEnum}}{{/model}}{{/models}} }{{/isEnum}}{{/model}}{{/models}}

View File

@ -56,7 +56,7 @@ Example
r, err := client.Service.Operation(auth, args) r, err := client.Service.Operation(auth, args)
``` ```
Or via OAuth2 module to automaticly refresh tokens and perform user authentication. Or via OAuth2 module to automatically refresh tokens and perform user authentication.
``` ```
import "golang.org/x/oauth2" import "golang.org/x/oauth2"

View File

@ -14,37 +14,39 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"encoding/xml" "encoding/xml"
"fmt"
"errors" "errors"
"fmt"
"io" "io"
"mime/multipart" "mime/multipart"
"golang.org/x/oauth2"
"golang.org/x/net/context"
"net/http" "net/http"
"net/url" "net/url"
"time"
"os" "os"
"path/filepath" "path/filepath"
"reflect" "reflect"
"regexp" "regexp"
"strings"
"unicode/utf8"
"strconv" "strconv"
"strings"
"time"
"unicode/utf8"
"golang.org/x/net/context"
"golang.org/x/oauth2"
) )
var ( var (
jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") jsonCheck = regexp.MustCompile("(?i:[application|text]/json)")
xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)")
) )
// APIClient manages communication with the Swagger Petstore *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r API v1.0.0 *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r // APIClient manages communication with the Swagger Petstore *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r API v1.0.0 *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
// In most cases there should be only one, shared, APIClient. // In most cases there should be only one, shared, APIClient.
type APIClient struct { type APIClient struct {
cfg *Configuration cfg *Configuration
common service // Reuse a single struct instead of allocating one for each service on the heap. common service // Reuse a single struct instead of allocating one for each service on the heap.
// API Services // API Services
FakeApi *FakeApiService
FakeApi *FakeApiService
} }
type service struct { type service struct {
@ -72,7 +74,6 @@ func atoi(in string) (int, error) {
return strconv.Atoi(in) return strconv.Atoi(in)
} }
// selectHeaderContentType select a content type from the available list. // selectHeaderContentType select a content type from the available list.
func selectHeaderContentType(contentTypes []string) string { func selectHeaderContentType(contentTypes []string) string {
if len(contentTypes) == 0 { if len(contentTypes) == 0 {
@ -143,18 +144,18 @@ func parameterToString(obj interface{}, collectionFormat string) string {
return fmt.Sprintf("%v", obj) return fmt.Sprintf("%v", obj)
} }
// callAPI do the request. // callAPI do the request.
func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
return c.cfg.HTTPClient.Do(request) return c.cfg.HTTPClient.Do(request)
} }
// Change base path to allow switching to mocks // Change base path to allow switching to mocks
func (c *APIClient) ChangeBasePath (path string) { func (c *APIClient) ChangeBasePath(path string) {
c.cfg.BasePath = path c.cfg.BasePath = path
} }
// prepareRequest build the request // prepareRequest build the request
func (c *APIClient) prepareRequest ( func (c *APIClient) prepareRequest(
ctx context.Context, ctx context.Context,
path string, method string, path string, method string,
postBody interface{}, postBody interface{},
@ -180,7 +181,7 @@ func (c *APIClient) prepareRequest (
} }
} }
// add form paramters and file if available. // add form parameters and file if available.
if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") {
if body != nil { if body != nil {
return nil, errors.New("Cannot specify postBody and multipart form at the same time.") return nil, errors.New("Cannot specify postBody and multipart form at the same time.")
@ -214,13 +215,13 @@ func (c *APIClient) prepareRequest (
// Set the Boundary in the Content-Type // Set the Boundary in the Content-Type
headerParams["Content-Type"] = w.FormDataContentType() headerParams["Content-Type"] = w.FormDataContentType()
} }
// Set Content-Length // Set Content-Length
headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
w.Close() w.Close()
} }
// Setup path and query paramters // Setup path and query parameters
url, err := url.Parse(path) url, err := url.Parse(path)
if err != nil { if err != nil {
return nil, err return nil, err
@ -260,10 +261,9 @@ func (c *APIClient) prepareRequest (
if c.cfg.Host != "" { if c.cfg.Host != "" {
localVarRequest.Host = c.cfg.Host localVarRequest.Host = c.cfg.Host
} }
// Add the user agent to the request. // Add the user agent to the request.
localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent)
if ctx != nil { if ctx != nil {
// add context to the request // add context to the request
@ -289,18 +289,17 @@ func (c *APIClient) prepareRequest (
// AccessToken Authentication // AccessToken Authentication
if auth, ok := ctx.Value(ContextAccessToken).(string); ok { if auth, ok := ctx.Value(ContextAccessToken).(string); ok {
localVarRequest.Header.Add("Authorization", "Bearer " + auth) localVarRequest.Header.Add("Authorization", "Bearer "+auth)
} }
} }
for header, value := range c.cfg.DefaultHeader { for header, value := range c.cfg.DefaultHeader {
localVarRequest.Header.Add(header, value) localVarRequest.Header.Add(header, value)
} }
return localVarRequest, nil return localVarRequest, nil
} }
// Add a file to the multipart request // Add a file to the multipart request
func addFile(w *multipart.Writer, fieldName, path string) error { func addFile(w *multipart.Writer, fieldName, path string) error {
file, err := os.Open(path) file, err := os.Open(path)
@ -319,7 +318,7 @@ func addFile(w *multipart.Writer, fieldName, path string) error {
} }
// Prevent trying to import "fmt" // Prevent trying to import "fmt"
func reportError(format string, a ...interface{}) (error) { func reportError(format string, a ...interface{}) error {
return fmt.Errorf(format, a...) return fmt.Errorf(format, a...)
} }
@ -356,7 +355,7 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
func detectContentType(body interface{}) string { func detectContentType(body interface{}) string {
contentType := "text/plain; charset=utf-8" contentType := "text/plain; charset=utf-8"
kind := reflect.TypeOf(body).Kind() kind := reflect.TypeOf(body).Kind()
switch kind { switch kind {
case reflect.Struct, reflect.Map, reflect.Ptr: case reflect.Struct, reflect.Map, reflect.Ptr:
contentType = "application/json; charset=utf-8" contentType = "application/json; charset=utf-8"
@ -373,7 +372,6 @@ func detectContentType(body interface{}) string {
return contentType return contentType
} }
// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go // Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go
type cacheControl map[string]string type cacheControl map[string]string
@ -396,7 +394,7 @@ func parseCacheControl(headers http.Header) cacheControl {
} }
// CacheExpires helper function to determine remaining time before repeating a request. // CacheExpires helper function to determine remaining time before repeating a request.
func CacheExpires(r *http.Response) (time.Time) { func CacheExpires(r *http.Response) time.Time {
// Figure out when the cache expires. // Figure out when the cache expires.
var expires time.Time var expires time.Time
now, err := time.Parse(time.RFC1123, r.Header.Get("date")) now, err := time.Parse(time.RFC1123, r.Header.Get("date"))
@ -404,7 +402,7 @@ func CacheExpires(r *http.Response) (time.Time) {
return time.Now() return time.Now()
} }
respCacheControl := parseCacheControl(r.Header) respCacheControl := parseCacheControl(r.Header)
if maxAge, ok := respCacheControl["max-age"]; ok { if maxAge, ok := respCacheControl["max-age"]; ok {
lifetime, err := time.ParseDuration(maxAge + "s") lifetime, err := time.ParseDuration(maxAge + "s")
if err != nil { if err != nil {
@ -423,7 +421,6 @@ func CacheExpires(r *http.Response) (time.Time) {
return expires return expires
} }
func strlen(s string) (int) { func strlen(s string) int {
return utf8.RuneCountInString(s) return utf8.RuneCountInString(s)
} }

View File

@ -16,15 +16,15 @@ import (
type APIResponse struct { type APIResponse struct {
*http.Response `json:"-"` *http.Response `json:"-"`
Message string `json:"message,omitempty"` Message string `json:"message,omitempty"`
// Operation is the name of the swagger operation. // Operation is the name of the swagger operation.
Operation string `json:"operation,omitempty"` Operation string `json:"operation,omitempty"`
// RequestURL is the request URL. This value is always available, even if the // RequestURL is the request URL. This value is always available, even if the
// embedded *http.Response is nil. // embedded *http.Response is nil.
RequestURL string `json:"url,omitempty"` RequestURL string `json:"url,omitempty"`
// Method is the HTTP method used for the request. This value is always // Method is the HTTP method used for the request. This value is always
// available, even if the embedded *http.Response is nil. // available, even if the embedded *http.Response is nil.
Method string `json:"method,omitempty"` Method string `json:"method,omitempty"`
// Payload holds the contents of the response body (which may be nil or empty). // Payload holds the contents of the response body (which may be nil or empty).
// This is provided here as the raw response.Body() reader will have already // This is provided here as the raw response.Body() reader will have already
// been drained. // been drained.

View File

@ -26,37 +26,37 @@ func (c contextKey) String() string {
var ( var (
// ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request.
ContextOAuth2 = contextKey("token") ContextOAuth2 = contextKey("token")
// ContextBasicAuth takes BasicAuth as authentication for the request. // ContextBasicAuth takes BasicAuth as authentication for the request.
ContextBasicAuth = contextKey("basic") ContextBasicAuth = contextKey("basic")
// ContextAccessToken takes a string oauth2 access token as authentication for the request. // ContextAccessToken takes a string oauth2 access token as authentication for the request.
ContextAccessToken = contextKey("accesstoken") ContextAccessToken = contextKey("accesstoken")
// ContextAPIKey takes an APIKey as authentication for the request // ContextAPIKey takes an APIKey as authentication for the request
ContextAPIKey = contextKey("apikey") ContextAPIKey = contextKey("apikey")
) )
// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
type BasicAuth struct { type BasicAuth struct {
UserName string `json:"userName,omitempty"` UserName string `json:"userName,omitempty"`
Password string `json:"password,omitempty"` Password string `json:"password,omitempty"`
} }
// APIKey provides API key based authentication to a request passed via context using ContextAPIKey // APIKey provides API key based authentication to a request passed via context using ContextAPIKey
type APIKey struct { type APIKey struct {
Key string Key string
Prefix string Prefix string
} }
type Configuration struct { type Configuration struct {
BasePath string `json:"basePath,omitempty"` BasePath string `json:"basePath,omitempty"`
Host string `json:"host,omitempty"` Host string `json:"host,omitempty"`
Scheme string `json:"scheme,omitempty"` Scheme string `json:"scheme,omitempty"`
DefaultHeader map[string]string `json:"defaultHeader,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
UserAgent string `json:"userAgent,omitempty"` UserAgent string `json:"userAgent,omitempty"`
HTTPClient *http.Client HTTPClient *http.Client
} }
func NewConfiguration() *Configuration { func NewConfiguration() *Configuration {
@ -70,4 +70,4 @@ func NewConfiguration() *Configuration {
func (c *Configuration) AddDefaultHeader(key string, value string) { func (c *Configuration) AddDefaultHeader(key string, value string) {
c.DefaultHeader[key] = value c.DefaultHeader[key] = value
} }

View File

@ -11,8 +11,9 @@
package swagger package swagger
import ( import (
"net/url" "io/ioutil"
"net/http" "net/http"
"net/url"
"strings" "strings"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
@ -24,18 +25,17 @@ var (
type FakeApiService service type FakeApiService service
/* FakeApiService To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r /* FakeApiService To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param optional (nil or map[string]interface{}) with one or more of: @param optional (nil or map[string]interface{}) with one or more of:
@param "testCodeInjectEndRnNR" (string) To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r @param "testCodeInjectEndRnNR" (string) To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
@return */ @return */
func (a *FakeApiService) TestCodeInjectEndRnNR(ctx context.Context, localVarOptionals map[string]interface{}) ( *http.Response, error) { func (a *FakeApiService) TestCodeInjectEndRnNR(ctx context.Context, localVarOptionals map[string]interface{}) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Put") localVarHttpMethod = strings.ToUpper("Put")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -44,13 +44,12 @@ func (a *FakeApiService) TestCodeInjectEndRnNR(ctx context.Context, localVarOpti
localVarHeaderParams := make(map[string]string) localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
if err := typeCheckParameter(localVarOptionals["testCodeInjectEndRnNR"], "string", "testCodeInjectEndRnNR"); err != nil { if err := typeCheckParameter(localVarOptionals["testCodeInjectEndRnNR"], "string", "testCodeInjectEndRnNR"); err != nil {
return nil, err return nil, err
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ "application/json", "*_/ ' =end -- ", } localVarHttpContentTypes := []string{"application/json", "*_/ ' =end -- "}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -59,10 +58,7 @@ func (a *FakeApiService) TestCodeInjectEndRnNR(ctx context.Context, localVarOpti
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/json", "*_/ ' =end -- "}
"application/json",
"*_/ ' =end -- ",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -83,9 +79,8 @@ func (a *FakeApiService) TestCodeInjectEndRnNR(ctx context.Context, localVarOpti
} }
defer localVarHttpResponse.Body.Close() defer localVarHttpResponse.Body.Close()
if localVarHttpResponse.StatusCode >= 300 { if localVarHttpResponse.StatusCode >= 300 {
return localVarHttpResponse, reportError(localVarHttpResponse.Status) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }

View File

@ -12,7 +12,6 @@ package swagger
// Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r // Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r
type ModelReturn struct { type ModelReturn struct {
// property description *_/ ' \" =end -- \\r\\n \\n \\r // property description *_/ ' \" =end -- \\r\\n \\n \\r
Return_ int32 `json:"return,omitempty"` Return_ int32 `json:"return,omitempty"`
} }

View File

@ -11,7 +11,6 @@
package petstore package petstore
type AdditionalPropertiesClass struct { type AdditionalPropertiesClass struct {
MapProperty map[string]string `json:"map_property,omitempty"` MapProperty map[string]string `json:"map_property,omitempty"`
MapOfMapProperty map[string]map[string]string `json:"map_of_map_property,omitempty"` MapOfMapProperty map[string]map[string]string `json:"map_of_map_property,omitempty"`

View File

@ -11,7 +11,6 @@
package petstore package petstore
type Animal struct { type Animal struct {
ClassName string `json:"className"` ClassName string `json:"className"`
Color string `json:"color,omitempty"` Color string `json:"color,omitempty"`

View File

@ -12,8 +12,8 @@ package petstore
import ( import (
"io/ioutil" "io/ioutil"
"net/url"
"net/http" "net/http"
"net/url"
"strings" "strings"
"golang.org/x/net/context" "golang.org/x/net/context"
"encoding/json" "encoding/json"
@ -26,19 +26,18 @@ var (
type AnotherFakeApiService service type AnotherFakeApiService service
/* AnotherFakeApiService To test special tags /* AnotherFakeApiService To test special tags
To test special tags To test special tags
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param body client model @param body client model
@return Client*/ @return Client*/
func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client) (Client, *http.Response, error) { func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client) (Client, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Patch") localVarHttpMethod = strings.ToUpper("Patch")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload Client successPayload Client
) )
// create path and map variables // create path and map variables
@ -48,9 +47,8 @@ func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ "application/json", } localVarHttpContentTypes := []string{"application/json"}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -59,9 +57,7 @@ func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/json"}
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -89,7 +85,5 @@ func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }

View File

@ -14,42 +14,49 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"encoding/xml" "encoding/xml"
"fmt"
"errors" "errors"
"fmt"
"io" "io"
"mime/multipart" "mime/multipart"
"golang.org/x/oauth2"
"golang.org/x/net/context"
"net/http" "net/http"
"net/url" "net/url"
"time"
"os" "os"
"path/filepath" "path/filepath"
"reflect" "reflect"
"regexp" "regexp"
"strings"
"unicode/utf8"
"strconv" "strconv"
"strings"
"time"
"unicode/utf8"
"golang.org/x/net/context"
"golang.org/x/oauth2"
) )
var ( var (
jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") jsonCheck = regexp.MustCompile("(?i:[application|text]/json)")
xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)")
) )
// APIClient manages communication with the Swagger Petstore API v1.0.0 // APIClient manages communication with the Swagger Petstore API v1.0.0
// In most cases there should be only one, shared, APIClient. // In most cases there should be only one, shared, APIClient.
type APIClient struct { type APIClient struct {
cfg *Configuration cfg *Configuration
common service // Reuse a single struct instead of allocating one for each service on the heap. common service // Reuse a single struct instead of allocating one for each service on the heap.
// API Services // API Services
AnotherFakeApi *AnotherFakeApiService
FakeApi *FakeApiService AnotherFakeApi *AnotherFakeApiService
FakeClassnameTags123Api *FakeClassnameTags123ApiService
PetApi *PetApiService FakeApi *FakeApiService
StoreApi *StoreApiService
UserApi *UserApiService FakeClassnameTags123Api *FakeClassnameTags123ApiService
PetApi *PetApiService
StoreApi *StoreApiService
UserApi *UserApiService
} }
type service struct { type service struct {
@ -82,7 +89,6 @@ func atoi(in string) (int, error) {
return strconv.Atoi(in) return strconv.Atoi(in)
} }
// selectHeaderContentType select a content type from the available list. // selectHeaderContentType select a content type from the available list.
func selectHeaderContentType(contentTypes []string) string { func selectHeaderContentType(contentTypes []string) string {
if len(contentTypes) == 0 { if len(contentTypes) == 0 {
@ -153,18 +159,18 @@ func parameterToString(obj interface{}, collectionFormat string) string {
return fmt.Sprintf("%v", obj) return fmt.Sprintf("%v", obj)
} }
// callAPI do the request. // callAPI do the request.
func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
return c.cfg.HTTPClient.Do(request) return c.cfg.HTTPClient.Do(request)
} }
// Change base path to allow switching to mocks // Change base path to allow switching to mocks
func (c *APIClient) ChangeBasePath (path string) { func (c *APIClient) ChangeBasePath(path string) {
c.cfg.BasePath = path c.cfg.BasePath = path
} }
// prepareRequest build the request // prepareRequest build the request
func (c *APIClient) prepareRequest ( func (c *APIClient) prepareRequest(
ctx context.Context, ctx context.Context,
path string, method string, path string, method string,
postBody interface{}, postBody interface{},
@ -224,7 +230,7 @@ func (c *APIClient) prepareRequest (
// Set the Boundary in the Content-Type // Set the Boundary in the Content-Type
headerParams["Content-Type"] = w.FormDataContentType() headerParams["Content-Type"] = w.FormDataContentType()
} }
// Set Content-Length // Set Content-Length
headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
w.Close() w.Close()
@ -270,10 +276,9 @@ func (c *APIClient) prepareRequest (
if c.cfg.Host != "" { if c.cfg.Host != "" {
localVarRequest.Host = c.cfg.Host localVarRequest.Host = c.cfg.Host
} }
// Add the user agent to the request. // Add the user agent to the request.
localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent)
if ctx != nil { if ctx != nil {
// add context to the request // add context to the request
@ -299,18 +304,17 @@ func (c *APIClient) prepareRequest (
// AccessToken Authentication // AccessToken Authentication
if auth, ok := ctx.Value(ContextAccessToken).(string); ok { if auth, ok := ctx.Value(ContextAccessToken).(string); ok {
localVarRequest.Header.Add("Authorization", "Bearer " + auth) localVarRequest.Header.Add("Authorization", "Bearer "+auth)
} }
} }
for header, value := range c.cfg.DefaultHeader { for header, value := range c.cfg.DefaultHeader {
localVarRequest.Header.Add(header, value) localVarRequest.Header.Add(header, value)
} }
return localVarRequest, nil return localVarRequest, nil
} }
// Add a file to the multipart request // Add a file to the multipart request
func addFile(w *multipart.Writer, fieldName, path string) error { func addFile(w *multipart.Writer, fieldName, path string) error {
file, err := os.Open(path) file, err := os.Open(path)
@ -329,7 +333,7 @@ func addFile(w *multipart.Writer, fieldName, path string) error {
} }
// Prevent trying to import "fmt" // Prevent trying to import "fmt"
func reportError(format string, a ...interface{}) (error) { func reportError(format string, a ...interface{}) error {
return fmt.Errorf(format, a...) return fmt.Errorf(format, a...)
} }
@ -366,7 +370,7 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
func detectContentType(body interface{}) string { func detectContentType(body interface{}) string {
contentType := "text/plain; charset=utf-8" contentType := "text/plain; charset=utf-8"
kind := reflect.TypeOf(body).Kind() kind := reflect.TypeOf(body).Kind()
switch kind { switch kind {
case reflect.Struct, reflect.Map, reflect.Ptr: case reflect.Struct, reflect.Map, reflect.Ptr:
contentType = "application/json; charset=utf-8" contentType = "application/json; charset=utf-8"
@ -383,7 +387,6 @@ func detectContentType(body interface{}) string {
return contentType return contentType
} }
// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go // Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go
type cacheControl map[string]string type cacheControl map[string]string
@ -406,7 +409,7 @@ func parseCacheControl(headers http.Header) cacheControl {
} }
// CacheExpires helper function to determine remaining time before repeating a request. // CacheExpires helper function to determine remaining time before repeating a request.
func CacheExpires(r *http.Response) (time.Time) { func CacheExpires(r *http.Response) time.Time {
// Figure out when the cache expires. // Figure out when the cache expires.
var expires time.Time var expires time.Time
now, err := time.Parse(time.RFC1123, r.Header.Get("date")) now, err := time.Parse(time.RFC1123, r.Header.Get("date"))
@ -414,7 +417,7 @@ func CacheExpires(r *http.Response) (time.Time) {
return time.Now() return time.Now()
} }
respCacheControl := parseCacheControl(r.Header) respCacheControl := parseCacheControl(r.Header)
if maxAge, ok := respCacheControl["max-age"]; ok { if maxAge, ok := respCacheControl["max-age"]; ok {
lifetime, err := time.ParseDuration(maxAge + "s") lifetime, err := time.ParseDuration(maxAge + "s")
if err != nil { if err != nil {
@ -433,7 +436,6 @@ func CacheExpires(r *http.Response) (time.Time) {
return expires return expires
} }
func strlen(s string) (int) { func strlen(s string) int {
return utf8.RuneCountInString(s) return utf8.RuneCountInString(s)
} }

View File

@ -16,15 +16,15 @@ import (
type APIResponse struct { type APIResponse struct {
*http.Response `json:"-"` *http.Response `json:"-"`
Message string `json:"message,omitempty"` Message string `json:"message,omitempty"`
// Operation is the name of the swagger operation. // Operation is the name of the swagger operation.
Operation string `json:"operation,omitempty"` Operation string `json:"operation,omitempty"`
// RequestURL is the request URL. This value is always available, even if the // RequestURL is the request URL. This value is always available, even if the
// embedded *http.Response is nil. // embedded *http.Response is nil.
RequestURL string `json:"url,omitempty"` RequestURL string `json:"url,omitempty"`
// Method is the HTTP method used for the request. This value is always // Method is the HTTP method used for the request. This value is always
// available, even if the embedded *http.Response is nil. // available, even if the embedded *http.Response is nil.
Method string `json:"method,omitempty"` Method string `json:"method,omitempty"`
// Payload holds the contents of the response body (which may be nil or empty). // Payload holds the contents of the response body (which may be nil or empty).
// This is provided here as the raw response.Body() reader will have already // This is provided here as the raw response.Body() reader will have already
// been drained. // been drained.

View File

@ -11,6 +11,5 @@
package petstore package petstore
type ArrayOfArrayOfNumberOnly struct { type ArrayOfArrayOfNumberOnly struct {
ArrayArrayNumber [][]float32 `json:"ArrayArrayNumber,omitempty"` ArrayArrayNumber [][]float32 `json:"ArrayArrayNumber,omitempty"`
} }

View File

@ -11,6 +11,5 @@
package petstore package petstore
type ArrayOfNumberOnly struct { type ArrayOfNumberOnly struct {
ArrayNumber []float32 `json:"ArrayNumber,omitempty"` ArrayNumber []float32 `json:"ArrayNumber,omitempty"`
} }

View File

@ -11,7 +11,6 @@
package petstore package petstore
type ArrayTest struct { type ArrayTest struct {
ArrayOfString []string `json:"array_of_string,omitempty"` ArrayOfString []string `json:"array_of_string,omitempty"`
ArrayArrayOfInteger [][]int64 `json:"array_array_of_integer,omitempty"` ArrayArrayOfInteger [][]int64 `json:"array_array_of_integer,omitempty"`

View File

@ -11,7 +11,6 @@
package petstore package petstore
type Capitalization struct { type Capitalization struct {
SmallCamel string `json:"smallCamel,omitempty"` SmallCamel string `json:"smallCamel,omitempty"`
CapitalCamel string `json:"CapitalCamel,omitempty"` CapitalCamel string `json:"CapitalCamel,omitempty"`

View File

@ -11,7 +11,6 @@
package petstore package petstore
type Cat struct { type Cat struct {
ClassName string `json:"className"` ClassName string `json:"className"`
Color string `json:"color,omitempty"` Color string `json:"color,omitempty"`

View File

@ -11,7 +11,6 @@
package petstore package petstore
type Category struct { type Category struct {
Id int64 `json:"id,omitempty"` Id int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`

View File

@ -12,6 +12,5 @@ package petstore
// Model for testing model with \"_class\" property // Model for testing model with \"_class\" property
type ClassModel struct { type ClassModel struct {
Class string `json:"_class,omitempty"` Class string `json:"_class,omitempty"`
} }

View File

@ -11,6 +11,5 @@
package petstore package petstore
type Client struct { type Client struct {
Client string `json:"client,omitempty"` Client string `json:"client,omitempty"`
} }

View File

@ -26,37 +26,37 @@ func (c contextKey) String() string {
var ( var (
// ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request.
ContextOAuth2 = contextKey("token") ContextOAuth2 = contextKey("token")
// ContextBasicAuth takes BasicAuth as authentication for the request. // ContextBasicAuth takes BasicAuth as authentication for the request.
ContextBasicAuth = contextKey("basic") ContextBasicAuth = contextKey("basic")
// ContextAccessToken takes a string oauth2 access token as authentication for the request. // ContextAccessToken takes a string oauth2 access token as authentication for the request.
ContextAccessToken = contextKey("accesstoken") ContextAccessToken = contextKey("accesstoken")
// ContextAPIKey takes an APIKey as authentication for the request // ContextAPIKey takes an APIKey as authentication for the request
ContextAPIKey = contextKey("apikey") ContextAPIKey = contextKey("apikey")
) )
// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
type BasicAuth struct { type BasicAuth struct {
UserName string `json:"userName,omitempty"` UserName string `json:"userName,omitempty"`
Password string `json:"password,omitempty"` Password string `json:"password,omitempty"`
} }
// APIKey provides API key based authentication to a request passed via context using ContextAPIKey // APIKey provides API key based authentication to a request passed via context using ContextAPIKey
type APIKey struct { type APIKey struct {
Key string Key string
Prefix string Prefix string
} }
type Configuration struct { type Configuration struct {
BasePath string `json:"basePath,omitempty"` BasePath string `json:"basePath,omitempty"`
Host string `json:"host,omitempty"` Host string `json:"host,omitempty"`
Scheme string `json:"scheme,omitempty"` Scheme string `json:"scheme,omitempty"`
DefaultHeader map[string]string `json:"defaultHeader,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
UserAgent string `json:"userAgent,omitempty"` UserAgent string `json:"userAgent,omitempty"`
HTTPClient *http.Client HTTPClient *http.Client
} }
func NewConfiguration() *Configuration { func NewConfiguration() *Configuration {
@ -70,4 +70,4 @@ func NewConfiguration() *Configuration {
func (c *Configuration) AddDefaultHeader(key string, value string) { func (c *Configuration) AddDefaultHeader(key string, value string) {
c.DefaultHeader[key] = value c.DefaultHeader[key] = value
} }

View File

@ -11,7 +11,6 @@
package petstore package petstore
type Dog struct { type Dog struct {
ClassName string `json:"className"` ClassName string `json:"className"`
Color string `json:"color,omitempty"` Color string `json:"color,omitempty"`

View File

@ -11,7 +11,6 @@
package petstore package petstore
type EnumArrays struct { type EnumArrays struct {
JustSymbol string `json:"just_symbol,omitempty"` JustSymbol string `json:"just_symbol,omitempty"`
ArrayEnum []string `json:"array_enum,omitempty"` ArrayEnum []string `json:"array_enum,omitempty"`

View File

@ -15,6 +15,8 @@ type EnumClass string
// List of EnumClass // List of EnumClass
const ( const (
ABC EnumClass = "_abc" ABC EnumClass = "_abc"
EFG EnumClass = "-efg" EFG EnumClass = "-efg"
XYZ EnumClass = "(xyz)" XYZ EnumClass = "(xyz)"
) )

View File

@ -11,7 +11,6 @@
package petstore package petstore
type EnumTest struct { type EnumTest struct {
EnumString string `json:"enum_string,omitempty"` EnumString string `json:"enum_string,omitempty"`
EnumInteger int32 `json:"enum_integer,omitempty"` EnumInteger int32 `json:"enum_integer,omitempty"`

View File

@ -12,8 +12,8 @@ package petstore
import ( import (
"io/ioutil" "io/ioutil"
"net/url"
"net/http" "net/http"
"net/url"
"strings" "strings"
"golang.org/x/net/context" "golang.org/x/net/context"
"time" "time"
@ -27,20 +27,19 @@ var (
type FakeApiService service type FakeApiService service
/* FakeApiService
/* FakeApiService Test serialization of outer boolean types
Test serialization of outer boolean types
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param optional (nil or map[string]interface{}) with one or more of: @param optional (nil or map[string]interface{}) with one or more of:
@param "body" (OuterBoolean) Input boolean as post body @param "body" (OuterBoolean) Input boolean as post body
@return OuterBoolean*/ @return OuterBoolean*/
func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterBoolean, *http.Response, error) { func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterBoolean, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Post") localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload OuterBoolean successPayload OuterBoolean
) )
// create path and map variables // create path and map variables
@ -50,9 +49,8 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -61,8 +59,7 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{}
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -92,23 +89,22 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
/* FakeApiService /* FakeApiService
Test serialization of object with outer number type Test serialization of object with outer number type
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param optional (nil or map[string]interface{}) with one or more of: @param optional (nil or map[string]interface{}) with one or more of:
@param "body" (OuterComposite) Input composite as post body @param "body" (OuterComposite) Input composite as post body
@return OuterComposite*/ @return OuterComposite*/
func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterComposite, *http.Response, error) { func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterComposite, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Post") localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload OuterComposite successPayload OuterComposite
) )
// create path and map variables // create path and map variables
@ -118,9 +114,8 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -129,8 +124,7 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{}
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -160,23 +154,22 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
/* FakeApiService /* FakeApiService
Test serialization of outer number types Test serialization of outer number types
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param optional (nil or map[string]interface{}) with one or more of: @param optional (nil or map[string]interface{}) with one or more of:
@param "body" (OuterNumber) Input number as post body @param "body" (OuterNumber) Input number as post body
@return OuterNumber*/ @return OuterNumber*/
func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterNumber, *http.Response, error) { func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterNumber, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Post") localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload OuterNumber successPayload OuterNumber
) )
// create path and map variables // create path and map variables
@ -186,9 +179,8 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -197,8 +189,7 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{}
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -228,23 +219,22 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
/* FakeApiService /* FakeApiService
Test serialization of outer string types Test serialization of outer string types
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param optional (nil or map[string]interface{}) with one or more of: @param optional (nil or map[string]interface{}) with one or more of:
@param "body" (OuterString) Input string as post body @param "body" (OuterString) Input string as post body
@return OuterString*/ @return OuterString*/
func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterString, *http.Response, error) { func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterString, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Post") localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload OuterString successPayload OuterString
) )
// create path and map variables // create path and map variables
@ -254,9 +244,8 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -265,8 +254,7 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{}
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -296,22 +284,21 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
/* FakeApiService To test \&quot;client\&quot; model /* FakeApiService To test \&quot;client\&quot; model
To test \&quot;client\&quot; model To test \&quot;client\&quot; model
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param body client model @param body client model
@return Client*/ @return Client*/
func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Client, *http.Response, error) { func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Client, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Patch") localVarHttpMethod = strings.ToUpper("Patch")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload Client successPayload Client
) )
// create path and map variables // create path and map variables
@ -321,9 +308,8 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Clie
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ "application/json", } localVarHttpContentTypes := []string{"application/json"}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -332,9 +318,7 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Clie
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/json"}
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -362,35 +346,34 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Clie
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
/* FakeApiService Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 /* FakeApiService Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param number None @param number None
@param double None @param double None
@param patternWithoutDelimiter None @param patternWithoutDelimiter None
@param byte_ None @param byte_ None
@param optional (nil or map[string]interface{}) with one or more of: @param optional (nil or map[string]interface{}) with one or more of:
@param "integer" (int32) None @param "integer" (int32) None
@param "int32_" (int32) None @param "int32_" (int32) None
@param "int64_" (int64) None @param "int64_" (int64) None
@param "float" (float32) None @param "float" (float32) None
@param "string_" (string) None @param "string_" (string) None
@param "binary" (string) None @param "binary" (string) None
@param "date" (string) None @param "date" (string) None
@param "dateTime" (time.Time) None @param "dateTime" (time.Time) None
@param "password" (string) None @param "password" (string) None
@param "callback" (string) None @param "callback" (string) None
@return */ @return */
func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number float32, double float64, patternWithoutDelimiter string, byte_ string, localVarOptionals map[string]interface{}) ( *http.Response, error) { func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number float32, double float64, patternWithoutDelimiter string, byte_ string, localVarOptionals map[string]interface{}) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Post") localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -399,7 +382,6 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa
localVarHeaderParams := make(map[string]string) localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
if number < 32.1 { if number < 32.1 {
return nil, reportError("number must be greater than 32.1") return nil, reportError("number must be greater than 32.1")
} }
@ -444,7 +426,7 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ "application/xml; charset=utf-8", "application/json; charset=utf-8", } localVarHttpContentTypes := []string{"application/xml; charset=utf-8", "application/json; charset=utf-8"}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -453,10 +435,7 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml; charset=utf-8", "application/json; charset=utf-8"}
"application/xml; charset=utf-8",
"application/json; charset=utf-8",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -511,29 +490,28 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }
/* FakeApiService To test enum parameters /* FakeApiService To test enum parameters
To test enum parameters To test enum parameters
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param optional (nil or map[string]interface{}) with one or more of: @param optional (nil or map[string]interface{}) with one or more of:
@param "enumFormStringArray" ([]string) Form parameter enum test (string array) @param "enumFormStringArray" ([]string) Form parameter enum test (string array)
@param "enumFormString" (string) Form parameter enum test (string) @param "enumFormString" (string) Form parameter enum test (string)
@param "enumHeaderStringArray" ([]string) Header parameter enum test (string array) @param "enumHeaderStringArray" ([]string) Header parameter enum test (string array)
@param "enumHeaderString" (string) Header parameter enum test (string) @param "enumHeaderString" (string) Header parameter enum test (string)
@param "enumQueryStringArray" ([]string) Query parameter enum test (string array) @param "enumQueryStringArray" ([]string) Query parameter enum test (string array)
@param "enumQueryString" (string) Query parameter enum test (string) @param "enumQueryString" (string) Query parameter enum test (string)
@param "enumQueryInteger" (int32) Query parameter enum test (double) @param "enumQueryInteger" (int32) Query parameter enum test (double)
@param "enumQueryDouble" (float64) Query parameter enum test (double) @param "enumQueryDouble" (float64) Query parameter enum test (double)
@return */ @return */
func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptionals map[string]interface{}) ( *http.Response, error) { func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptionals map[string]interface{}) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Get") localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -542,7 +520,6 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona
localVarHeaderParams := make(map[string]string) localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
if err := typeCheckParameter(localVarOptionals["enumFormString"], "string", "enumFormString"); err != nil { if err := typeCheckParameter(localVarOptionals["enumFormString"], "string", "enumFormString"); err != nil {
return nil, err return nil, err
} }
@ -569,7 +546,7 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona
localVarQueryParams.Add("enum_query_integer", parameterToString(localVarTempParam, "")) localVarQueryParams.Add("enum_query_integer", parameterToString(localVarTempParam, ""))
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ "*/*", } localVarHttpContentTypes := []string{"*/*"}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -578,9 +555,7 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"*/*"}
"*/*",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -616,21 +591,20 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }
/* FakeApiService test inline additionalProperties /* FakeApiService test inline additionalProperties
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param param request body @param param request body
@return */ @return */
func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, param interface{}) ( *http.Response, error) { func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, param interface{}) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Post") localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -640,9 +614,8 @@ func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, par
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ "application/json", } localVarHttpContentTypes := []string{"application/json"}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -651,8 +624,7 @@ func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, par
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{}
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -675,22 +647,21 @@ func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, par
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }
/* FakeApiService test json serialization of form data /* FakeApiService test json serialization of form data
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param param field1 @param param field1
@param param2 field2 @param param2 field2
@return */ @return */
func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, param2 string) ( *http.Response, error) { func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, param2 string) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Get") localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -700,9 +671,8 @@ func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, par
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ "application/json", } localVarHttpContentTypes := []string{"application/json"}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -711,8 +681,7 @@ func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, par
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{}
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -735,7 +704,5 @@ func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, par
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }

View File

@ -12,8 +12,8 @@ package petstore
import ( import (
"io/ioutil" "io/ioutil"
"net/url"
"net/http" "net/http"
"net/url"
"strings" "strings"
"golang.org/x/net/context" "golang.org/x/net/context"
"encoding/json" "encoding/json"
@ -26,18 +26,17 @@ var (
type FakeClassnameTags123ApiService service type FakeClassnameTags123ApiService service
/* FakeClassnameTags123ApiService To test class name in snake case /* FakeClassnameTags123ApiService To test class name in snake case
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param body client model @param body client model
@return Client*/ @return Client*/
func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body Client) (Client, *http.Response, error) { func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body Client) (Client, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Patch") localVarHttpMethod = strings.ToUpper("Patch")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload Client successPayload Client
) )
// create path and map variables // create path and map variables
@ -47,9 +46,8 @@ func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ "application/json", } localVarHttpContentTypes := []string{"application/json"}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -58,9 +56,7 @@ func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/json"}
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -100,7 +96,5 @@ func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }

View File

@ -15,7 +15,6 @@ import (
) )
type FormatTest struct { type FormatTest struct {
Integer int32 `json:"integer,omitempty"` Integer int32 `json:"integer,omitempty"`
Int32_ int32 `json:"int32,omitempty"` Int32_ int32 `json:"int32,omitempty"`

View File

@ -11,7 +11,6 @@
package petstore package petstore
type HasOnlyReadOnly struct { type HasOnlyReadOnly struct {
Bar string `json:"bar,omitempty"` Bar string `json:"bar,omitempty"`
Foo string `json:"foo,omitempty"` Foo string `json:"foo,omitempty"`

View File

@ -11,6 +11,5 @@
package petstore package petstore
type List struct { type List struct {
Var123List string `json:"123-list,omitempty"` Var123List string `json:"123-list,omitempty"`
} }

View File

@ -11,7 +11,6 @@
package petstore package petstore
type MapTest struct { type MapTest struct {
MapMapOfString map[string]map[string]string `json:"map_map_of_string,omitempty"` MapMapOfString map[string]map[string]string `json:"map_map_of_string,omitempty"`
MapOfEnumString map[string]string `json:"map_of_enum_string,omitempty"` MapOfEnumString map[string]string `json:"map_of_enum_string,omitempty"`

View File

@ -15,7 +15,6 @@ import (
) )
type MixedPropertiesAndAdditionalPropertiesClass struct { type MixedPropertiesAndAdditionalPropertiesClass struct {
Uuid string `json:"uuid,omitempty"` Uuid string `json:"uuid,omitempty"`
DateTime time.Time `json:"dateTime,omitempty"` DateTime time.Time `json:"dateTime,omitempty"`

View File

@ -12,7 +12,6 @@ package petstore
// Model for testing model name starting with number // Model for testing model name starting with number
type Model200Response struct { type Model200Response struct {
Name int32 `json:"name,omitempty"` Name int32 `json:"name,omitempty"`
Class string `json:"class,omitempty"` Class string `json:"class,omitempty"`

View File

@ -11,7 +11,6 @@
package petstore package petstore
type ModelApiResponse struct { type ModelApiResponse struct {
Code int32 `json:"code,omitempty"` Code int32 `json:"code,omitempty"`
Type_ string `json:"type,omitempty"` Type_ string `json:"type,omitempty"`

View File

@ -12,6 +12,5 @@ package petstore
// Model for testing reserved words // Model for testing reserved words
type ModelReturn struct { type ModelReturn struct {
Return_ int32 `json:"return,omitempty"` Return_ int32 `json:"return,omitempty"`
} }

View File

@ -12,7 +12,6 @@ package petstore
// Model for testing model name same as property name // Model for testing model name same as property name
type Name struct { type Name struct {
Name int32 `json:"name"` Name int32 `json:"name"`
SnakeCase int32 `json:"snake_case,omitempty"` SnakeCase int32 `json:"snake_case,omitempty"`

View File

@ -11,6 +11,5 @@
package petstore package petstore
type NumberOnly struct { type NumberOnly struct {
JustNumber float32 `json:"JustNumber,omitempty"` JustNumber float32 `json:"JustNumber,omitempty"`
} }

View File

@ -15,7 +15,6 @@ import (
) )
type Order struct { type Order struct {
Id int64 `json:"id,omitempty"` Id int64 `json:"id,omitempty"`
PetId int64 `json:"petId,omitempty"` PetId int64 `json:"petId,omitempty"`

View File

@ -11,7 +11,6 @@
package petstore package petstore
type OuterComposite struct { type OuterComposite struct {
MyNumber *OuterNumber `json:"my_number,omitempty"` MyNumber *OuterNumber `json:"my_number,omitempty"`
MyString *OuterString `json:"my_string,omitempty"` MyString *OuterString `json:"my_string,omitempty"`

View File

@ -15,6 +15,8 @@ type OuterEnum string
// List of OuterEnum // List of OuterEnum
const ( const (
PLACED OuterEnum = "placed" PLACED OuterEnum = "placed"
APPROVED OuterEnum = "approved" APPROVED OuterEnum = "approved"
DELIVERED OuterEnum = "delivered" DELIVERED OuterEnum = "delivered"
) )

View File

@ -11,7 +11,6 @@
package petstore package petstore
type Pet struct { type Pet struct {
Id int64 `json:"id,omitempty"` Id int64 `json:"id,omitempty"`
Category *Category `json:"category,omitempty"` Category *Category `json:"category,omitempty"`

View File

@ -12,8 +12,8 @@ package petstore
import ( import (
"io/ioutil" "io/ioutil"
"net/url"
"net/http" "net/http"
"net/url"
"strings" "strings"
"golang.org/x/net/context" "golang.org/x/net/context"
"os" "os"
@ -28,18 +28,17 @@ var (
type PetApiService service type PetApiService service
/* PetApiService Add a new pet to the store /* PetApiService Add a new pet to the store
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param body Pet object that needs to be added to the store @param body Pet object that needs to be added to the store
@return */ @return */
func (a *PetApiService) AddPet(ctx context.Context, body Pet) ( *http.Response, error) { func (a *PetApiService) AddPet(ctx context.Context, body Pet) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Post") localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -49,9 +48,8 @@ func (a *PetApiService) AddPet(ctx context.Context, body Pet) ( *http.Response,
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ "application/json", "application/xml", } localVarHttpContentTypes := []string{"application/json", "application/xml"}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -60,10 +58,7 @@ func (a *PetApiService) AddPet(ctx context.Context, body Pet) ( *http.Response,
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -86,23 +81,22 @@ func (a *PetApiService) AddPet(ctx context.Context, body Pet) ( *http.Response,
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }
/* PetApiService Deletes a pet /* PetApiService Deletes a pet
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param petId Pet id to delete @param petId Pet id to delete
@param optional (nil or map[string]interface{}) with one or more of: @param optional (nil or map[string]interface{}) with one or more of:
@param "apiKey" (string) @param "apiKey" (string)
@return */ @return */
func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOptionals map[string]interface{}) ( *http.Response, error) { func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOptionals map[string]interface{}) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Delete") localVarHttpMethod = strings.ToUpper("Delete")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -112,13 +106,12 @@ func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOpti
localVarHeaderParams := make(map[string]string) localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
if err := typeCheckParameter(localVarOptionals["apiKey"], "string", "apiKey"); err != nil { if err := typeCheckParameter(localVarOptionals["apiKey"], "string", "apiKey"); err != nil {
return nil, err return nil, err
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -127,10 +120,7 @@ func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOpti
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -154,22 +144,21 @@ func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOpti
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }
/* PetApiService Finds Pets by status /* PetApiService Finds Pets by status
Multiple status values can be provided with comma separated strings Multiple status values can be provided with comma separated strings
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param status Status values that need to be considered for filter @param status Status values that need to be considered for filter
@return []Pet*/ @return []Pet*/
func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) ([]Pet, *http.Response, error) { func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) ([]Pet, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Get") localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload []Pet successPayload []Pet
) )
// create path and map variables // create path and map variables
@ -179,10 +168,9 @@ func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) (
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
localVarQueryParams.Add("status", parameterToString(status, "csv")) localVarQueryParams.Add("status", parameterToString(status, "csv"))
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -191,10 +179,7 @@ func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) (
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -220,22 +205,21 @@ func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) (
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
/* PetApiService Finds Pets by tags /* PetApiService Finds Pets by tags
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param tags Tags to filter by @param tags Tags to filter by
@return []Pet*/ @return []Pet*/
func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pet, *http.Response, error) { func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pet, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Get") localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload []Pet successPayload []Pet
) )
// create path and map variables // create path and map variables
@ -245,10 +229,9 @@ func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pe
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
localVarQueryParams.Add("tags", parameterToString(tags, "csv")) localVarQueryParams.Add("tags", parameterToString(tags, "csv"))
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -257,10 +240,7 @@ func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pe
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -286,22 +266,21 @@ func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pe
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
/* PetApiService Find pet by ID /* PetApiService Find pet by ID
Returns a single pet Returns a single pet
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param petId ID of pet to return @param petId ID of pet to return
@return Pet*/ @return Pet*/
func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *http.Response, error) { func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Get") localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload Pet successPayload Pet
) )
// create path and map variables // create path and map variables
@ -312,9 +291,8 @@ func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *htt
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -323,10 +301,7 @@ func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *htt
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -364,21 +339,20 @@ func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *htt
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
/* PetApiService Update an existing pet /* PetApiService Update an existing pet
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param body Pet object that needs to be added to the store @param body Pet object that needs to be added to the store
@return */ @return */
func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) ( *http.Response, error) { func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Put") localVarHttpMethod = strings.ToUpper("Put")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -388,9 +362,8 @@ func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) ( *http.Respons
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ "application/json", "application/xml", } localVarHttpContentTypes := []string{"application/json", "application/xml"}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -399,10 +372,7 @@ func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) ( *http.Respons
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -425,24 +395,23 @@ func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) ( *http.Respons
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }
/* PetApiService Updates a pet in the store with form data /* PetApiService Updates a pet in the store with form data
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param petId ID of pet that needs to be updated @param petId ID of pet that needs to be updated
@param optional (nil or map[string]interface{}) with one or more of: @param optional (nil or map[string]interface{}) with one or more of:
@param "name" (string) Updated name of the pet @param "name" (string) Updated name of the pet
@param "status" (string) Updated status of the pet @param "status" (string) Updated status of the pet
@return */ @return */
func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, localVarOptionals map[string]interface{}) ( *http.Response, error) { func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, localVarOptionals map[string]interface{}) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Post") localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -452,7 +421,6 @@ func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, loca
localVarHeaderParams := make(map[string]string) localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
if err := typeCheckParameter(localVarOptionals["name"], "string", "name"); err != nil { if err := typeCheckParameter(localVarOptionals["name"], "string", "name"); err != nil {
return nil, err return nil, err
} }
@ -461,7 +429,7 @@ func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, loca
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ "application/x-www-form-urlencoded", } localVarHttpContentTypes := []string{"application/x-www-form-urlencoded"}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -470,10 +438,7 @@ func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, loca
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -500,25 +465,24 @@ func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, loca
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }
/* PetApiService uploads an image /* PetApiService uploads an image
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param petId ID of pet to update @param petId ID of pet to update
@param optional (nil or map[string]interface{}) with one or more of: @param optional (nil or map[string]interface{}) with one or more of:
@param "additionalMetadata" (string) Additional data to pass to server @param "additionalMetadata" (string) Additional data to pass to server
@param "file" (*os.File) file to upload @param "file" (*os.File) file to upload
@return ModelApiResponse*/ @return ModelApiResponse*/
func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOptionals map[string]interface{}) (ModelApiResponse, *http.Response, error) { func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOptionals map[string]interface{}) (ModelApiResponse, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Post") localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload ModelApiResponse successPayload ModelApiResponse
) )
// create path and map variables // create path and map variables
@ -528,13 +492,12 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt
localVarHeaderParams := make(map[string]string) localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
if err := typeCheckParameter(localVarOptionals["additionalMetadata"], "string", "additionalMetadata"); err != nil { if err := typeCheckParameter(localVarOptionals["additionalMetadata"], "string", "additionalMetadata"); err != nil {
return successPayload, nil, err return successPayload, nil, err
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ "multipart/form-data", } localVarHttpContentTypes := []string{"multipart/form-data"}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -543,9 +506,7 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/json"}
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -584,7 +545,5 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }

View File

@ -11,7 +11,6 @@
package petstore package petstore
type ReadOnlyFirst struct { type ReadOnlyFirst struct {
Bar string `json:"bar,omitempty"` Bar string `json:"bar,omitempty"`
Baz string `json:"baz,omitempty"` Baz string `json:"baz,omitempty"`

View File

@ -11,6 +11,5 @@
package petstore package petstore
type SpecialModelName struct { type SpecialModelName struct {
SpecialPropertyName int64 `json:"$special[property.name],omitempty"` SpecialPropertyName int64 `json:"$special[property.name],omitempty"`
} }

View File

@ -12,8 +12,8 @@ package petstore
import ( import (
"io/ioutil" "io/ioutil"
"net/url"
"net/http" "net/http"
"net/url"
"strings" "strings"
"golang.org/x/net/context" "golang.org/x/net/context"
"encoding/json" "encoding/json"
@ -27,18 +27,17 @@ var (
type StoreApiService service type StoreApiService service
/* StoreApiService Delete purchase order by ID /* StoreApiService Delete purchase order by ID
For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param orderId ID of the order that needs to be deleted @param orderId ID of the order that needs to be deleted
@return */ @return */
func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) ( *http.Response, error) { func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Delete") localVarHttpMethod = strings.ToUpper("Delete")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -49,9 +48,8 @@ func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) ( *ht
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -60,10 +58,7 @@ func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) ( *ht
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -84,21 +79,20 @@ func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) ( *ht
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }
/* StoreApiService Returns pet inventories by status /* StoreApiService Returns pet inventories by status
Returns a map of status codes to quantities Returns a map of status codes to quantities
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@return map[string]int32*/ @return map[string]int32*/
func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32, *http.Response, error) { func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Get") localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload map[string]int32 successPayload map[string]int32
) )
// create path and map variables // create path and map variables
@ -108,9 +102,8 @@ func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32,
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -119,9 +112,7 @@ func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32,
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/json"}
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -159,22 +150,21 @@ func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32,
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
/* StoreApiService Find purchase order by ID /* StoreApiService Find purchase order by ID
For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param orderId ID of pet that needs to be fetched @param orderId ID of pet that needs to be fetched
@return Order*/ @return Order*/
func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Order, *http.Response, error) { func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Order, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Get") localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload Order successPayload Order
) )
// create path and map variables // create path and map variables
@ -184,7 +174,6 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde
localVarHeaderParams := make(map[string]string) localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
if orderId < 1 { if orderId < 1 {
return successPayload, nil, reportError("orderId must be greater than 1") return successPayload, nil, reportError("orderId must be greater than 1")
} }
@ -193,7 +182,7 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -202,10 +191,7 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -231,22 +217,21 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
/* StoreApiService Place an order for a pet /* StoreApiService Place an order for a pet
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param body order placed for purchasing the pet @param body order placed for purchasing the pet
@return Order*/ @return Order*/
func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, *http.Response, error) { func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Post") localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload Order successPayload Order
) )
// create path and map variables // create path and map variables
@ -256,9 +241,8 @@ func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, *
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -267,10 +251,7 @@ func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, *
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -298,7 +279,5 @@ func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, *
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }

View File

@ -11,7 +11,6 @@
package petstore package petstore
type Tag struct { type Tag struct {
Id int64 `json:"id,omitempty"` Id int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`

View File

@ -11,7 +11,6 @@
package petstore package petstore
type User struct { type User struct {
Id int64 `json:"id,omitempty"` Id int64 `json:"id,omitempty"`
Username string `json:"username,omitempty"` Username string `json:"username,omitempty"`

View File

@ -12,8 +12,8 @@ package petstore
import ( import (
"io/ioutil" "io/ioutil"
"net/url"
"net/http" "net/http"
"net/url"
"strings" "strings"
"golang.org/x/net/context" "golang.org/x/net/context"
"encoding/json" "encoding/json"
@ -27,18 +27,17 @@ var (
type UserApiService service type UserApiService service
/* UserApiService Create user /* UserApiService Create user
This can only be done by the logged in user. This can only be done by the logged in user.
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param body Created user object @param body Created user object
@return */ @return */
func (a *UserApiService) CreateUser(ctx context.Context, body User) ( *http.Response, error) { func (a *UserApiService) CreateUser(ctx context.Context, body User) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Post") localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -48,9 +47,8 @@ func (a *UserApiService) CreateUser(ctx context.Context, body User) ( *http.Resp
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -59,10 +57,7 @@ func (a *UserApiService) CreateUser(ctx context.Context, body User) ( *http.Resp
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -85,21 +80,20 @@ func (a *UserApiService) CreateUser(ctx context.Context, body User) ( *http.Resp
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }
/* UserApiService Creates list of users with given input array /* UserApiService Creates list of users with given input array
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param body List of user object @param body List of user object
@return */ @return */
func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []User) ( *http.Response, error) { func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []User) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Post") localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -109,9 +103,8 @@ func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []U
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -120,10 +113,7 @@ func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []U
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -146,21 +136,20 @@ func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []U
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }
/* UserApiService Creates list of users with given input array /* UserApiService Creates list of users with given input array
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param body List of user object @param body List of user object
@return */ @return */
func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []User) ( *http.Response, error) { func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []User) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Post") localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -170,9 +159,8 @@ func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []Us
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -181,10 +169,7 @@ func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []Us
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -207,21 +192,20 @@ func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []Us
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }
/* UserApiService Delete user /* UserApiService Delete user
This can only be done by the logged in user. This can only be done by the logged in user.
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param username The name that needs to be deleted @param username The name that needs to be deleted
@return */ @return */
func (a *UserApiService) DeleteUser(ctx context.Context, username string) ( *http.Response, error) { func (a *UserApiService) DeleteUser(ctx context.Context, username string) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Delete") localVarHttpMethod = strings.ToUpper("Delete")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -232,9 +216,8 @@ func (a *UserApiService) DeleteUser(ctx context.Context, username string) ( *htt
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -243,10 +226,7 @@ func (a *UserApiService) DeleteUser(ctx context.Context, username string) ( *htt
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -267,22 +247,21 @@ func (a *UserApiService) DeleteUser(ctx context.Context, username string) ( *htt
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }
/* UserApiService Get user by user name /* UserApiService Get user by user name
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param username The name that needs to be fetched. Use user1 for testing. @param username The name that needs to be fetched. Use user1 for testing.
@return User*/ @return User*/
func (a *UserApiService) GetUserByName(ctx context.Context, username string) (User, *http.Response, error) { func (a *UserApiService) GetUserByName(ctx context.Context, username string) (User, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Get") localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload User successPayload User
) )
// create path and map variables // create path and map variables
@ -293,9 +272,8 @@ func (a *UserApiService) GetUserByName(ctx context.Context, username string) (Us
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -304,10 +282,7 @@ func (a *UserApiService) GetUserByName(ctx context.Context, username string) (Us
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -333,23 +308,22 @@ func (a *UserApiService) GetUserByName(ctx context.Context, username string) (Us
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
/* UserApiService Logs user into the system /* UserApiService Logs user into the system
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param username The user name for login @param username The user name for login
@param password The password for login in clear text @param password The password for login in clear text
@return string*/ @return string*/
func (a *UserApiService) LoginUser(ctx context.Context, username string, password string) (string, *http.Response, error) { func (a *UserApiService) LoginUser(ctx context.Context, username string, password string) (string, *http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Get") localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
successPayload string successPayload string
) )
// create path and map variables // create path and map variables
@ -359,11 +333,10 @@ func (a *UserApiService) LoginUser(ctx context.Context, username string, passwor
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
localVarQueryParams.Add("username", parameterToString(username, "")) localVarQueryParams.Add("username", parameterToString(username, ""))
localVarQueryParams.Add("password", parameterToString(password, "")) localVarQueryParams.Add("password", parameterToString(password, ""))
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -372,10 +345,7 @@ func (a *UserApiService) LoginUser(ctx context.Context, username string, passwor
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -401,20 +371,19 @@ func (a *UserApiService) LoginUser(ctx context.Context, username string, passwor
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
return successPayload, localVarHttpResponse, err return successPayload, localVarHttpResponse, err
} }
/* UserApiService Logs out current logged in user session /* UserApiService Logs out current logged in user session
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@return */ @return */
func (a *UserApiService) LogoutUser(ctx context.Context) ( *http.Response, error) { func (a *UserApiService) LogoutUser(ctx context.Context) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Get") localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -424,9 +393,8 @@ func (a *UserApiService) LogoutUser(ctx context.Context) ( *http.Response, error
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -435,10 +403,7 @@ func (a *UserApiService) LogoutUser(ctx context.Context) ( *http.Response, error
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -459,22 +424,21 @@ func (a *UserApiService) LogoutUser(ctx context.Context) ( *http.Response, error
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }
/* UserApiService Updated user /* UserApiService Updated user
This can only be done by the logged in user. This can only be done by the logged in user.
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param username name that need to be deleted @param username name that need to be deleted
@param body Updated user object @param body Updated user object
@return */ @return */
func (a *UserApiService) UpdateUser(ctx context.Context, username string, body User) ( *http.Response, error) { func (a *UserApiService) UpdateUser(ctx context.Context, username string, body User) (*http.Response, error) {
var ( var (
localVarHttpMethod = strings.ToUpper("Put") localVarHttpMethod = strings.ToUpper("Put")
localVarPostBody interface{} localVarPostBody interface{}
localVarFileName string localVarFileName string
localVarFileBytes []byte localVarFileBytes []byte
) )
// create path and map variables // create path and map variables
@ -485,9 +449,8 @@ func (a *UserApiService) UpdateUser(ctx context.Context, username string, body U
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string{ } localVarHttpContentTypes := []string{}
// set Content-Type header // set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
@ -496,10 +459,7 @@ func (a *UserApiService) UpdateUser(ctx context.Context, username string, body U
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string{ localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
"application/xml",
"application/json",
}
// set Accept header // set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
@ -522,7 +482,5 @@ func (a *UserApiService) UpdateUser(ctx context.Context, username string, body U
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
} }
return localVarHttpResponse, err return localVarHttpResponse, err
} }