From b49ec6e033df1c8b6f64fddfa3e69f28142345bf Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 6 Oct 2025 15:10:10 +0800 Subject: [PATCH] [fix][elixir] missing type mapping for AnyType (#22081) * fix: unmapped anytype * add tests for any type in elixir client --------- Co-authored-by: Enrique Fernandez --- .../openapitools/codegen/languages/ElixirClientCodegen.java | 1 + .../petstore-with-fake-endpoints-models-for-testing.yaml | 1 + .../petstore/elixir/lib/openapi_petstore/model/any.ex | 6 ++++-- 3 files changed, 6 insertions(+), 2 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 5af1d923890..c68ad41f8a0 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 @@ -226,6 +226,7 @@ public class ElixirClientCodegen extends DefaultCodegen { typeMapping.put("date", "Date.t"); typeMapping.put("date-time", "DateTime.t"); // other + typeMapping.put("AnyType", "any()"); typeMapping.put("ByteArray", "binary()"); typeMapping.put("DateTime", "DateTime.t"); typeMapping.put("UUID", "String.t"); diff --git a/modules/openapi-generator/src/test/resources/3_0/elixir/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/elixir/petstore-with-fake-endpoints-models-for-testing.yaml index 33b40979364..7af5e66e193 100644 --- a/modules/openapi-generator/src/test/resources/3_0/elixir/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/elixir/petstore-with-fake-endpoints-models-for-testing.yaml @@ -2134,6 +2134,7 @@ components: properties: "@type": type: string + any_type_property: {} SingleRefType: type: string title: SingleRefType 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 6c3809d825b..c61687cc262 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/any.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/any.ex @@ -8,11 +8,13 @@ defmodule OpenapiPetstore.Model.Any do @derive JSON.Encoder defstruct [ - :"@type" + :"@type", + :any_type_property ] @type t :: %__MODULE__{ - :"@type" => String.t | nil + :"@type" => String.t | nil, + :any_type_property => any() | nil } def decode(value) do