mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
Fix data type shadowing
This commit is contained in:
parent
d8165b0cfb
commit
622a75b2ce
@ -35,6 +35,21 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
"array")
|
||||
);
|
||||
|
||||
setReservedWordsLowerCase(
|
||||
Arrays.asList(
|
||||
// data type
|
||||
"string", "bool", "uint", "uint8", "uint16", "uint32", "uint64",
|
||||
"int", "int8", "int16", "int32", "int64", "float32", "float64",
|
||||
"complex64", "complex128", "rune", "byte", "uintptr",
|
||||
|
||||
"break", "default", "func", "interface", "select",
|
||||
"case", "defer", "go", "map", "struct",
|
||||
"chan", "else", "goto", "package", "switch",
|
||||
"const", "fallthrough", "if", "range", "type",
|
||||
"continue", "for", "import", "return", "var", "error", "nil")
|
||||
// Added "error" as it's used so frequently that it may as well be a keyword
|
||||
);
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"string",
|
||||
@ -123,9 +138,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
// pet_id => PetId
|
||||
name = camelize(name);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name))
|
||||
// for reserved word append _
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as variable name. Renamed to "+ escapeReservedWord(name));
|
||||
name = escapeReservedWord(name);
|
||||
}
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (name.matches("^\\d.*"))
|
||||
@ -134,15 +151,27 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isReservedWord(String word) {
|
||||
return word != null && reservedWords.contains(word);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// params should be lowerCamelCase. E.g. "person Person", instead of
|
||||
// "Person Person".
|
||||
//
|
||||
name = camelize(toVarName(name), true);
|
||||
|
||||
// REVISIT: Actually, for idiomatic go, the param name should
|
||||
// really should just be a letter, e.g. "p Person"), but we'll get
|
||||
// around to that some other time... Maybe.
|
||||
return camelize(toVarName(name), true);
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as parameter name. Renamed to "+ name + "_");
|
||||
name = name + "_";
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,21 +35,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
// default HIDE_GENERATION_TIMESTAMP to true
|
||||
hideGenerationTimestamp = Boolean.TRUE;
|
||||
|
||||
setReservedWordsLowerCase(
|
||||
Arrays.asList(
|
||||
// data type
|
||||
"string", "bool", "uint", "uint8", "uint16", "uint32", "uint64",
|
||||
"int", "int8", "int16", "int32", "int64", "float32", "float64",
|
||||
"complex64", "complex128", "rune", "byte", "uintptr",
|
||||
|
||||
"break", "default", "func", "interface", "select",
|
||||
"case", "defer", "go", "map", "struct",
|
||||
"chan", "else", "goto", "package", "switch",
|
||||
"const", "fallthrough", "if", "range", "type",
|
||||
"continue", "for", "import", "return", "var", "error", "ApiResponse", "nil")
|
||||
// Added "error" as it's used so frequently that it may as well be a keyword
|
||||
);
|
||||
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Go package version.")
|
||||
.defaultValue("1.0.0"));
|
||||
cliOptions.add(CliOption.newBoolean(WITH_XML, "whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)"));
|
||||
|
@ -60,6 +60,7 @@ Class | Method | HTTP request | Description
|
||||
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
||||
- [Animal](docs/Animal.md)
|
||||
- [AnimalFarm](docs/AnimalFarm.md)
|
||||
- [ApiResponse](docs/ApiResponse.md)
|
||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||
- [ArrayTest](docs/ArrayTest.md)
|
||||
@ -78,8 +79,6 @@ Class | Method | HTTP request | Description
|
||||
- [MapTest](docs/MapTest.md)
|
||||
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||
- [Model200Response](docs/Model200Response.md)
|
||||
- [ModelApiResponse](docs/ModelApiResponse.md)
|
||||
- [ModelReturn](docs/ModelReturn.md)
|
||||
- [Name](docs/Name.md)
|
||||
- [NumberOnly](docs/NumberOnly.md)
|
||||
- [Order](docs/Order.md)
|
||||
@ -87,6 +86,7 @@ Class | Method | HTTP request | Description
|
||||
- [OuterEnum](docs/OuterEnum.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||
- [Return](docs/Return.md)
|
||||
- [SpecialModelName](docs/SpecialModelName.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [User](docs/User.md)
|
||||
|
@ -100,11 +100,11 @@ paths:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default: available
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
default: available
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
@ -613,20 +613,20 @@ paths:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default: $
|
||||
enum:
|
||||
- '>'
|
||||
- $
|
||||
default: $
|
||||
- name: enum_header_string
|
||||
in: header
|
||||
description: Header parameter enum test (string)
|
||||
schema:
|
||||
type: string
|
||||
default: -efg
|
||||
enum:
|
||||
- _abc
|
||||
- -efg
|
||||
- (xyz)
|
||||
default: -efg
|
||||
- name: enum_query_string_array
|
||||
in: query
|
||||
description: Query parameter enum test (string array)
|
||||
@ -635,20 +635,20 @@ paths:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default: $
|
||||
enum:
|
||||
- '>'
|
||||
- $
|
||||
default: $
|
||||
- name: enum_query_string
|
||||
in: query
|
||||
description: Query parameter enum test (string)
|
||||
schema:
|
||||
type: string
|
||||
default: -efg
|
||||
enum:
|
||||
- _abc
|
||||
- -efg
|
||||
- (xyz)
|
||||
default: -efg
|
||||
- name: enum_query_integer
|
||||
in: query
|
||||
description: Query parameter enum test (double)
|
||||
@ -677,18 +677,18 @@ paths:
|
||||
description: Form parameter enum test (string array)
|
||||
items:
|
||||
type: string
|
||||
default: $
|
||||
enum:
|
||||
- '>'
|
||||
- $
|
||||
default: $
|
||||
enum_form_string:
|
||||
type: string
|
||||
description: Form parameter enum test (string)
|
||||
default: -efg
|
||||
enum:
|
||||
- _abc
|
||||
- -efg
|
||||
- (xyz)
|
||||
default: -efg
|
||||
responses:
|
||||
400:
|
||||
description: Invalid request
|
||||
@ -1100,11 +1100,11 @@ components:
|
||||
name: Name
|
||||
EnumClass:
|
||||
type: string
|
||||
default: -efg
|
||||
enum:
|
||||
- _abc
|
||||
- -efg
|
||||
- (xyz)
|
||||
default: -efg
|
||||
List:
|
||||
type: object
|
||||
properties:
|
||||
|
@ -11,13 +11,13 @@
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/antihax/optional"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"context"
|
||||
"github.com/antihax/optional"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Linger please
|
||||
@ -27,7 +27,7 @@ var (
|
||||
|
||||
type FakeApiService service
|
||||
|
||||
/*
|
||||
/*
|
||||
FakeApiService
|
||||
Test serialization of outer boolean types
|
||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
@ -37,15 +37,15 @@ Test serialization of outer boolean types
|
||||
*/
|
||||
|
||||
type FakeOuterBooleanSerializeOpts struct {
|
||||
BooleanPostBody optional.Bool
|
||||
BooleanPostBody optional.Bool
|
||||
}
|
||||
|
||||
func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVarOptionals *FakeOuterBooleanSerializeOpts) (bool, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarReturnValue bool
|
||||
)
|
||||
|
||||
@ -96,26 +96,26 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar
|
||||
|
||||
if localVarHttpResponse.StatusCode < 300 {
|
||||
// If we succeed, return the data, otherwise pass on to decode error.
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err == nil {
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
if err == nil {
|
||||
return localVarReturnValue, localVarHttpResponse, err
|
||||
}
|
||||
}
|
||||
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
newErr := GenericSwaggerError{
|
||||
body: localVarBody,
|
||||
body: localVarBody,
|
||||
error: localVarHttpResponse.Status,
|
||||
}
|
||||
if localVarHttpResponse.StatusCode == 200 {
|
||||
var v bool
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
newErr.model = v
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
newErr.model = v
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
@ -123,7 +123,7 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar
|
||||
return localVarReturnValue, localVarHttpResponse, nil
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
FakeApiService
|
||||
Test serialization of object with outer number type
|
||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
@ -133,15 +133,15 @@ Test serialization of object with outer number type
|
||||
*/
|
||||
|
||||
type FakeOuterCompositeSerializeOpts struct {
|
||||
OuterComposite optional.Interface
|
||||
OuterComposite optional.Interface
|
||||
}
|
||||
|
||||
func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localVarOptionals *FakeOuterCompositeSerializeOpts) (OuterComposite, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarReturnValue OuterComposite
|
||||
)
|
||||
|
||||
@ -196,26 +196,26 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV
|
||||
|
||||
if localVarHttpResponse.StatusCode < 300 {
|
||||
// If we succeed, return the data, otherwise pass on to decode error.
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err == nil {
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
if err == nil {
|
||||
return localVarReturnValue, localVarHttpResponse, err
|
||||
}
|
||||
}
|
||||
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
newErr := GenericSwaggerError{
|
||||
body: localVarBody,
|
||||
body: localVarBody,
|
||||
error: localVarHttpResponse.Status,
|
||||
}
|
||||
if localVarHttpResponse.StatusCode == 200 {
|
||||
var v OuterComposite
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
newErr.model = v
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
newErr.model = v
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
@ -223,7 +223,7 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV
|
||||
return localVarReturnValue, localVarHttpResponse, nil
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
FakeApiService
|
||||
Test serialization of outer number types
|
||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
@ -233,15 +233,15 @@ Test serialization of outer number types
|
||||
*/
|
||||
|
||||
type FakeOuterNumberSerializeOpts struct {
|
||||
Body optional.Float32
|
||||
Body optional.Float32
|
||||
}
|
||||
|
||||
func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarOptionals *FakeOuterNumberSerializeOpts) (float32, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarReturnValue float32
|
||||
)
|
||||
|
||||
@ -292,26 +292,26 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO
|
||||
|
||||
if localVarHttpResponse.StatusCode < 300 {
|
||||
// If we succeed, return the data, otherwise pass on to decode error.
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err == nil {
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
if err == nil {
|
||||
return localVarReturnValue, localVarHttpResponse, err
|
||||
}
|
||||
}
|
||||
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
newErr := GenericSwaggerError{
|
||||
body: localVarBody,
|
||||
body: localVarBody,
|
||||
error: localVarHttpResponse.Status,
|
||||
}
|
||||
if localVarHttpResponse.StatusCode == 200 {
|
||||
var v float32
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
newErr.model = v
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
newErr.model = v
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
@ -319,7 +319,7 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO
|
||||
return localVarReturnValue, localVarHttpResponse, nil
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
FakeApiService
|
||||
Test serialization of outer string types
|
||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
@ -329,15 +329,15 @@ Test serialization of outer string types
|
||||
*/
|
||||
|
||||
type FakeOuterStringSerializeOpts struct {
|
||||
Body optional.String
|
||||
Body optional.String
|
||||
}
|
||||
|
||||
func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarOptionals *FakeOuterStringSerializeOpts) (string, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarReturnValue string
|
||||
)
|
||||
|
||||
@ -388,26 +388,26 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO
|
||||
|
||||
if localVarHttpResponse.StatusCode < 300 {
|
||||
// If we succeed, return the data, otherwise pass on to decode error.
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err == nil {
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
if err == nil {
|
||||
return localVarReturnValue, localVarHttpResponse, err
|
||||
}
|
||||
}
|
||||
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
newErr := GenericSwaggerError{
|
||||
body: localVarBody,
|
||||
body: localVarBody,
|
||||
error: localVarHttpResponse.Status,
|
||||
}
|
||||
if localVarHttpResponse.StatusCode == 200 {
|
||||
var v string
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
newErr.model = v
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
newErr.model = v
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
@ -415,7 +415,7 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO
|
||||
return localVarReturnValue, localVarHttpResponse, nil
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
FakeApiService
|
||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param query
|
||||
@ -474,7 +474,7 @@ func (a *FakeApiService) TestBodyWithQueryParams(ctx context.Context, query stri
|
||||
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
newErr := GenericSwaggerError{
|
||||
body: localVarBody,
|
||||
body: localVarBody,
|
||||
error: localVarHttpResponse.Status,
|
||||
}
|
||||
return localVarHttpResponse, newErr
|
||||
@ -483,7 +483,7 @@ func (a *FakeApiService) TestBodyWithQueryParams(ctx context.Context, query stri
|
||||
return localVarHttpResponse, nil
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
FakeApiService To test \"client\" model
|
||||
To test \"client\" model
|
||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
@ -492,10 +492,10 @@ To test \"client\" model
|
||||
*/
|
||||
func (a *FakeApiService) TestClientModel(ctx context.Context, client Client) (Client, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Patch")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarHttpMethod = strings.ToUpper("Patch")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarReturnValue Client
|
||||
)
|
||||
|
||||
@ -543,26 +543,26 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, client Client) (Cl
|
||||
|
||||
if localVarHttpResponse.StatusCode < 300 {
|
||||
// If we succeed, return the data, otherwise pass on to decode error.
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err == nil {
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
if err == nil {
|
||||
return localVarReturnValue, localVarHttpResponse, err
|
||||
}
|
||||
}
|
||||
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
newErr := GenericSwaggerError{
|
||||
body: localVarBody,
|
||||
body: localVarBody,
|
||||
error: localVarHttpResponse.Status,
|
||||
}
|
||||
if localVarHttpResponse.StatusCode == 200 {
|
||||
var v Client
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
newErr.model = v
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
newErr.model = v
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
}
|
||||
@ -570,20 +570,20 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, client Client) (Cl
|
||||
return localVarReturnValue, localVarHttpResponse, nil
|
||||
}
|
||||
|
||||
/*
|
||||
FakeApiService Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
/*
|
||||
FakeApiService Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param number None
|
||||
* @param double None
|
||||
* @param patternWithoutDelimiter None
|
||||
* @param byte None
|
||||
* @param byte_ None
|
||||
* @param optional nil or *TestEndpointParametersOpts - Optional Parameters:
|
||||
* @param "Integer" (optional.Int32) - None
|
||||
* @param "Int32" (optional.Int32) - None
|
||||
* @param "Int64" (optional.Int64) - None
|
||||
* @param "Int32_" (optional.Int32) - None
|
||||
* @param "Int64_" (optional.Int64) - None
|
||||
* @param "Float" (optional.Float32) - None
|
||||
* @param "String" (optional.String) - None
|
||||
* @param "String_" (optional.String) - None
|
||||
* @param "Binary" (optional.Interface of *os.File) - None
|
||||
* @param "Date" (optional.String) - None
|
||||
* @param "DateTime" (optional.Time) - None
|
||||
@ -592,19 +592,19 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン
|
||||
*/
|
||||
|
||||
type TestEndpointParametersOpts struct {
|
||||
Integer optional.Int32
|
||||
Int32 optional.Int32
|
||||
Int64 optional.Int64
|
||||
Float optional.Float32
|
||||
String optional.String
|
||||
Binary optional.Interface
|
||||
Date optional.String
|
||||
DateTime optional.Time
|
||||
Password optional.String
|
||||
Callback optional.String
|
||||
Integer optional.Int32
|
||||
Int32_ optional.Int32
|
||||
Int64_ optional.Int64
|
||||
Float optional.Float32
|
||||
String_ optional.String
|
||||
Binary optional.Interface
|
||||
Date optional.String
|
||||
DateTime optional.Time
|
||||
Password optional.String
|
||||
Callback optional.String
|
||||
}
|
||||
|
||||
func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number float32, double float64, patternWithoutDelimiter string, byte string, localVarOptionals *TestEndpointParametersOpts) (*http.Response, error) {
|
||||
func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number float32, double float64, patternWithoutDelimiter string, byte_ string, localVarOptionals *TestEndpointParametersOpts) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
@ -651,28 +651,28 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa
|
||||
if localVarOptionals != nil && localVarOptionals.Integer.IsSet() {
|
||||
localVarFormParams.Add("integer", parameterToString(localVarOptionals.Integer.Value(), ""))
|
||||
}
|
||||
if localVarOptionals != nil && localVarOptionals.Int32.IsSet() {
|
||||
localVarFormParams.Add("int32", parameterToString(localVarOptionals.Int32.Value(), ""))
|
||||
if localVarOptionals != nil && localVarOptionals.Int32_.IsSet() {
|
||||
localVarFormParams.Add("int32", parameterToString(localVarOptionals.Int32_.Value(), ""))
|
||||
}
|
||||
if localVarOptionals != nil && localVarOptionals.Int64.IsSet() {
|
||||
localVarFormParams.Add("int64", parameterToString(localVarOptionals.Int64.Value(), ""))
|
||||
if localVarOptionals != nil && localVarOptionals.Int64_.IsSet() {
|
||||
localVarFormParams.Add("int64", parameterToString(localVarOptionals.Int64_.Value(), ""))
|
||||
}
|
||||
localVarFormParams.Add("number", parameterToString(number, ""))
|
||||
if localVarOptionals != nil && localVarOptionals.Float.IsSet() {
|
||||
localVarFormParams.Add("float", parameterToString(localVarOptionals.Float.Value(), ""))
|
||||
}
|
||||
localVarFormParams.Add("double", parameterToString(double, ""))
|
||||
if localVarOptionals != nil && localVarOptionals.String.IsSet() {
|
||||
localVarFormParams.Add("string", parameterToString(localVarOptionals.String.Value(), ""))
|
||||
if localVarOptionals != nil && localVarOptionals.String_.IsSet() {
|
||||
localVarFormParams.Add("string", parameterToString(localVarOptionals.String_.Value(), ""))
|
||||
}
|
||||
localVarFormParams.Add("pattern_without_delimiter", parameterToString(patternWithoutDelimiter, ""))
|
||||
localVarFormParams.Add("byte", parameterToString(byte, ""))
|
||||
localVarFormParams.Add("byte", parameterToString(byte_, ""))
|
||||
var localVarFile *os.File
|
||||
if localVarOptionals != nil && localVarOptionals.Binary.IsSet() {
|
||||
localVarFileOk := false
|
||||
localVarFile, localVarFileOk = localVarOptionals.Binary.Value().(*os.File)
|
||||
if !localVarFileOk {
|
||||
return nil, reportError("binary should be *os.File")
|
||||
return nil, reportError("binary should be *os.File")
|
||||
}
|
||||
}
|
||||
if localVarFile != nil {
|
||||
@ -711,7 +711,7 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa
|
||||
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
newErr := GenericSwaggerError{
|
||||
body: localVarBody,
|
||||
body: localVarBody,
|
||||
error: localVarHttpResponse.Status,
|
||||
}
|
||||
return localVarHttpResponse, newErr
|
||||
@ -720,7 +720,7 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa
|
||||
return localVarHttpResponse, nil
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
FakeApiService To test enum parameters
|
||||
To test enum parameters
|
||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
@ -736,14 +736,14 @@ To test enum parameters
|
||||
*/
|
||||
|
||||
type TestEnumParametersOpts struct {
|
||||
EnumHeaderStringArray optional.Interface
|
||||
EnumHeaderString optional.String
|
||||
EnumQueryStringArray optional.Interface
|
||||
EnumQueryString optional.String
|
||||
EnumQueryInteger optional.Int32
|
||||
EnumQueryDouble optional.Float64
|
||||
EnumFormStringArray optional.Interface
|
||||
EnumFormString optional.String
|
||||
EnumHeaderStringArray optional.Interface
|
||||
EnumHeaderString optional.String
|
||||
EnumQueryStringArray optional.Interface
|
||||
EnumQueryString optional.String
|
||||
EnumQueryInteger optional.Int32
|
||||
EnumQueryDouble optional.Float64
|
||||
EnumFormStringArray optional.Interface
|
||||
EnumFormString optional.String
|
||||
}
|
||||
|
||||
func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptionals *TestEnumParametersOpts) (*http.Response, error) {
|
||||
@ -820,7 +820,7 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona
|
||||
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
newErr := GenericSwaggerError{
|
||||
body: localVarBody,
|
||||
body: localVarBody,
|
||||
error: localVarHttpResponse.Status,
|
||||
}
|
||||
return localVarHttpResponse, newErr
|
||||
@ -829,7 +829,7 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona
|
||||
return localVarHttpResponse, nil
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
FakeApiService test inline additionalProperties
|
||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param requestBody request body
|
||||
@ -886,7 +886,7 @@ func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, req
|
||||
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
newErr := GenericSwaggerError{
|
||||
body: localVarBody,
|
||||
body: localVarBody,
|
||||
error: localVarHttpResponse.Status,
|
||||
}
|
||||
return localVarHttpResponse, newErr
|
||||
@ -895,7 +895,7 @@ func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, req
|
||||
return localVarHttpResponse, nil
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
FakeApiService test json serialization of form data
|
||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param param field1
|
||||
@ -953,7 +953,7 @@ func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, par
|
||||
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
newErr := GenericSwaggerError{
|
||||
body: localVarBody,
|
||||
body: localVarBody,
|
||||
error: localVarHttpResponse.Status,
|
||||
}
|
||||
return localVarHttpResponse, newErr
|
||||
|
@ -594,7 +594,7 @@ PetApiService uploads an image
|
||||
* @param optional nil or *UploadFileOpts - Optional Parameters:
|
||||
* @param "AdditionalMetadata" (optional.String) - Additional data to pass to server
|
||||
* @param "File" (optional.Interface of *os.File) - file to upload
|
||||
@return ModelApiResponse
|
||||
@return ApiResponse
|
||||
*/
|
||||
|
||||
type UploadFileOpts struct {
|
||||
@ -602,13 +602,13 @@ type UploadFileOpts struct {
|
||||
File optional.Interface
|
||||
}
|
||||
|
||||
func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOptionals *UploadFileOpts) (ModelApiResponse, *http.Response, error) {
|
||||
func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOptionals *UploadFileOpts) (ApiResponse, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarReturnValue ModelApiResponse
|
||||
localVarReturnValue ApiResponse
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
@ -683,7 +683,7 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt
|
||||
error: localVarHttpResponse.Status,
|
||||
}
|
||||
if localVarHttpResponse.StatusCode == 200 {
|
||||
var v ModelApiResponse
|
||||
var v ApiResponse
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
|
12
samples/client/petstore/go/go-petstore/docs/ApiResponse.md
Normal file
12
samples/client/petstore/go/go-petstore/docs/ApiResponse.md
Normal file
@ -0,0 +1,12 @@
|
||||
# ApiResponse
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Code** | **int32** | | [optional] [default to null]
|
||||
**Type** | **string** | | [optional] [default to null]
|
||||
**Message** | **string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -212,7 +212,7 @@ No authorization required
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **TestEndpointParameters**
|
||||
> TestEndpointParameters(ctx, number, double, patternWithoutDelimiter, byte, optional)
|
||||
> TestEndpointParameters(ctx, number, double, patternWithoutDelimiter, byte_, optional)
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
@ -225,7 +225,7 @@ Name | Type | Description | Notes
|
||||
**number** | **float32**| None |
|
||||
**double** | **float64**| None |
|
||||
**patternWithoutDelimiter** | **string**| None |
|
||||
**byte** | **string**| None |
|
||||
**byte_** | **string**| None |
|
||||
**optional** | ***TestEndpointParametersOpts** | optional parameters | nil if no parameters
|
||||
|
||||
### Optional Parameters
|
||||
@ -238,10 +238,10 @@ Name | Type | Description | Notes
|
||||
|
||||
|
||||
**integer** | **optional.Int32**| None |
|
||||
**int32** | **optional.Int32**| None |
|
||||
**int64** | **optional.Int64**| None |
|
||||
**int32_** | **optional.Int32**| None |
|
||||
**int64_** | **optional.Int64**| None |
|
||||
**float** | **optional.Float32**| None |
|
||||
**string** | **optional.String**| None |
|
||||
**string_** | **optional.String**| None |
|
||||
**binary** | **optional.Interface of *os.File****optional.*os.File**| None |
|
||||
**date** | **optional.String**| None |
|
||||
**dateTime** | **optional.Time**| None |
|
||||
|
@ -4,13 +4,13 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Integer** | **int32** | | [optional] [default to null]
|
||||
**Int32_** | **int32** | | [optional] [default to null]
|
||||
**Int64_** | **int64** | | [optional] [default to null]
|
||||
**Int32** | **int32** | | [optional] [default to null]
|
||||
**Int64** | **int64** | | [optional] [default to null]
|
||||
**Number** | **float32** | | [default to null]
|
||||
**Float** | **float32** | | [optional] [default to null]
|
||||
**Double** | **float64** | | [optional] [default to null]
|
||||
**String_** | **string** | | [optional] [default to null]
|
||||
**Byte_** | **string** | | [default to null]
|
||||
**String** | **string** | | [optional] [default to null]
|
||||
**Byte** | **string** | | [default to null]
|
||||
**Binary** | [****os.File**](*os.File.md) | | [optional] [default to null]
|
||||
**Date** | **string** | | [default to null]
|
||||
**DateTime** | [**time.Time**](time.Time.md) | | [optional] [default to null]
|
||||
|
@ -5,7 +5,7 @@ Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Uuid** | **string** | | [optional] [default to null]
|
||||
**DateTime** | [**time.Time**](time.Time.md) | | [optional] [default to null]
|
||||
**Map_** | [**map[string]Animal**](Animal.md) | | [optional] [default to null]
|
||||
**Map** | [**map[string]Animal**](Animal.md) | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -222,7 +222,7 @@ Name | Type | Description | Notes
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **UploadFile**
|
||||
> ModelApiResponse UploadFile(ctx, petId, optional)
|
||||
> ApiResponse UploadFile(ctx, petId, optional)
|
||||
uploads an image
|
||||
|
||||
### Required Parameters
|
||||
@ -244,7 +244,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Return type
|
||||
|
||||
[**ModelApiResponse**](ApiResponse.md)
|
||||
[**ApiResponse**](ApiResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
|
10
samples/client/petstore/go/go-petstore/docs/Return.md
Normal file
10
samples/client/petstore/go/go-petstore/docs/Return.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Return
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Return** | **int32** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
package petstore
|
||||
|
||||
type ModelApiResponse struct {
|
||||
type ApiResponse struct {
|
||||
Code int32 `json:"code,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
@ -16,13 +16,13 @@ import (
|
||||
|
||||
type FormatTest struct {
|
||||
Integer int32 `json:"integer,omitempty"`
|
||||
Int32_ int32 `json:"int32,omitempty"`
|
||||
Int64_ int64 `json:"int64,omitempty"`
|
||||
Int32 int32 `json:"int32,omitempty"`
|
||||
Int64 int64 `json:"int64,omitempty"`
|
||||
Number float32 `json:"number"`
|
||||
Float float32 `json:"float,omitempty"`
|
||||
Double float64 `json:"double,omitempty"`
|
||||
String_ string `json:"string,omitempty"`
|
||||
Byte_ string `json:"byte"`
|
||||
String string `json:"string,omitempty"`
|
||||
Byte string `json:"byte"`
|
||||
Binary **os.File `json:"binary,omitempty"`
|
||||
Date string `json:"date"`
|
||||
DateTime time.Time `json:"dateTime,omitempty"`
|
||||
|
@ -16,5 +16,5 @@ import (
|
||||
type MixedPropertiesAndAdditionalPropertiesClass struct {
|
||||
Uuid string `json:"uuid,omitempty"`
|
||||
DateTime time.Time `json:"dateTime,omitempty"`
|
||||
Map_ map[string]Animal `json:"map,omitempty"`
|
||||
Map map[string]Animal `json:"map,omitempty"`
|
||||
}
|
||||
|
@ -11,6 +11,6 @@
|
||||
package petstore
|
||||
|
||||
// Model for testing reserved words
|
||||
type ModelReturn struct {
|
||||
Return_ int32 `json:"return,omitempty"`
|
||||
type Return struct {
|
||||
Return int32 `json:"return,omitempty"`
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user