mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-13 05:00:50 +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")
|
"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>(
|
languageSpecificPrimitives = new HashSet<String>(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"string",
|
"string",
|
||||||
@ -123,9 +138,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
// pet_id => PetId
|
// pet_id => PetId
|
||||||
name = camelize(name);
|
name = camelize(name);
|
||||||
|
|
||||||
// for reserved word or word starting with number, append _
|
// for reserved word append _
|
||||||
if (isReservedWord(name))
|
if (isReservedWord(name)) {
|
||||||
|
LOGGER.warn(name + " (reserved word) cannot be used as variable name. Renamed to "+ escapeReservedWord(name));
|
||||||
name = escapeReservedWord(name);
|
name = escapeReservedWord(name);
|
||||||
|
}
|
||||||
|
|
||||||
// for reserved word or word starting with number, append _
|
// for reserved word or word starting with number, append _
|
||||||
if (name.matches("^\\d.*"))
|
if (name.matches("^\\d.*"))
|
||||||
@ -134,15 +151,27 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isReservedWord(String word) {
|
||||||
|
return word != null && reservedWords.contains(word);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toParamName(String name) {
|
public String toParamName(String name) {
|
||||||
// params should be lowerCamelCase. E.g. "person Person", instead of
|
// params should be lowerCamelCase. E.g. "person Person", instead of
|
||||||
// "Person Person".
|
// "Person Person".
|
||||||
//
|
//
|
||||||
|
name = camelize(toVarName(name), true);
|
||||||
|
|
||||||
// REVISIT: Actually, for idiomatic go, the param name should
|
// REVISIT: Actually, for idiomatic go, the param name should
|
||||||
// really should just be a letter, e.g. "p Person"), but we'll get
|
// really should just be a letter, e.g. "p Person"), but we'll get
|
||||||
// around to that some other time... Maybe.
|
// 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
|
@Override
|
||||||
|
@ -35,21 +35,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
|||||||
// default HIDE_GENERATION_TIMESTAMP to true
|
// default HIDE_GENERATION_TIMESTAMP to true
|
||||||
hideGenerationTimestamp = Boolean.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.")
|
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Go package version.")
|
||||||
.defaultValue("1.0.0"));
|
.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)"));
|
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)
|
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
||||||
- [Animal](docs/Animal.md)
|
- [Animal](docs/Animal.md)
|
||||||
- [AnimalFarm](docs/AnimalFarm.md)
|
- [AnimalFarm](docs/AnimalFarm.md)
|
||||||
|
- [ApiResponse](docs/ApiResponse.md)
|
||||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||||
- [ArrayTest](docs/ArrayTest.md)
|
- [ArrayTest](docs/ArrayTest.md)
|
||||||
@ -78,8 +79,6 @@ Class | Method | HTTP request | Description
|
|||||||
- [MapTest](docs/MapTest.md)
|
- [MapTest](docs/MapTest.md)
|
||||||
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||||
- [Model200Response](docs/Model200Response.md)
|
- [Model200Response](docs/Model200Response.md)
|
||||||
- [ModelApiResponse](docs/ModelApiResponse.md)
|
|
||||||
- [ModelReturn](docs/ModelReturn.md)
|
|
||||||
- [Name](docs/Name.md)
|
- [Name](docs/Name.md)
|
||||||
- [NumberOnly](docs/NumberOnly.md)
|
- [NumberOnly](docs/NumberOnly.md)
|
||||||
- [Order](docs/Order.md)
|
- [Order](docs/Order.md)
|
||||||
@ -87,6 +86,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [OuterEnum](docs/OuterEnum.md)
|
- [OuterEnum](docs/OuterEnum.md)
|
||||||
- [Pet](docs/Pet.md)
|
- [Pet](docs/Pet.md)
|
||||||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||||
|
- [Return](docs/Return.md)
|
||||||
- [SpecialModelName](docs/SpecialModelName.md)
|
- [SpecialModelName](docs/SpecialModelName.md)
|
||||||
- [Tag](docs/Tag.md)
|
- [Tag](docs/Tag.md)
|
||||||
- [User](docs/User.md)
|
- [User](docs/User.md)
|
||||||
|
@ -100,11 +100,11 @@ paths:
|
|||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
default: available
|
|
||||||
enum:
|
enum:
|
||||||
- available
|
- available
|
||||||
- pending
|
- pending
|
||||||
- sold
|
- sold
|
||||||
|
default: available
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: successful operation
|
description: successful operation
|
||||||
@ -613,20 +613,20 @@ paths:
|
|||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
default: $
|
|
||||||
enum:
|
enum:
|
||||||
- '>'
|
- '>'
|
||||||
- $
|
- $
|
||||||
|
default: $
|
||||||
- name: enum_header_string
|
- name: enum_header_string
|
||||||
in: header
|
in: header
|
||||||
description: Header parameter enum test (string)
|
description: Header parameter enum test (string)
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
default: -efg
|
|
||||||
enum:
|
enum:
|
||||||
- _abc
|
- _abc
|
||||||
- -efg
|
- -efg
|
||||||
- (xyz)
|
- (xyz)
|
||||||
|
default: -efg
|
||||||
- name: enum_query_string_array
|
- name: enum_query_string_array
|
||||||
in: query
|
in: query
|
||||||
description: Query parameter enum test (string array)
|
description: Query parameter enum test (string array)
|
||||||
@ -635,20 +635,20 @@ paths:
|
|||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
default: $
|
|
||||||
enum:
|
enum:
|
||||||
- '>'
|
- '>'
|
||||||
- $
|
- $
|
||||||
|
default: $
|
||||||
- name: enum_query_string
|
- name: enum_query_string
|
||||||
in: query
|
in: query
|
||||||
description: Query parameter enum test (string)
|
description: Query parameter enum test (string)
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
default: -efg
|
|
||||||
enum:
|
enum:
|
||||||
- _abc
|
- _abc
|
||||||
- -efg
|
- -efg
|
||||||
- (xyz)
|
- (xyz)
|
||||||
|
default: -efg
|
||||||
- name: enum_query_integer
|
- name: enum_query_integer
|
||||||
in: query
|
in: query
|
||||||
description: Query parameter enum test (double)
|
description: Query parameter enum test (double)
|
||||||
@ -677,18 +677,18 @@ paths:
|
|||||||
description: Form parameter enum test (string array)
|
description: Form parameter enum test (string array)
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
default: $
|
|
||||||
enum:
|
enum:
|
||||||
- '>'
|
- '>'
|
||||||
- $
|
- $
|
||||||
|
default: $
|
||||||
enum_form_string:
|
enum_form_string:
|
||||||
type: string
|
type: string
|
||||||
description: Form parameter enum test (string)
|
description: Form parameter enum test (string)
|
||||||
default: -efg
|
|
||||||
enum:
|
enum:
|
||||||
- _abc
|
- _abc
|
||||||
- -efg
|
- -efg
|
||||||
- (xyz)
|
- (xyz)
|
||||||
|
default: -efg
|
||||||
responses:
|
responses:
|
||||||
400:
|
400:
|
||||||
description: Invalid request
|
description: Invalid request
|
||||||
@ -1100,11 +1100,11 @@ components:
|
|||||||
name: Name
|
name: Name
|
||||||
EnumClass:
|
EnumClass:
|
||||||
type: string
|
type: string
|
||||||
default: -efg
|
|
||||||
enum:
|
enum:
|
||||||
- _abc
|
- _abc
|
||||||
- -efg
|
- -efg
|
||||||
- (xyz)
|
- (xyz)
|
||||||
|
default: -efg
|
||||||
List:
|
List:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -11,13 +11,13 @@
|
|||||||
package petstore
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"github.com/antihax/optional"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
"context"
|
||||||
|
"github.com/antihax/optional"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Linger please
|
// Linger please
|
||||||
@ -96,7 +96,7 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar
|
|||||||
|
|
||||||
if localVarHttpResponse.StatusCode < 300 {
|
if localVarHttpResponse.StatusCode < 300 {
|
||||||
// If we succeed, return the data, otherwise pass on to decode error.
|
// If we succeed, return the data, otherwise pass on to decode error.
|
||||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return localVarReturnValue, localVarHttpResponse, err
|
return localVarReturnValue, localVarHttpResponse, err
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar
|
|||||||
}
|
}
|
||||||
if localVarHttpResponse.StatusCode == 200 {
|
if localVarHttpResponse.StatusCode == 200 {
|
||||||
var v bool
|
var v bool
|
||||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newErr.error = err.Error()
|
newErr.error = err.Error()
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||||||
@ -196,7 +196,7 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV
|
|||||||
|
|
||||||
if localVarHttpResponse.StatusCode < 300 {
|
if localVarHttpResponse.StatusCode < 300 {
|
||||||
// If we succeed, return the data, otherwise pass on to decode error.
|
// If we succeed, return the data, otherwise pass on to decode error.
|
||||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return localVarReturnValue, localVarHttpResponse, err
|
return localVarReturnValue, localVarHttpResponse, err
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV
|
|||||||
}
|
}
|
||||||
if localVarHttpResponse.StatusCode == 200 {
|
if localVarHttpResponse.StatusCode == 200 {
|
||||||
var v OuterComposite
|
var v OuterComposite
|
||||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newErr.error = err.Error()
|
newErr.error = err.Error()
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||||||
@ -292,7 +292,7 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO
|
|||||||
|
|
||||||
if localVarHttpResponse.StatusCode < 300 {
|
if localVarHttpResponse.StatusCode < 300 {
|
||||||
// If we succeed, return the data, otherwise pass on to decode error.
|
// If we succeed, return the data, otherwise pass on to decode error.
|
||||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return localVarReturnValue, localVarHttpResponse, err
|
return localVarReturnValue, localVarHttpResponse, err
|
||||||
}
|
}
|
||||||
@ -305,7 +305,7 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO
|
|||||||
}
|
}
|
||||||
if localVarHttpResponse.StatusCode == 200 {
|
if localVarHttpResponse.StatusCode == 200 {
|
||||||
var v float32
|
var v float32
|
||||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newErr.error = err.Error()
|
newErr.error = err.Error()
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||||||
@ -388,7 +388,7 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO
|
|||||||
|
|
||||||
if localVarHttpResponse.StatusCode < 300 {
|
if localVarHttpResponse.StatusCode < 300 {
|
||||||
// If we succeed, return the data, otherwise pass on to decode error.
|
// If we succeed, return the data, otherwise pass on to decode error.
|
||||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return localVarReturnValue, localVarHttpResponse, err
|
return localVarReturnValue, localVarHttpResponse, err
|
||||||
}
|
}
|
||||||
@ -401,7 +401,7 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO
|
|||||||
}
|
}
|
||||||
if localVarHttpResponse.StatusCode == 200 {
|
if localVarHttpResponse.StatusCode == 200 {
|
||||||
var v string
|
var v string
|
||||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newErr.error = err.Error()
|
newErr.error = err.Error()
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||||||
@ -543,7 +543,7 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, client Client) (Cl
|
|||||||
|
|
||||||
if localVarHttpResponse.StatusCode < 300 {
|
if localVarHttpResponse.StatusCode < 300 {
|
||||||
// If we succeed, return the data, otherwise pass on to decode error.
|
// If we succeed, return the data, otherwise pass on to decode error.
|
||||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return localVarReturnValue, localVarHttpResponse, err
|
return localVarReturnValue, localVarHttpResponse, err
|
||||||
}
|
}
|
||||||
@ -556,7 +556,7 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, client Client) (Cl
|
|||||||
}
|
}
|
||||||
if localVarHttpResponse.StatusCode == 200 {
|
if localVarHttpResponse.StatusCode == 200 {
|
||||||
var v Client
|
var v Client
|
||||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newErr.error = err.Error()
|
newErr.error = err.Error()
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||||||
@ -577,13 +577,13 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン
|
|||||||
* @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 *TestEndpointParametersOpts - Optional Parameters:
|
* @param optional nil or *TestEndpointParametersOpts - Optional Parameters:
|
||||||
* @param "Integer" (optional.Int32) - None
|
* @param "Integer" (optional.Int32) - None
|
||||||
* @param "Int32" (optional.Int32) - None
|
* @param "Int32_" (optional.Int32) - None
|
||||||
* @param "Int64" (optional.Int64) - None
|
* @param "Int64_" (optional.Int64) - None
|
||||||
* @param "Float" (optional.Float32) - 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 "Binary" (optional.Interface of *os.File) - None
|
||||||
* @param "Date" (optional.String) - None
|
* @param "Date" (optional.String) - None
|
||||||
* @param "DateTime" (optional.Time) - None
|
* @param "DateTime" (optional.Time) - None
|
||||||
@ -593,10 +593,10 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン
|
|||||||
|
|
||||||
type TestEndpointParametersOpts struct {
|
type TestEndpointParametersOpts struct {
|
||||||
Integer optional.Int32
|
Integer optional.Int32
|
||||||
Int32 optional.Int32
|
Int32_ optional.Int32
|
||||||
Int64 optional.Int64
|
Int64_ optional.Int64
|
||||||
Float optional.Float32
|
Float optional.Float32
|
||||||
String optional.String
|
String_ optional.String
|
||||||
Binary optional.Interface
|
Binary optional.Interface
|
||||||
Date optional.String
|
Date optional.String
|
||||||
DateTime optional.Time
|
DateTime optional.Time
|
||||||
@ -604,7 +604,7 @@ type TestEndpointParametersOpts struct {
|
|||||||
Callback 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 (
|
var (
|
||||||
localVarHttpMethod = strings.ToUpper("Post")
|
localVarHttpMethod = strings.ToUpper("Post")
|
||||||
localVarPostBody interface{}
|
localVarPostBody interface{}
|
||||||
@ -651,22 +651,22 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa
|
|||||||
if localVarOptionals != nil && localVarOptionals.Integer.IsSet() {
|
if localVarOptionals != nil && localVarOptionals.Integer.IsSet() {
|
||||||
localVarFormParams.Add("integer", parameterToString(localVarOptionals.Integer.Value(), ""))
|
localVarFormParams.Add("integer", parameterToString(localVarOptionals.Integer.Value(), ""))
|
||||||
}
|
}
|
||||||
if localVarOptionals != nil && localVarOptionals.Int32.IsSet() {
|
if localVarOptionals != nil && localVarOptionals.Int32_.IsSet() {
|
||||||
localVarFormParams.Add("int32", parameterToString(localVarOptionals.Int32.Value(), ""))
|
localVarFormParams.Add("int32", parameterToString(localVarOptionals.Int32_.Value(), ""))
|
||||||
}
|
}
|
||||||
if localVarOptionals != nil && localVarOptionals.Int64.IsSet() {
|
if localVarOptionals != nil && localVarOptionals.Int64_.IsSet() {
|
||||||
localVarFormParams.Add("int64", parameterToString(localVarOptionals.Int64.Value(), ""))
|
localVarFormParams.Add("int64", parameterToString(localVarOptionals.Int64_.Value(), ""))
|
||||||
}
|
}
|
||||||
localVarFormParams.Add("number", parameterToString(number, ""))
|
localVarFormParams.Add("number", parameterToString(number, ""))
|
||||||
if localVarOptionals != nil && localVarOptionals.Float.IsSet() {
|
if localVarOptionals != nil && localVarOptionals.Float.IsSet() {
|
||||||
localVarFormParams.Add("float", parameterToString(localVarOptionals.Float.Value(), ""))
|
localVarFormParams.Add("float", parameterToString(localVarOptionals.Float.Value(), ""))
|
||||||
}
|
}
|
||||||
localVarFormParams.Add("double", parameterToString(double, ""))
|
localVarFormParams.Add("double", parameterToString(double, ""))
|
||||||
if localVarOptionals != nil && localVarOptionals.String.IsSet() {
|
if localVarOptionals != nil && localVarOptionals.String_.IsSet() {
|
||||||
localVarFormParams.Add("string", parameterToString(localVarOptionals.String.Value(), ""))
|
localVarFormParams.Add("string", parameterToString(localVarOptionals.String_.Value(), ""))
|
||||||
}
|
}
|
||||||
localVarFormParams.Add("pattern_without_delimiter", parameterToString(patternWithoutDelimiter, ""))
|
localVarFormParams.Add("pattern_without_delimiter", parameterToString(patternWithoutDelimiter, ""))
|
||||||
localVarFormParams.Add("byte", parameterToString(byte, ""))
|
localVarFormParams.Add("byte", parameterToString(byte_, ""))
|
||||||
var localVarFile *os.File
|
var localVarFile *os.File
|
||||||
if localVarOptionals != nil && localVarOptionals.Binary.IsSet() {
|
if localVarOptionals != nil && localVarOptionals.Binary.IsSet() {
|
||||||
localVarFileOk := false
|
localVarFileOk := false
|
||||||
|
@ -594,7 +594,7 @@ PetApiService uploads an image
|
|||||||
* @param optional nil or *UploadFileOpts - Optional Parameters:
|
* @param optional nil or *UploadFileOpts - Optional Parameters:
|
||||||
* @param "AdditionalMetadata" (optional.String) - Additional data to pass to server
|
* @param "AdditionalMetadata" (optional.String) - Additional data to pass to server
|
||||||
* @param "File" (optional.Interface of *os.File) - file to upload
|
* @param "File" (optional.Interface of *os.File) - file to upload
|
||||||
@return ModelApiResponse
|
@return ApiResponse
|
||||||
*/
|
*/
|
||||||
|
|
||||||
type UploadFileOpts struct {
|
type UploadFileOpts struct {
|
||||||
@ -602,13 +602,13 @@ type UploadFileOpts struct {
|
|||||||
File optional.Interface
|
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 (
|
var (
|
||||||
localVarHttpMethod = strings.ToUpper("Post")
|
localVarHttpMethod = strings.ToUpper("Post")
|
||||||
localVarPostBody interface{}
|
localVarPostBody interface{}
|
||||||
localVarFileName string
|
localVarFileName string
|
||||||
localVarFileBytes []byte
|
localVarFileBytes []byte
|
||||||
localVarReturnValue ModelApiResponse
|
localVarReturnValue ApiResponse
|
||||||
)
|
)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
@ -683,7 +683,7 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt
|
|||||||
error: localVarHttpResponse.Status,
|
error: localVarHttpResponse.Status,
|
||||||
}
|
}
|
||||||
if localVarHttpResponse.StatusCode == 200 {
|
if localVarHttpResponse.StatusCode == 200 {
|
||||||
var v ModelApiResponse
|
var v ApiResponse
|
||||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newErr.error = err.Error()
|
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)
|
[[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**
|
||||||
> 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 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||||
|
|
||||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||||
@ -225,7 +225,7 @@ Name | Type | Description | Notes
|
|||||||
**number** | **float32**| None |
|
**number** | **float32**| None |
|
||||||
**double** | **float64**| None |
|
**double** | **float64**| None |
|
||||||
**patternWithoutDelimiter** | **string**| None |
|
**patternWithoutDelimiter** | **string**| None |
|
||||||
**byte** | **string**| None |
|
**byte_** | **string**| None |
|
||||||
**optional** | ***TestEndpointParametersOpts** | optional parameters | nil if no parameters
|
**optional** | ***TestEndpointParametersOpts** | optional parameters | nil if no parameters
|
||||||
|
|
||||||
### Optional Parameters
|
### Optional Parameters
|
||||||
@ -238,10 +238,10 @@ Name | Type | Description | Notes
|
|||||||
|
|
||||||
|
|
||||||
**integer** | **optional.Int32**| None |
|
**integer** | **optional.Int32**| None |
|
||||||
**int32** | **optional.Int32**| None |
|
**int32_** | **optional.Int32**| None |
|
||||||
**int64** | **optional.Int64**| None |
|
**int64_** | **optional.Int64**| None |
|
||||||
**float** | **optional.Float32**| None |
|
**float** | **optional.Float32**| None |
|
||||||
**string** | **optional.String**| None |
|
**string_** | **optional.String**| None |
|
||||||
**binary** | **optional.Interface of *os.File****optional.*os.File**| None |
|
**binary** | **optional.Interface of *os.File****optional.*os.File**| None |
|
||||||
**date** | **optional.String**| None |
|
**date** | **optional.String**| None |
|
||||||
**dateTime** | **optional.Time**| None |
|
**dateTime** | **optional.Time**| None |
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**Integer** | **int32** | | [optional] [default to null]
|
**Integer** | **int32** | | [optional] [default to null]
|
||||||
**Int32_** | **int32** | | [optional] [default to null]
|
**Int32** | **int32** | | [optional] [default to null]
|
||||||
**Int64_** | **int64** | | [optional] [default to null]
|
**Int64** | **int64** | | [optional] [default to null]
|
||||||
**Number** | **float32** | | [default to null]
|
**Number** | **float32** | | [default to null]
|
||||||
**Float** | **float32** | | [optional] [default to null]
|
**Float** | **float32** | | [optional] [default to null]
|
||||||
**Double** | **float64** | | [optional] [default to null]
|
**Double** | **float64** | | [optional] [default to null]
|
||||||
**String_** | **string** | | [optional] [default to null]
|
**String** | **string** | | [optional] [default to null]
|
||||||
**Byte_** | **string** | | [default to null]
|
**Byte** | **string** | | [default to null]
|
||||||
**Binary** | [****os.File**](*os.File.md) | | [optional] [default to null]
|
**Binary** | [****os.File**](*os.File.md) | | [optional] [default to null]
|
||||||
**Date** | **string** | | [default to null]
|
**Date** | **string** | | [default to null]
|
||||||
**DateTime** | [**time.Time**](time.Time.md) | | [optional] [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]
|
**Uuid** | **string** | | [optional] [default to null]
|
||||||
**DateTime** | [**time.Time**](time.Time.md) | | [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)
|
[[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)
|
[[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**
|
# **UploadFile**
|
||||||
> ModelApiResponse UploadFile(ctx, petId, optional)
|
> ApiResponse UploadFile(ctx, petId, optional)
|
||||||
uploads an image
|
uploads an image
|
||||||
|
|
||||||
### Required Parameters
|
### Required Parameters
|
||||||
@ -244,7 +244,7 @@ Name | Type | Description | Notes
|
|||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
[**ModelApiResponse**](ApiResponse.md)
|
[**ApiResponse**](ApiResponse.md)
|
||||||
|
|
||||||
### Authorization
|
### 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
|
package petstore
|
||||||
|
|
||||||
type ModelApiResponse struct {
|
type ApiResponse struct {
|
||||||
Code int32 `json:"code,omitempty"`
|
Code int32 `json:"code,omitempty"`
|
||||||
Type_ string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
Message string `json:"message,omitempty"`
|
Message string `json:"message,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,13 @@ 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"`
|
||||||
Int64_ int64 `json:"int64,omitempty"`
|
Int64 int64 `json:"int64,omitempty"`
|
||||||
Number float32 `json:"number"`
|
Number float32 `json:"number"`
|
||||||
Float float32 `json:"float,omitempty"`
|
Float float32 `json:"float,omitempty"`
|
||||||
Double float64 `json:"double,omitempty"`
|
Double float64 `json:"double,omitempty"`
|
||||||
String_ string `json:"string,omitempty"`
|
String string `json:"string,omitempty"`
|
||||||
Byte_ string `json:"byte"`
|
Byte string `json:"byte"`
|
||||||
Binary **os.File `json:"binary,omitempty"`
|
Binary **os.File `json:"binary,omitempty"`
|
||||||
Date string `json:"date"`
|
Date string `json:"date"`
|
||||||
DateTime time.Time `json:"dateTime,omitempty"`
|
DateTime time.Time `json:"dateTime,omitempty"`
|
||||||
|
@ -16,5 +16,5 @@ 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"`
|
||||||
Map_ map[string]Animal `json:"map,omitempty"`
|
Map map[string]Animal `json:"map,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,6 @@
|
|||||||
package petstore
|
package petstore
|
||||||
|
|
||||||
// Model for testing reserved words
|
// Model for testing reserved words
|
||||||
type ModelReturn struct {
|
type Return struct {
|
||||||
Return_ int32 `json:"return,omitempty"`
|
Return int32 `json:"return,omitempty"`
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user