Skip to content

Commit 93a3335

Browse files
committed
fix: inner types in maps
1 parent 356647d commit 93a3335

6 files changed

Lines changed: 19 additions & 15 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,10 @@ public String ectoType() {
11141114
}
11151115

11161116
private String ectoType(CodegenProperty property) {
1117+
if (property == null) {
1118+
return ":any";
1119+
}
1120+
11171121
if (property.isEnumRef) {
11181122
List<Object> values = (List<Object>) property.allowableValues.get("values");
11191123
if (!values.isEmpty()) {
@@ -1157,7 +1161,7 @@ private String ectoType(CodegenProperty property) {
11571161
case "list()":
11581162
return "{:array, " + ectoType(property.items) + "}";
11591163
case "map()":
1160-
return ":map";
1164+
return "{:map, " + ectoType(property.items) + "}";
11611165
case "nil":
11621166
return ":any";
11631167
default:

samples/client/petstore/elixir/lib/openapi_petstore/model/additional_properties_class.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ defmodule OpenapiPetstore.Model.AdditionalPropertiesClass do
1515
@derive {JSON.Encoder, only: [:map_property, :map_of_map_property]}
1616
@primary_key false
1717
embedded_schema do
18-
field :map_property, :map
19-
field :map_of_map_property, :map
18+
field :map_property, {:map, :string}
19+
field :map_of_map_property, {:map, {:map, :string}}
2020
end
2121

2222
@spec changeset(t(), map()) :: Ecto.Changeset.t()

samples/client/petstore/elixir/lib/openapi_petstore/model/fake_big_decimal_map_200_response.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ defmodule OpenapiPetstore.Model.FakeBigDecimalMap200Response do
1616
@primary_key false
1717
embedded_schema do
1818
field :someId, :float
19-
field :someMap, :map
19+
field :someMap, {:map, :float}
2020
end
2121

2222
@spec changeset(t(), map()) :: Ecto.Changeset.t()

samples/client/petstore/elixir/lib/openapi_petstore/model/map_test.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ defmodule OpenapiPetstore.Model.MapTest do
1717
@derive {JSON.Encoder, only: [:map_map_of_string, :map_of_enum_string, :direct_map, :indirect_map]}
1818
@primary_key false
1919
embedded_schema do
20-
field :map_map_of_string, :map
21-
field :map_of_enum_string, :map
22-
field :direct_map, :map
23-
field :indirect_map, :map
20+
field :map_map_of_string, {:map, {:map, :string}}
21+
field :map_of_enum_string, {:map, :string}
22+
field :direct_map, {:map, :boolean}
23+
field :indirect_map, {:map, :boolean}
2424
end
2525

2626
@spec changeset(t(), map()) :: Ecto.Changeset.t()

samples/client/petstore/elixir/lib/openapi_petstore/model/mixed_properties_and_additional_properties_class.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ defmodule OpenapiPetstore.Model.MixedPropertiesAndAdditionalPropertiesClass do
1818
embedded_schema do
1919
field :uuid, :string
2020
field :dateTime, :utc_datetime
21-
field :map, :map
21+
field :map, {:map, :any}
2222
end
2323

2424
@spec changeset(t(), map()) :: Ecto.Changeset.t()

samples/client/petstore/elixir/lib/openapi_petstore/model/nullable_class.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ defmodule OpenapiPetstore.Model.NullableClass do
3131
field :string_prop, :string
3232
field :date_prop, :date
3333
field :datetime_prop, :utc_datetime
34-
field :array_nullable_prop, {:array, :map}
35-
field :array_and_items_nullable_prop, {:array, :map}
36-
field :array_items_nullable, {:array, :map}
37-
field :object_nullable_prop, :map
38-
field :object_and_items_nullable_prop, :map
39-
field :object_items_nullable, :map
34+
field :array_nullable_prop, {:array, {:map, :any}}
35+
field :array_and_items_nullable_prop, {:array, {:map, :any}}
36+
field :array_items_nullable, {:array, {:map, :any}}
37+
field :object_nullable_prop, {:map, {:map, :any}}
38+
field :object_and_items_nullable_prop, {:map, {:map, :any}}
39+
field :object_items_nullable, {:map, {:map, :any}}
4040
end
4141

4242
@spec changeset(t(), map()) :: Ecto.Changeset.t()

0 commit comments

Comments
 (0)