From d3f365fd297bdb9fedaca15700a3988e754a3e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pa=C5=ADlo=20Ebermann?= Date: Mon, 20 Mar 2017 08:24:24 +0100 Subject: [PATCH] Fix (partially) #4898 for elixir (#5021) * fix (partially) #4898 for Elixir * Update petstore samples (after fix for elixir for #4898) --- .../src/main/resources/elixir/api.mustache | 6 +++--- .../petstore/elixir/lib/swagger_petstore/api/fake.ex | 8 ++++---- .../petstore/elixir/lib/swagger_petstore/api/pet.ex | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/elixir/api.mustache b/modules/swagger-codegen/src/main/resources/elixir/api.mustache index 0e1a5fb9a5..d748076c69 100644 --- a/modules/swagger-codegen/src/main/resources/elixir/api.mustache +++ b/modules/swagger-codegen/src/main/resources/elixir/api.mustache @@ -13,10 +13,10 @@ defmodule {{#modulized}}{{appName}}{{/modulized}}.Api.{{classname}} do def {{#underscored}}{{operationId}}{{/underscored}}({{#allParams}}{{^-first}}, {{/-first}}{{#underscored}}{{paramName}}{{/underscored}}{{/allParams}}) do method = [method: :{{#underscored}}{{httpMethod}}{{/underscored}}] url = [url: "{{replacedPathName}}"] - query_params = [{{^queryParams.isEmpty}}query: [{{#queryParams}}{{^-first}}, {{/-first}}{:"{{paramName}}", {{#underscored}}{{paramName}}{{/underscored}}}{{/queryParams}}]{{/queryParams.isEmpty}}] - header_params = [{{^headerParams.isEmpty}}header: [{{#headerParams}}{{^-first}}, {{/-first}}{:"{{paramName}}", {{#underscored}}{{paramName}}{{/underscored}}}{{/headerParams}}]{{/headerParams.isEmpty}}] + query_params = [{{^queryParams.isEmpty}}query: [{{#queryParams}}{{^-first}}, {{/-first}}{:"{{baseName}}", {{#underscored}}{{paramName}}{{/underscored}}}{{/queryParams}}]{{/queryParams.isEmpty}}] + header_params = [{{^headerParams.isEmpty}}header: [{{#headerParams}}{{^-first}}, {{/-first}}{:"{{baseName}}", {{#underscored}}{{paramName}}{{/underscored}}}{{/headerParams}}]{{/headerParams.isEmpty}}] body_params = [{{^bodyParams.isEmpty}}body: {{#bodyParams}}{{#underscored}}{{paramName}}{{/underscored}}{{/bodyParams}}{{/bodyParams.isEmpty}}] - form_params = [{{^formParams.isEmpty}}body: Enum.map_join([{{#formParams}}{{^-first}}, {{/-first}}{:"{{paramName}}", {{#underscored}}{{paramName}}{{/underscored}}}{{/formParams}}], "&", &("#{elem(&1, 0)}=#{elem(&1, 1)}")){{/formParams.isEmpty}}] + form_params = [{{^formParams.isEmpty}}body: Enum.map_join([{{#formParams}}{{^-first}}, {{/-first}}{:"{{baseName}}", {{#underscored}}{{paramName}}{{/underscored}}}{{/formParams}}], "&", &("#{elem(&1, 0)}=#{elem(&1, 1)}")){{/formParams.isEmpty}}] params = query_params ++ header_params ++ body_params ++ form_params opts = [] options = method ++ url ++ params ++ opts diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex b/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex index 707744d861..1c97508292 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex @@ -28,7 +28,7 @@ defmodule SwaggerPetstore.Api.Fake do query_params = [] header_params = [] body_params = [] - form_params = [body: Enum.map_join([{:"integer", integer}, {:"int32", int32}, {:"int64", int64}, {:"number", number}, {:"float", float}, {:"double", double}, {:"string", string}, {:"patternWithoutDelimiter", pattern_without_delimiter}, {:"byte", byte}, {:"binary", binary}, {:"date", date}, {:"dateTime", date_time}, {:"password", password}, {:"callback", callback}], "&", &("#{elem(&1, 0)}=#{elem(&1, 1)}"))] + form_params = [body: Enum.map_join([{:"integer", integer}, {:"int32", int32}, {:"int64", int64}, {:"number", number}, {:"float", float}, {:"double", double}, {:"string", string}, {:"pattern_without_delimiter", pattern_without_delimiter}, {:"byte", byte}, {:"binary", binary}, {:"date", date}, {:"dateTime", date_time}, {:"password", password}, {:"callback", callback}], "&", &("#{elem(&1, 0)}=#{elem(&1, 1)}"))] params = query_params ++ header_params ++ body_params ++ form_params opts = [] options = method ++ url ++ params ++ opts @@ -39,10 +39,10 @@ defmodule SwaggerPetstore.Api.Fake do def test_enum_parameters(enum_form_string_array, enum_form_string, enum_header_string_array, enum_header_string, enum_query_string_array, enum_query_string, enum_query_integer, enum_query_double) do method = [method: :get] url = [url: "/fake"] - query_params = [query: [{:"enumQueryStringArray", enum_query_string_array}, {:"enumQueryString", enum_query_string}, {:"enumQueryInteger", enum_query_integer}]] - header_params = [header: [{:"enumHeaderStringArray", enum_header_string_array}, {:"enumHeaderString", enum_header_string}]] + query_params = [query: [{:"enum_query_string_array", enum_query_string_array}, {:"enum_query_string", enum_query_string}, {:"enum_query_integer", enum_query_integer}]] + header_params = [header: [{:"enum_header_string_array", enum_header_string_array}, {:"enum_header_string", enum_header_string}]] body_params = [] - form_params = [body: Enum.map_join([{:"enumFormStringArray", enum_form_string_array}, {:"enumFormString", enum_form_string}, {:"enumQueryDouble", enum_query_double}], "&", &("#{elem(&1, 0)}=#{elem(&1, 1)}"))] + form_params = [body: Enum.map_join([{:"enum_form_string_array", enum_form_string_array}, {:"enum_form_string", enum_form_string}, {:"enum_query_double", enum_query_double}], "&", &("#{elem(&1, 0)}=#{elem(&1, 1)}"))] params = query_params ++ header_params ++ body_params ++ form_params opts = [] options = method ++ url ++ params ++ opts diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/api/pet.ex b/samples/client/petstore/elixir/lib/swagger_petstore/api/pet.ex index b0ca76c91f..ffbc64c132 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/api/pet.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/api/pet.ex @@ -26,7 +26,7 @@ defmodule SwaggerPetstore.Api.Pet do method = [method: :delete] url = [url: "/pet/#{pet_id}"] query_params = [] - header_params = [header: [{:"apiKey", api_key}]] + header_params = [header: [{:"api_key", api_key}]] body_params = [] form_params = [] params = query_params ++ header_params ++ body_params ++ form_params