forked from loafle/openapi-generator-original
Improved Elixir Atom Generation (#20229)
* Update ElixirClientCodegen.java * Refine the regular expression for atoms The original regex incorrectly matched `@atom` (unquoted atoms cannot begin with @). However, through testing with `iex`, it also turns out that the atom `:@` is legal. The following atoms will now be quoted that would have been incorrectly not quoted: - `:@type` * Add model to petstore client to test new atom creation regex pattern
This commit is contained in:
parent
52b5b8fb76
commit
ba5ecbccde
@ -48,7 +48,7 @@ import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
public class ElixirClientCodegen extends DefaultCodegen {
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(ElixirClientCodegen.class);
|
||||
|
||||
private final Pattern simpleAtomPattern = Pattern.compile("\\A(?:(?:[_@\\p{Alpha}][_@\\p{Alnum}]*[?!]?)|-)\\z");
|
||||
private final Pattern simpleAtomPattern = Pattern.compile("\\A(?:(?:[_\\p{Alpha}][_@\\p{Alnum}]*[?!]?)|-|@)\\z");
|
||||
|
||||
@Setter protected String packageVersion = "1.0.0";
|
||||
@Setter protected String moduleName;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -17,6 +17,7 @@ lib/openapi_petstore/model/_special_model_name_.ex
|
||||
lib/openapi_petstore/model/additional_properties_class.ex
|
||||
lib/openapi_petstore/model/all_of_with_single_ref.ex
|
||||
lib/openapi_petstore/model/animal.ex
|
||||
lib/openapi_petstore/model/any.ex
|
||||
lib/openapi_petstore/model/api_response.ex
|
||||
lib/openapi_petstore/model/array_of_array_of_number_only.ex
|
||||
lib/openapi_petstore/model/array_of_number_only.ex
|
||||
|
@ -0,0 +1,22 @@
|
||||
# NOTE: This file is auto generated by OpenAPI Generator 7.11.0-SNAPSHOT (https://openapi-generator.tech).
|
||||
# Do not edit this file manually.
|
||||
|
||||
defmodule OpenapiPetstore.Model.Any do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive Jason.Encoder
|
||||
defstruct [
|
||||
:"@type"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"@type" => String.t | nil
|
||||
}
|
||||
|
||||
def decode(value) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
14
samples/client/petstore/elixir/test/any_test.exs
Normal file
14
samples/client/petstore/elixir/test/any_test.exs
Normal file
@ -0,0 +1,14 @@
|
||||
defmodule AnyTest do
|
||||
use ExUnit.Case, async: true
|
||||
alias OpenapiPetstore.Model.Any, as: Model
|
||||
|
||||
test "decode all properties (not nil)" do
|
||||
assert %Model{
|
||||
"@type": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
|
||||
}
|
||||
|> Model.decode() ==
|
||||
%Model{
|
||||
"@type": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
|
||||
}
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user