mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 22:20:56 +00:00
Fix nim code generation (#20752)
Same variable name declared multiple times in the same scope. => nim generated code does not compile.
This commit is contained in:
parent
af536f6205
commit
e0b6b2bbc7
@ -37,19 +37,19 @@ proc {{{operationId}}}*(httpClient: HttpClient{{#allParams}}, {{{paramName}}}: {
|
|||||||
httpClient.headers["Content-Type"] = "application/x-www-form-urlencoded"{{/isMultipart}}{{#isMultipart}}
|
httpClient.headers["Content-Type"] = "application/x-www-form-urlencoded"{{/isMultipart}}{{#isMultipart}}
|
||||||
httpClient.headers["Content-Type"] = "multipart/form-data"{{/isMultipart}}{{/hasFormParams}}{{#hasHeaderParams}}{{#headerParams}}
|
httpClient.headers["Content-Type"] = "multipart/form-data"{{/isMultipart}}{{/hasFormParams}}{{#hasHeaderParams}}{{#headerParams}}
|
||||||
httpClient.headers["{{{baseName}}}"] = {{{paramName}}}{{#isArray}}.join(","){{/isArray}}{{/headerParams}}{{#description}} ## {{{.}}}{{/description}}{{/hasHeaderParams}}{{#hasQueryParams}}
|
httpClient.headers["{{{baseName}}}"] = {{{paramName}}}{{#isArray}}.join(","){{/isArray}}{{/headerParams}}{{#description}} ## {{{.}}}{{/description}}{{/hasHeaderParams}}{{#hasQueryParams}}
|
||||||
let query_for_api_call = encodeQuery([{{#queryParams}}
|
let url_encoded_query_params = encodeQuery([{{#queryParams}}
|
||||||
("{{{baseName}}}", ${{{paramName}}}{{#isArray}}.join(","){{/isArray}}), # {{{description}}}{{/queryParams}}
|
("{{{baseName}}}", ${{{paramName}}}{{#isArray}}.join(","){{/isArray}}), # {{{description}}}{{/queryParams}}
|
||||||
]){{/hasQueryParams}}{{#hasFormParams}}{{^isMultipart}}
|
]){{/hasQueryParams}}{{#hasFormParams}}{{^isMultipart}}
|
||||||
let query_for_api_call = encodeQuery([{{#formParams}}
|
let form_data = encodeQuery([{{#formParams}}
|
||||||
("{{{baseName}}}", ${{{paramName}}}{{#isArray}}.join(","){{/isArray}}), # {{{description}}}{{/formParams}}
|
("{{{baseName}}}", ${{{paramName}}}{{#isArray}}.join(","){{/isArray}}), # {{{description}}}{{/formParams}}
|
||||||
]){{/isMultipart}}{{#isMultipart}}
|
]){{/isMultipart}}{{#isMultipart}}
|
||||||
let query_for_api_call = newMultipartData({
|
let multipart_data = newMultipartData({
|
||||||
{{#formParams}} "{{{baseName}}}": ${{{paramName}}}{{#isArray}}.join(","){{/isArray}}, # {{{description}}}
|
{{#formParams}} "{{{baseName}}}": ${{{paramName}}}{{#isArray}}.join(","){{/isArray}}, # {{{description}}}
|
||||||
{{/formParams}}
|
{{/formParams}}
|
||||||
}){{/isMultipart}}{{/hasFormParams}}{{#returnType}}
|
}){{/isMultipart}}{{/hasFormParams}}{{#returnType}}
|
||||||
|
|
||||||
let response = httpClient.{{{httpMethod}}}(basepath & {{^pathParams}}"{{{path}}}"{{/pathParams}}{{#hasPathParams}}fmt"{{{path}}}"{{/hasPathParams}}{{#hasQueryParams}} & "?" & query_for_api_call{{/hasQueryParams}}{{#hasBodyParam}}{{#bodyParams}}, $(%{{{paramName}}}){{/bodyParams}}{{/hasBodyParam}}{{#hasFormParams}}, {{^isMultipart}}$query_for_api_call{{/isMultipart}}{{#isMultipart}}multipart=query_for_api_call{{/isMultipart}}{{/hasFormParams}})
|
let response = httpClient.{{{httpMethod}}}(basepath & {{^pathParams}}"{{{path}}}"{{/pathParams}}{{#hasPathParams}}fmt"{{{path}}}"{{/hasPathParams}}{{#hasQueryParams}} & "?" & url_encoded_query_params{{/hasQueryParams}}{{#hasBodyParam}}{{#bodyParams}}, $(%{{{paramName}}}){{/bodyParams}}{{/hasBodyParam}}{{#hasFormParams}}, {{^isMultipart}}$form_data{{/isMultipart}}{{#isMultipart}}multipart=multipart_data{{/isMultipart}}{{/hasFormParams}})
|
||||||
constructResult[{{{returnType}}}](response){{/returnType}}{{^returnType}}
|
constructResult[{{{returnType}}}](response){{/returnType}}{{^returnType}}
|
||||||
httpClient.{{{httpMethod}}}(basepath & {{^pathParams}}"{{{path}}}"{{/pathParams}}{{#hasPathParams}}fmt"{{{path}}}"{{/hasPathParams}}{{#hasQueryParams}} & "?" & query_for_api_call{{/hasQueryParams}}{{#hasBodyParam}}{{#bodyParams}}, $(%{{{paramName}}}){{/bodyParams}}{{/hasBodyParam}}{{#hasFormParams}}, {{^isMultipart}}$query_for_api_call{{/isMultipart}}{{#isMultipart}}multipart=query_for_api_call{{/isMultipart}}{{/hasFormParams}}){{/returnType}}
|
httpClient.{{{httpMethod}}}(basepath & {{^pathParams}}"{{{path}}}"{{/pathParams}}{{#hasPathParams}}fmt"{{{path}}}"{{/hasPathParams}}{{#hasQueryParams}} & "?" & url_encoded_query_params{{/hasQueryParams}}{{#hasBodyParam}}{{#bodyParams}}, $(%{{{paramName}}}){{/bodyParams}}{{/hasBodyParam}}{{#hasFormParams}}, {{^isMultipart}}$form_data{{/isMultipart}}{{#isMultipart}}multipart=multipart_data{{/isMultipart}}{{/hasFormParams}}){{/returnType}}
|
||||||
|
|
||||||
{{/operation}}{{/operations}}
|
{{/operation}}{{/operations}}
|
@ -55,21 +55,21 @@ proc deletePet*(httpClient: HttpClient, petId: int64, apiKey: string): Response
|
|||||||
|
|
||||||
proc findPetsByStatus*(httpClient: HttpClient, status: seq[Status]): (Option[seq[Pet]], Response) =
|
proc findPetsByStatus*(httpClient: HttpClient, status: seq[Status]): (Option[seq[Pet]], Response) =
|
||||||
## Finds Pets by status
|
## Finds Pets by status
|
||||||
let query_for_api_call = encodeQuery([
|
let url_encoded_query_params = encodeQuery([
|
||||||
("status", $status.join(",")), # Status values that need to be considered for filter
|
("status", $status.join(",")), # Status values that need to be considered for filter
|
||||||
])
|
])
|
||||||
|
|
||||||
let response = httpClient.get(basepath & "/pet/findByStatus" & "?" & query_for_api_call)
|
let response = httpClient.get(basepath & "/pet/findByStatus" & "?" & url_encoded_query_params)
|
||||||
constructResult[seq[Pet]](response)
|
constructResult[seq[Pet]](response)
|
||||||
|
|
||||||
|
|
||||||
proc findPetsByTags*(httpClient: HttpClient, tags: seq[string]): (Option[seq[Pet]], Response) {.deprecated.} =
|
proc findPetsByTags*(httpClient: HttpClient, tags: seq[string]): (Option[seq[Pet]], Response) {.deprecated.} =
|
||||||
## Finds Pets by tags
|
## Finds Pets by tags
|
||||||
let query_for_api_call = encodeQuery([
|
let url_encoded_query_params = encodeQuery([
|
||||||
("tags", $tags.join(",")), # Tags to filter by
|
("tags", $tags.join(",")), # Tags to filter by
|
||||||
])
|
])
|
||||||
|
|
||||||
let response = httpClient.get(basepath & "/pet/findByTags" & "?" & query_for_api_call)
|
let response = httpClient.get(basepath & "/pet/findByTags" & "?" & url_encoded_query_params)
|
||||||
constructResult[seq[Pet]](response)
|
constructResult[seq[Pet]](response)
|
||||||
|
|
||||||
|
|
||||||
@ -91,21 +91,21 @@ proc updatePet*(httpClient: HttpClient, pet: Pet): (Option[Pet], Response) =
|
|||||||
proc updatePetWithForm*(httpClient: HttpClient, petId: int64, name: string, status: string): Response =
|
proc updatePetWithForm*(httpClient: HttpClient, petId: int64, name: string, status: string): Response =
|
||||||
## Updates a pet in the store with form data
|
## Updates a pet in the store with form data
|
||||||
httpClient.headers["Content-Type"] = "application/x-www-form-urlencoded"
|
httpClient.headers["Content-Type"] = "application/x-www-form-urlencoded"
|
||||||
let query_for_api_call = encodeQuery([
|
let form_data = encodeQuery([
|
||||||
("name", $name), # Updated name of the pet
|
("name", $name), # Updated name of the pet
|
||||||
("status", $status), # Updated status of the pet
|
("status", $status), # Updated status of the pet
|
||||||
])
|
])
|
||||||
httpClient.post(basepath & fmt"/pet/{petId}", $query_for_api_call)
|
httpClient.post(basepath & fmt"/pet/{petId}", $form_data)
|
||||||
|
|
||||||
|
|
||||||
proc uploadFile*(httpClient: HttpClient, petId: int64, additionalMetadata: string, file: string): (Option[ApiResponse], Response) =
|
proc uploadFile*(httpClient: HttpClient, petId: int64, additionalMetadata: string, file: string): (Option[ApiResponse], Response) =
|
||||||
## uploads an image
|
## uploads an image
|
||||||
httpClient.headers["Content-Type"] = "multipart/form-data"
|
httpClient.headers["Content-Type"] = "multipart/form-data"
|
||||||
let query_for_api_call = newMultipartData({
|
let multipart_data = newMultipartData({
|
||||||
"additionalMetadata": $additionalMetadata, # Additional data to pass to server
|
"additionalMetadata": $additionalMetadata, # Additional data to pass to server
|
||||||
"file": $file, # file to upload
|
"file": $file, # file to upload
|
||||||
})
|
})
|
||||||
|
|
||||||
let response = httpClient.post(basepath & fmt"/pet/{petId}/uploadImage", multipart=query_for_api_call)
|
let response = httpClient.post(basepath & fmt"/pet/{petId}/uploadImage", multipart=multipart_data)
|
||||||
constructResult[ApiResponse](response)
|
constructResult[ApiResponse](response)
|
||||||
|
|
||||||
|
@ -70,12 +70,12 @@ proc getUserByName*(httpClient: HttpClient, username: string): (Option[User], Re
|
|||||||
|
|
||||||
proc loginUser*(httpClient: HttpClient, username: string, password: string): (Option[string], Response) =
|
proc loginUser*(httpClient: HttpClient, username: string, password: string): (Option[string], Response) =
|
||||||
## Logs user into the system
|
## Logs user into the system
|
||||||
let query_for_api_call = encodeQuery([
|
let url_encoded_query_params = encodeQuery([
|
||||||
("username", $username), # The user name for login
|
("username", $username), # The user name for login
|
||||||
("password", $password), # The password for login in clear text
|
("password", $password), # The password for login in clear text
|
||||||
])
|
])
|
||||||
|
|
||||||
let response = httpClient.get(basepath & "/user/login" & "?" & query_for_api_call)
|
let response = httpClient.get(basepath & "/user/login" & "?" & url_encoded_query_params)
|
||||||
constructResult[string](response)
|
constructResult[string](response)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user