-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Closed
Copy link
Labels
Milestone
Description
Description
spec:
post:
tags:
- Authentication
description: Log in to the server
operationId: login
security:
- ApiTokenQueryParam: []
consumes:
- application/json
parameters:
- name: api-token
in: header
description: the token to log in
required: true
type: string
securityDefinitions:
ApiTokenQueryParam:
type: apiKey
name: api-token
in: query
It will generate the following GO code,
func (a AuthenticationApi) Login(apiToken string) (*LoginResponse, *APIResponse, error) {
...
localVarQueryParams := url.Values{}
// authentication '(ApiTokenQueryParam)' required
// set key with prefix in query string
localVarQueryParams["api-token"] = a.Configuration.GetAPIKeyWithPrefix("api-token")
It has an error:
cannot use a.Configuration.GetAPIKeyWithPrefix("api-token") (type string) as type []string in assignment
The correct code should be:
localVarQueryParams.Add("api-token", a.Configuration.GetAPIKeyWithPrefix("api-token"))
Swagger-codegen version
2.2.3
Swagger declaration file content or url
Command line used for generation
java -jar swagger-codegen-cli-2.2.3.jar generate -i