Skip to content

[Go][Exp] better code format #7088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ type api{{operationId}}Request struct {
{{paramName}} {{^isPathParam}}*{{/isPathParam}}{{{dataType}}}{{/allParams}}
}

{{#allParams}}{{^isPathParam}}
{{#allParams}}
{{^isPathParam}}
func (r api{{operationId}}Request) {{vendorExtensions.x-export-param-name}}({{paramName}} {{{dataType}}}) api{{operationId}}Request {
r.{{paramName}} = &{{paramName}}
return r
}
{{/isPathParam}}{{/allParams}}
{{/isPathParam}}
{{/allParams}}
/*
{{operationId}}{{#summary}} {{{.}}}{{/summary}}{{^summary}} Method for {{operationId}}{{/summary}}
{{#notes}}
Expand All @@ -51,7 +53,9 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx _context.Context{{#pathParam

/*
Execute executes the request
{{#returnType}} @return {{{.}}}{{/returnType}}
{{#returnType}}
@return {{{.}}}
{{/returnType}}
*/
func (r api{{operationId}}Request) Execute() ({{#returnType}}{{{.}}}, {{/returnType}}*_nethttp.Response, error) {
var (
Expand All @@ -60,7 +64,9 @@ func (r api{{operationId}}Request) Execute() ({{#returnType}}{{{.}}}, {{/returnT
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
{{#returnType}}localVarReturnValue {{{.}}}{{/returnType}}
{{#returnType}}
localVarReturnValue {{{.}}}
{{/returnType}}
)

localBasePath, err := r.apiService.client.cfg.ServerURLWithContext(r.ctx, "{{{classname}}}Service.{{{nickname}}}")
Expand All @@ -75,10 +81,12 @@ func (r api{{operationId}}Request) Execute() ({{#returnType}}{{{.}}}, {{/returnT
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
{{#allParams}}
{{#required}}{{^isPathParam}}
{{#required}}
{{^isPathParam}}
if r.{{paramName}} == nil {
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} is required and must be specified")
}{{/isPathParam}}
}
{{/isPathParam}}
{{#minItems}}
if len({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) < {{minItems}} {
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have at least {{minItems}} elements")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
{{/isNullable}}
{{#discriminator}}
{{#mappedModels}}
{{#-first}}
{{#-first}}
// use discriminator value to speed up the lookup
var jsonDict map[string]interface{}
err := json.Unmarshal(data, &jsonDict)
if err != nil {
return fmt.Errorf("Failed to unmarshal JSON into map for the discrimintor lookup.")
}

{{/-first}}
{{/-first}}
// check if the discriminator value is '{{{mappingName}}}'
if jsonDict["{{{propertyBaseName}}}"] == "{{{mappingName}}}" {
// try to unmarshal JSON data into {{{modelName}}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const (
// The 'Host' header, as defined in RFC 2616, section 14.23.
HttpHeaderHost string = "Host"
// The 'Date' header.
HttpHeaderDate string = "Date"
HttpHeaderDate string = "Date"
// The digest header, as defined in RFC 3230, section 4.3.2.
HttpHeaderDigest string = "Digest"
// The HTTP Authorization header, as defined in RFC 7235, section 4.2.
Expand Down Expand Up @@ -106,7 +106,7 @@ type HttpSignatureAuth struct {
SigningScheme string // The signature scheme, when signing HTTP requests. Supported value is 'hs2019'.
// The signature algorithm, when signing HTTP requests.
// Supported values are RSASSA-PKCS1-v1_5, RSASSA-PSS.
SigningAlgorithm string
SigningAlgorithm string
SignedHeaders []string // A list of HTTP headers included when generating the signature for the message.
// SignatureMaxValidity specifies the maximum duration of the signature validity.
// The value is used to set the '(expires)' signature parameter in the HTTP request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ type apiCall123TestSpecialTagsRequest struct {
body *Client
}


func (r apiCall123TestSpecialTagsRequest) Body(body Client) apiCall123TestSpecialTagsRequest {
r.body = &body
return r
}

/*
Call123TestSpecialTags To test special tags
To test special tags and operation ID starting with number
Expand All @@ -51,7 +49,7 @@ func (a *AnotherFakeApiService) Call123TestSpecialTags(ctx _context.Context) api

/*
Execute executes the request
@return Client
@return Client
*/
func (r apiCall123TestSpecialTagsRequest) Execute() (Client, *_nethttp.Response, error) {
var (
Expand All @@ -73,7 +71,6 @@ func (r apiCall123TestSpecialTagsRequest) Execute() (Client, *_nethttp.Response,
localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}

if r.body == nil {
return localVarReturnValue, nil, reportError("body is required and must be specified")
}
Expand Down
Loading