From dcd9463e8877cc1d0393c3d34a0ba44be9508f2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Fern=C3=A1ndez?= Date: Tue, 8 Apr 2025 12:47:37 +0200 Subject: [PATCH] [feat][elixir] use elixir 1.18 built-in json module (#21039) * feat: replace jason by built-in json encoder/decoder * chore: update samples --- .../codegen/languages/ElixirClientCodegen.java | 5 ++--- .../src/main/resources/elixir/connection.ex.mustache | 2 +- .../src/main/resources/elixir/deserializer.ex.mustache | 10 ++++------ .../src/main/resources/elixir/model.mustache | 2 +- .../main/resources/elixir/request_builder.ex.mustache | 6 +++--- .../petstore/elixir/lib/openapi_petstore/connection.ex | 2 +- .../elixir/lib/openapi_petstore/deserializer.ex | 10 ++++------ .../model/_foo_get_default_response.ex | 2 +- .../lib/openapi_petstore/model/_special_model_name_.ex | 2 +- .../model/additional_properties_class.ex | 2 +- .../openapi_petstore/model/all_of_with_single_ref.ex | 2 +- .../elixir/lib/openapi_petstore/model/animal.ex | 2 +- .../petstore/elixir/lib/openapi_petstore/model/any.ex | 2 +- .../elixir/lib/openapi_petstore/model/api_response.ex | 2 +- .../model/array_of_array_of_number_only.ex | 2 +- .../lib/openapi_petstore/model/array_of_number_only.ex | 2 +- .../elixir/lib/openapi_petstore/model/array_test.ex | 2 +- .../lib/openapi_petstore/model/capitalization.ex | 2 +- .../petstore/elixir/lib/openapi_petstore/model/cat.ex | 2 +- .../elixir/lib/openapi_petstore/model/category.ex | 2 +- .../lib/openapi_petstore/model/child_with_nullable.ex | 2 +- .../elixir/lib/openapi_petstore/model/class_model.ex | 2 +- .../elixir/lib/openapi_petstore/model/client.ex | 2 +- .../lib/openapi_petstore/model/deprecated_model.ex | 2 +- .../petstore/elixir/lib/openapi_petstore/model/dog.ex | 2 +- .../elixir/lib/openapi_petstore/model/enum_arrays.ex | 2 +- .../elixir/lib/openapi_petstore/model/enum_class.ex | 2 +- .../elixir/lib/openapi_petstore/model/enum_test.ex | 2 +- .../model/fake_big_decimal_map_200_response.ex | 2 +- .../petstore/elixir/lib/openapi_petstore/model/file.ex | 2 +- .../openapi_petstore/model/file_schema_test_class.ex | 2 +- .../petstore/elixir/lib/openapi_petstore/model/foo.ex | 2 +- .../elixir/lib/openapi_petstore/model/format_test.ex | 2 +- .../lib/openapi_petstore/model/has_only_read_only.ex | 2 +- .../lib/openapi_petstore/model/health_check_result.ex | 2 +- .../petstore/elixir/lib/openapi_petstore/model/list.ex | 2 +- .../elixir/lib/openapi_petstore/model/map_test.ex | 2 +- ...mixed_properties_and_additional_properties_class.ex | 2 +- .../lib/openapi_petstore/model/model_200_response.ex | 2 +- .../petstore/elixir/lib/openapi_petstore/model/name.ex | 2 +- .../lib/openapi_petstore/model/nullable_class.ex | 2 +- .../elixir/lib/openapi_petstore/model/number_only.ex | 2 +- .../model/object_with_deprecated_fields.ex | 2 +- .../elixir/lib/openapi_petstore/model/order.ex | 2 +- .../lib/openapi_petstore/model/outer_composite.ex | 2 +- .../elixir/lib/openapi_petstore/model/outer_enum.ex | 2 +- .../openapi_petstore/model/outer_enum_default_value.ex | 2 +- .../lib/openapi_petstore/model/outer_enum_integer.ex | 2 +- .../model/outer_enum_integer_default_value.ex | 2 +- .../model/outer_object_with_enum_property.ex | 2 +- .../lib/openapi_petstore/model/parent_with_nullable.ex | 2 +- .../petstore/elixir/lib/openapi_petstore/model/pet.ex | 2 +- .../lib/openapi_petstore/model/read_only_first.ex | 2 +- .../elixir/lib/openapi_petstore/model/return.ex | 2 +- .../lib/openapi_petstore/model/single_ref_type.ex | 2 +- .../petstore/elixir/lib/openapi_petstore/model/tag.ex | 2 +- ...st_inline_freeform_additional_properties_request.ex | 2 +- .../petstore/elixir/lib/openapi_petstore/model/user.ex | 2 +- .../elixir/lib/openapi_petstore/request_builder.ex | 6 +++--- samples/client/petstore/elixir/mix.exs | 3 +-- 60 files changed, 71 insertions(+), 77 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java index 2f73cfd6f33..99be37036d7 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java @@ -57,11 +57,10 @@ public class ElixirClientCodegen extends DefaultCodegen { // This is the name of elixir project name; protected static final String defaultPackageName = "openapi_client"; - String supportedElixirVersion = "1.10"; + String supportedElixirVersion = "1.18"; List extraApplications = Arrays.asList(":logger"); List deps = Arrays.asList( "{:tesla, \"~> 1.7\"}", - "{:jason, \"~> 1.4\"}", "{:ex_doc, \"~> 0.30\", only: :dev, runtime: false}", "{:dialyxir, \"~> 1.3\", only: [:dev, :test], runtime: false}"); @@ -694,7 +693,7 @@ public class ElixirClientCodegen extends DefaultCodegen { } public String decodedStruct() { - // Let Jason decode the entire response into a generic blob + // Decode the entire response into a generic blob if (isMap) { return "%{}"; } diff --git a/modules/openapi-generator/src/main/resources/elixir/connection.ex.mustache b/modules/openapi-generator/src/main/resources/elixir/connection.ex.mustache index 6683a7a456b..18c795e2390 100644 --- a/modules/openapi-generator/src/main/resources/elixir/connection.ex.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/connection.ex.mustache @@ -216,7 +216,7 @@ defmodule {{moduleName}}.Connection do tesla_options = Application.get_env(:tesla, __MODULE__, []) middleware = Keyword.get(tesla_options, :middleware, []) - json_engine = Keyword.get(tesla_options, :json, Jason) + json_engine = Keyword.get(tesla_options, :json, JSON) user_agent = Keyword.get( diff --git a/modules/openapi-generator/src/main/resources/elixir/deserializer.ex.mustache b/modules/openapi-generator/src/main/resources/elixir/deserializer.ex.mustache index 6c3ece2818a..b0b0ad16911 100644 --- a/modules/openapi-generator/src/main/resources/elixir/deserializer.ex.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/deserializer.ex.mustache @@ -4,15 +4,13 @@ defmodule {{moduleName}}.Deserializer do Helper functions for deserializing responses into models """ - @jason_decode_opts [keys: :strings] - - def jason_decode(json) do - Jason.decode(json, @jason_decode_opts) + def json_decode(json) do + JSON.decode(json) end - def jason_decode(json, module) do + def json_decode(json, module) do json - |> jason_decode() + |> json_decode() |> case do {:ok, decoded} -> {:ok, to_struct(decoded, module)} {:error, _} = error -> error diff --git a/modules/openapi-generator/src/main/resources/elixir/model.mustache b/modules/openapi-generator/src/main/resources/elixir/model.mustache index e2dc0facf91..e7afe8407d0 100644 --- a/modules/openapi-generator/src/main/resources/elixir/model.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/model.mustache @@ -4,7 +4,7 @@ {{&description}} """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ {{#vars}}{{#atom}}{{&baseName}}{{/atom}}{{^-last}}, {{/-last}}{{/vars}} diff --git a/modules/openapi-generator/src/main/resources/elixir/request_builder.ex.mustache b/modules/openapi-generator/src/main/resources/elixir/request_builder.ex.mustache index bda2ce4efa7..05a8527bdca 100644 --- a/modules/openapi-generator/src/main/resources/elixir/request_builder.ex.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/request_builder.ex.mustache @@ -94,7 +94,7 @@ defmodule {{moduleName}}.RequestBuilder do Tesla.Multipart.add_field( multipart, key, - Jason.encode!(value), + JSON.encode!(value), headers: [{:"Content-Type", "application/json"}] ) end) @@ -187,10 +187,10 @@ defmodule {{moduleName}}.RequestBuilder do defp decode(%Tesla.Env{} = env, false), do: {:ok, env} defp decode(%Tesla.Env{body: body}, %{}) do - {{moduleName}}.Deserializer.jason_decode(body) + {{moduleName}}.Deserializer.json_decode(body) end defp decode(%Tesla.Env{body: body}, module) do - {{moduleName}}.Deserializer.jason_decode(body, module) + {{moduleName}}.Deserializer.json_decode(body, module) end end diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex b/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex index d3782e7f3a1..ec43955eaf2 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex @@ -153,7 +153,7 @@ defmodule OpenapiPetstore.Connection do tesla_options = Application.get_env(:tesla, __MODULE__, []) middleware = Keyword.get(tesla_options, :middleware, []) - json_engine = Keyword.get(tesla_options, :json, Jason) + json_engine = Keyword.get(tesla_options, :json, JSON) user_agent = Keyword.get( diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/deserializer.ex b/samples/client/petstore/elixir/lib/openapi_petstore/deserializer.ex index a1b42393e42..dcad80581fe 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/deserializer.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/deserializer.ex @@ -6,15 +6,13 @@ defmodule OpenapiPetstore.Deserializer do Helper functions for deserializing responses into models """ - @jason_decode_opts [keys: :strings] - - def jason_decode(json) do - Jason.decode(json, @jason_decode_opts) + def json_decode(json) do + JSON.decode(json) end - def jason_decode(json, module) do + def json_decode(json, module) do json - |> jason_decode() + |> json_decode() |> case do {:ok, decoded} -> {:ok, to_struct(decoded, module)} {:error, _} = error -> error diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/_foo_get_default_response.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/_foo_get_default_response.ex index 4dafa97e429..55e0d1757be 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/_foo_get_default_response.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/_foo_get_default_response.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.FooGetDefaultResponse do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :string ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/_special_model_name_.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/_special_model_name_.ex index f1f419c32c2..99dec84fe15 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/_special_model_name_.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/_special_model_name_.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.SpecialModelName do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :"$special[property.name]" ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/additional_properties_class.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/additional_properties_class.ex index 2bd3c84277e..47baf29d08c 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/additional_properties_class.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/additional_properties_class.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.AdditionalPropertiesClass do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :map_property, :map_of_map_property diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/all_of_with_single_ref.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/all_of_with_single_ref.ex index a3c5f3a0fb9..9b3ae849600 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/all_of_with_single_ref.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/all_of_with_single_ref.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.AllOfWithSingleRef do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :username, :SingleRefType diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/animal.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/animal.ex index f6eb8ce85f8..e60dd0d8f6a 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/animal.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/animal.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Animal do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :className, :color diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/any.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/any.ex index 7dee7481b54..8e87eb48398 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/any.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/any.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Any do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :"@type" ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/api_response.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/api_response.ex index 103922790d5..77097cdb272 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/api_response.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/api_response.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ApiResponse do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :code, :type, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_array_of_number_only.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_array_of_number_only.ex index 31dce8c2e19..2c677885ca2 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_array_of_number_only.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_array_of_number_only.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ArrayOfArrayOfNumberOnly do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :ArrayArrayNumber ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_number_only.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_number_only.ex index b6bc4ffd9f2..095cf30a596 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_number_only.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_number_only.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ArrayOfNumberOnly do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :ArrayNumber ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/array_test.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/array_test.ex index eb347789d97..83f38674af2 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/array_test.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/array_test.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ArrayTest do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :array_of_string, :array_array_of_integer, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/capitalization.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/capitalization.ex index c26b747c45b..0465dafe744 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/capitalization.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/capitalization.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Capitalization do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :smallCamel, :CapitalCamel, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/cat.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/cat.ex index 8690c017a0e..8ca68ee7037 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/cat.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/cat.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Cat do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :className, :color, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/category.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/category.ex index 83f77f68112..a82c4d03966 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/category.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/category.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Category do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :id, :name diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/child_with_nullable.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/child_with_nullable.ex index cb7313d7efd..a8d8bb2aa74 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/child_with_nullable.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/child_with_nullable.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ChildWithNullable do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :type, :nullableProperty, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/class_model.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/class_model.ex index b0fd030518d..eec88ec44d7 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/class_model.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/class_model.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ClassModel do Model for testing model with \"_class\" property """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :_class ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/client.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/client.ex index 311d4608ad3..db2d5e17036 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/client.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/client.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Client do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :client ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/deprecated_model.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/deprecated_model.ex index fe3ac2e6f3f..1352dc9c365 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/deprecated_model.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/deprecated_model.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.DeprecatedModel do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :name ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/dog.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/dog.ex index 557c0403dca..bfad3b402ae 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/dog.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/dog.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Dog do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :className, :color, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_arrays.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_arrays.ex index 950a2362f61..cf92835e599 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_arrays.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_arrays.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.EnumArrays do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :just_symbol, :array_enum diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_class.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_class.ex index 58fdbdef4f1..48ab6e68319 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_class.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_class.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.EnumClass do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_test.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_test.ex index f3cc024d955..f0890be51e7 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_test.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_test.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.EnumTest do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :enum_string, :enum_string_required, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/fake_big_decimal_map_200_response.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/fake_big_decimal_map_200_response.ex index d5d8169fc07..f9e5ef7517c 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/fake_big_decimal_map_200_response.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/fake_big_decimal_map_200_response.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.FakeBigDecimalMap200Response do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :someId, :someMap diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/file.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/file.ex index 8ae26a408d1..ebdbbef0cfc 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/file.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/file.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.File do Must be named `File` for test. """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :sourceURI ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/file_schema_test_class.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/file_schema_test_class.ex index 0f83a3885e8..244686df655 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/file_schema_test_class.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/file_schema_test_class.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.FileSchemaTestClass do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :file, :files diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/foo.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/foo.ex index 8e753c0b6d2..58449af14db 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/foo.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/foo.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Foo do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :bar ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/format_test.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/format_test.ex index 94550b80dfc..ef67673e377 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/format_test.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/format_test.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.FormatTest do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :integer, :int32, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/has_only_read_only.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/has_only_read_only.ex index 29416e81d4d..01b3b2fb91b 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/has_only_read_only.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/has_only_read_only.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.HasOnlyReadOnly do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :bar, :foo diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/health_check_result.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/health_check_result.ex index c6e063700b2..b1bfd45fa62 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/health_check_result.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/health_check_result.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.HealthCheckResult do Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :NullableMessage ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/list.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/list.ex index cc989874bdb..5c724750c95 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/list.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/list.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.List do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :"123-list" ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/map_test.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/map_test.ex index 2a263cd1398..1b1147538de 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/map_test.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/map_test.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.MapTest do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :map_map_of_string, :map_of_enum_string, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/mixed_properties_and_additional_properties_class.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/mixed_properties_and_additional_properties_class.ex index a633727c3e5..89955b8e66e 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/mixed_properties_and_additional_properties_class.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/mixed_properties_and_additional_properties_class.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.MixedPropertiesAndAdditionalPropertiesClass do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :uuid, :dateTime, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/model_200_response.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/model_200_response.ex index 57456a09c0e..003f26a9159 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/model_200_response.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/model_200_response.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Model200Response do Model for testing model name starting with number """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :name, :class diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/name.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/name.ex index ad8cec7ac01..d220a783b20 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/name.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/name.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Name do Model for testing model name same as property name """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :name, :snake_case, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/nullable_class.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/nullable_class.ex index 36595f37c08..8fab347fad9 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/nullable_class.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/nullable_class.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.NullableClass do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :integer_prop, :number_prop, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/number_only.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/number_only.ex index bd0726a29b5..755a4174bb0 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/number_only.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/number_only.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.NumberOnly do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :JustNumber ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/object_with_deprecated_fields.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/object_with_deprecated_fields.ex index 1ec741f7608..17362be72e1 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/object_with_deprecated_fields.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/object_with_deprecated_fields.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ObjectWithDeprecatedFields do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :uuid, :id, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/order.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/order.ex index ab79f944005..5bf534749ed 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/order.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/order.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Order do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :id, :petId, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_composite.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_composite.ex index 78035fdf5cb..af0b16a5ab4 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_composite.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_composite.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.OuterComposite do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :my_number, :my_string, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum.ex index 1f4ad97da8c..d3ba48395d1 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.OuterEnum do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_default_value.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_default_value.ex index f03b45c5eda..9d545017676 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_default_value.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_default_value.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.OuterEnumDefaultValue do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer.ex index 406547bfa69..8829e9bc021 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.OuterEnumInteger do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer_default_value.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer_default_value.ex index f3478f5e62a..45890241e7c 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer_default_value.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer_default_value.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.OuterEnumIntegerDefaultValue do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_object_with_enum_property.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_object_with_enum_property.ex index ec192994544..4bf28207c93 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_object_with_enum_property.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_object_with_enum_property.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.OuterObjectWithEnumProperty do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :value ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/parent_with_nullable.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/parent_with_nullable.ex index 3924d7658de..62a258b37a7 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/parent_with_nullable.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/parent_with_nullable.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ParentWithNullable do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :type, :nullableProperty diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/pet.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/pet.ex index a872b739c80..7870bfc4667 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/pet.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/pet.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Pet do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :id, :category, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/read_only_first.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/read_only_first.ex index e1d20c1e866..c5e3baa77a3 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/read_only_first.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/read_only_first.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ReadOnlyFirst do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :bar, :baz diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/return.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/return.ex index 4719bd1fc9f..26591d8025c 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/return.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/return.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Return do Model for testing reserved words """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :return ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/single_ref_type.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/single_ref_type.ex index 6b74942f72c..cc9601ffad6 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/single_ref_type.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/single_ref_type.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.SingleRefType do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/tag.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/tag.ex index 3f3d7753888..bc2bf64027e 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/tag.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/tag.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Tag do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :id, :name diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/test_inline_freeform_additional_properties_request.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/test_inline_freeform_additional_properties_request.ex index 4baad054575..ce0b4ca8dc3 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/test_inline_freeform_additional_properties_request.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/test_inline_freeform_additional_properties_request.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.TestInlineFreeformAdditionalPropertiesRequest do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :someProperty ] diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/user.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/user.ex index b01c72878df..c522fc4822b 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/user.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/user.ex @@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.User do """ - @derive Jason.Encoder + @derive JSON.Encoder defstruct [ :id, :username, diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/request_builder.ex b/samples/client/petstore/elixir/lib/openapi_petstore/request_builder.ex index 270aba091a7..afa7da3e008 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/request_builder.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/request_builder.ex @@ -96,7 +96,7 @@ defmodule OpenapiPetstore.RequestBuilder do Tesla.Multipart.add_field( multipart, key, - Jason.encode!(value), + JSON.encode!(value), headers: [{:"Content-Type", "application/json"}] ) end) @@ -189,10 +189,10 @@ defmodule OpenapiPetstore.RequestBuilder do defp decode(%Tesla.Env{} = env, false), do: {:ok, env} defp decode(%Tesla.Env{body: body}, %{}) do - OpenapiPetstore.Deserializer.jason_decode(body) + OpenapiPetstore.Deserializer.json_decode(body) end defp decode(%Tesla.Env{body: body}, module) do - OpenapiPetstore.Deserializer.jason_decode(body, module) + OpenapiPetstore.Deserializer.json_decode(body, module) end end diff --git a/samples/client/petstore/elixir/mix.exs b/samples/client/petstore/elixir/mix.exs index 7ccbcd9ffb3..167ea9f4478 100644 --- a/samples/client/petstore/elixir/mix.exs +++ b/samples/client/petstore/elixir/mix.exs @@ -5,7 +5,7 @@ defmodule OpenapiPetstore.Mixfile do [ app: :openapi_petstore, version: "1.0.0", - elixir: "~> 1.10", + elixir: "~> 1.18", build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, package: package(), @@ -36,7 +36,6 @@ defmodule OpenapiPetstore.Mixfile do defp deps do [ {:tesla, "~> 1.7"}, - {:jason, "~> 1.4"}, {:ex_doc, "~> 0.30", only: :dev, runtime: false}, {:dialyxir, "~> 1.3", only: [:dev, :test], runtime: false} ]