forked from loafle/openapi-generator-original
[feat][elixir] use elixir 1.18 built-in json module (#21039)
* feat: replace jason by built-in json encoder/decoder * chore: update samples
This commit is contained in:
parent
7a3ea2872a
commit
dcd9463e88
@ -57,11 +57,10 @@ public class ElixirClientCodegen extends DefaultCodegen {
|
|||||||
// This is the name of elixir project name;
|
// This is the name of elixir project name;
|
||||||
protected static final String defaultPackageName = "openapi_client";
|
protected static final String defaultPackageName = "openapi_client";
|
||||||
|
|
||||||
String supportedElixirVersion = "1.10";
|
String supportedElixirVersion = "1.18";
|
||||||
List<String> extraApplications = Arrays.asList(":logger");
|
List<String> extraApplications = Arrays.asList(":logger");
|
||||||
List<String> deps = Arrays.asList(
|
List<String> deps = Arrays.asList(
|
||||||
"{:tesla, \"~> 1.7\"}",
|
"{:tesla, \"~> 1.7\"}",
|
||||||
"{:jason, \"~> 1.4\"}",
|
|
||||||
"{:ex_doc, \"~> 0.30\", only: :dev, runtime: false}",
|
"{:ex_doc, \"~> 0.30\", only: :dev, runtime: false}",
|
||||||
"{:dialyxir, \"~> 1.3\", only: [:dev, :test], runtime: false}");
|
"{:dialyxir, \"~> 1.3\", only: [:dev, :test], runtime: false}");
|
||||||
|
|
||||||
@ -694,7 +693,7 @@ public class ElixirClientCodegen extends DefaultCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String decodedStruct() {
|
public String decodedStruct() {
|
||||||
// Let Jason decode the entire response into a generic blob
|
// Decode the entire response into a generic blob
|
||||||
if (isMap) {
|
if (isMap) {
|
||||||
return "%{}";
|
return "%{}";
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ defmodule {{moduleName}}.Connection do
|
|||||||
|
|
||||||
tesla_options = Application.get_env(:tesla, __MODULE__, [])
|
tesla_options = Application.get_env(:tesla, __MODULE__, [])
|
||||||
middleware = Keyword.get(tesla_options, :middleware, [])
|
middleware = Keyword.get(tesla_options, :middleware, [])
|
||||||
json_engine = Keyword.get(tesla_options, :json, Jason)
|
json_engine = Keyword.get(tesla_options, :json, JSON)
|
||||||
|
|
||||||
user_agent =
|
user_agent =
|
||||||
Keyword.get(
|
Keyword.get(
|
||||||
|
@ -4,15 +4,13 @@ defmodule {{moduleName}}.Deserializer do
|
|||||||
Helper functions for deserializing responses into models
|
Helper functions for deserializing responses into models
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@jason_decode_opts [keys: :strings]
|
def json_decode(json) do
|
||||||
|
JSON.decode(json)
|
||||||
def jason_decode(json) do
|
|
||||||
Jason.decode(json, @jason_decode_opts)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def jason_decode(json, module) do
|
def json_decode(json, module) do
|
||||||
json
|
json
|
||||||
|> jason_decode()
|
|> json_decode()
|
||||||
|> case do
|
|> case do
|
||||||
{:ok, decoded} -> {:ok, to_struct(decoded, module)}
|
{:ok, decoded} -> {:ok, to_struct(decoded, module)}
|
||||||
{:error, _} = error -> error
|
{:error, _} = error -> error
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{{&description}}
|
{{&description}}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
{{#vars}}{{#atom}}{{&baseName}}{{/atom}}{{^-last}},
|
{{#vars}}{{#atom}}{{&baseName}}{{/atom}}{{^-last}},
|
||||||
{{/-last}}{{/vars}}
|
{{/-last}}{{/vars}}
|
||||||
|
@ -94,7 +94,7 @@ defmodule {{moduleName}}.RequestBuilder do
|
|||||||
Tesla.Multipart.add_field(
|
Tesla.Multipart.add_field(
|
||||||
multipart,
|
multipart,
|
||||||
key,
|
key,
|
||||||
Jason.encode!(value),
|
JSON.encode!(value),
|
||||||
headers: [{:"Content-Type", "application/json"}]
|
headers: [{:"Content-Type", "application/json"}]
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
@ -187,10 +187,10 @@ defmodule {{moduleName}}.RequestBuilder do
|
|||||||
defp decode(%Tesla.Env{} = env, false), do: {:ok, env}
|
defp decode(%Tesla.Env{} = env, false), do: {:ok, env}
|
||||||
|
|
||||||
defp decode(%Tesla.Env{body: body}, %{}) do
|
defp decode(%Tesla.Env{body: body}, %{}) do
|
||||||
{{moduleName}}.Deserializer.jason_decode(body)
|
{{moduleName}}.Deserializer.json_decode(body)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp decode(%Tesla.Env{body: body}, module) do
|
defp decode(%Tesla.Env{body: body}, module) do
|
||||||
{{moduleName}}.Deserializer.jason_decode(body, module)
|
{{moduleName}}.Deserializer.json_decode(body, module)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -153,7 +153,7 @@ defmodule OpenapiPetstore.Connection do
|
|||||||
|
|
||||||
tesla_options = Application.get_env(:tesla, __MODULE__, [])
|
tesla_options = Application.get_env(:tesla, __MODULE__, [])
|
||||||
middleware = Keyword.get(tesla_options, :middleware, [])
|
middleware = Keyword.get(tesla_options, :middleware, [])
|
||||||
json_engine = Keyword.get(tesla_options, :json, Jason)
|
json_engine = Keyword.get(tesla_options, :json, JSON)
|
||||||
|
|
||||||
user_agent =
|
user_agent =
|
||||||
Keyword.get(
|
Keyword.get(
|
||||||
|
@ -6,15 +6,13 @@ defmodule OpenapiPetstore.Deserializer do
|
|||||||
Helper functions for deserializing responses into models
|
Helper functions for deserializing responses into models
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@jason_decode_opts [keys: :strings]
|
def json_decode(json) do
|
||||||
|
JSON.decode(json)
|
||||||
def jason_decode(json) do
|
|
||||||
Jason.decode(json, @jason_decode_opts)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def jason_decode(json, module) do
|
def json_decode(json, module) do
|
||||||
json
|
json
|
||||||
|> jason_decode()
|
|> json_decode()
|
||||||
|> case do
|
|> case do
|
||||||
{:ok, decoded} -> {:ok, to_struct(decoded, module)}
|
{:ok, decoded} -> {:ok, to_struct(decoded, module)}
|
||||||
{:error, _} = error -> error
|
{:error, _} = error -> error
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.FooGetDefaultResponse do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:string
|
:string
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.SpecialModelName do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:"$special[property.name]"
|
:"$special[property.name]"
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.AdditionalPropertiesClass do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:map_property,
|
:map_property,
|
||||||
:map_of_map_property
|
:map_of_map_property
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.AllOfWithSingleRef do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:username,
|
:username,
|
||||||
:SingleRefType
|
:SingleRefType
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Animal do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:className,
|
:className,
|
||||||
:color
|
:color
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Any do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:"@type"
|
:"@type"
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ApiResponse do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:code,
|
:code,
|
||||||
:type,
|
:type,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ArrayOfArrayOfNumberOnly do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:ArrayArrayNumber
|
:ArrayArrayNumber
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ArrayOfNumberOnly do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:ArrayNumber
|
:ArrayNumber
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ArrayTest do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:array_of_string,
|
:array_of_string,
|
||||||
:array_array_of_integer,
|
:array_array_of_integer,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Capitalization do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:smallCamel,
|
:smallCamel,
|
||||||
:CapitalCamel,
|
:CapitalCamel,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Cat do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:className,
|
:className,
|
||||||
:color,
|
:color,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Category do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:id,
|
:id,
|
||||||
:name
|
:name
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ChildWithNullable do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:type,
|
:type,
|
||||||
:nullableProperty,
|
:nullableProperty,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ClassModel do
|
|||||||
Model for testing model with \"_class\" property
|
Model for testing model with \"_class\" property
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:_class
|
:_class
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Client do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:client
|
:client
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.DeprecatedModel do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:name
|
:name
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Dog do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:className,
|
:className,
|
||||||
:color,
|
:color,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.EnumArrays do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:just_symbol,
|
:just_symbol,
|
||||||
:array_enum
|
:array_enum
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.EnumClass do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
|
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.EnumTest do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:enum_string,
|
:enum_string,
|
||||||
:enum_string_required,
|
:enum_string_required,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.FakeBigDecimalMap200Response do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:someId,
|
:someId,
|
||||||
:someMap
|
:someMap
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.File do
|
|||||||
Must be named `File` for test.
|
Must be named `File` for test.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:sourceURI
|
:sourceURI
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.FileSchemaTestClass do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:file,
|
:file,
|
||||||
:files
|
:files
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Foo do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:bar
|
:bar
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.FormatTest do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:integer,
|
:integer,
|
||||||
:int32,
|
:int32,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.HasOnlyReadOnly do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:bar,
|
:bar,
|
||||||
:foo
|
:foo
|
||||||
|
@ -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.
|
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 [
|
defstruct [
|
||||||
:NullableMessage
|
:NullableMessage
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.List do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:"123-list"
|
:"123-list"
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.MapTest do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:map_map_of_string,
|
:map_map_of_string,
|
||||||
:map_of_enum_string,
|
:map_of_enum_string,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.MixedPropertiesAndAdditionalPropertiesClass do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:uuid,
|
:uuid,
|
||||||
:dateTime,
|
:dateTime,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Model200Response do
|
|||||||
Model for testing model name starting with number
|
Model for testing model name starting with number
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:name,
|
:name,
|
||||||
:class
|
:class
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Name do
|
|||||||
Model for testing model name same as property name
|
Model for testing model name same as property name
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:name,
|
:name,
|
||||||
:snake_case,
|
:snake_case,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.NullableClass do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:integer_prop,
|
:integer_prop,
|
||||||
:number_prop,
|
:number_prop,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.NumberOnly do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:JustNumber
|
:JustNumber
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ObjectWithDeprecatedFields do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:uuid,
|
:uuid,
|
||||||
:id,
|
:id,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Order do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:id,
|
:id,
|
||||||
:petId,
|
:petId,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.OuterComposite do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:my_number,
|
:my_number,
|
||||||
:my_string,
|
:my_string,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.OuterEnum do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
|
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.OuterEnumDefaultValue do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
|
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.OuterEnumInteger do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
|
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.OuterEnumIntegerDefaultValue do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
|
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.OuterObjectWithEnumProperty do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:value
|
:value
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ParentWithNullable do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:type,
|
:type,
|
||||||
:nullableProperty
|
:nullableProperty
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Pet do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:id,
|
:id,
|
||||||
:category,
|
:category,
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.ReadOnlyFirst do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:bar,
|
:bar,
|
||||||
:baz
|
:baz
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Return do
|
|||||||
Model for testing reserved words
|
Model for testing reserved words
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:return
|
:return
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.SingleRefType do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
|
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.Tag do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:id,
|
:id,
|
||||||
:name
|
:name
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.TestInlineFreeformAdditionalPropertiesRequest do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:someProperty
|
:someProperty
|
||||||
]
|
]
|
||||||
|
@ -6,7 +6,7 @@ defmodule OpenapiPetstore.Model.User do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@derive Jason.Encoder
|
@derive JSON.Encoder
|
||||||
defstruct [
|
defstruct [
|
||||||
:id,
|
:id,
|
||||||
:username,
|
:username,
|
||||||
|
@ -96,7 +96,7 @@ defmodule OpenapiPetstore.RequestBuilder do
|
|||||||
Tesla.Multipart.add_field(
|
Tesla.Multipart.add_field(
|
||||||
multipart,
|
multipart,
|
||||||
key,
|
key,
|
||||||
Jason.encode!(value),
|
JSON.encode!(value),
|
||||||
headers: [{:"Content-Type", "application/json"}]
|
headers: [{:"Content-Type", "application/json"}]
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
@ -189,10 +189,10 @@ defmodule OpenapiPetstore.RequestBuilder do
|
|||||||
defp decode(%Tesla.Env{} = env, false), do: {:ok, env}
|
defp decode(%Tesla.Env{} = env, false), do: {:ok, env}
|
||||||
|
|
||||||
defp decode(%Tesla.Env{body: body}, %{}) do
|
defp decode(%Tesla.Env{body: body}, %{}) do
|
||||||
OpenapiPetstore.Deserializer.jason_decode(body)
|
OpenapiPetstore.Deserializer.json_decode(body)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp decode(%Tesla.Env{body: body}, module) do
|
defp decode(%Tesla.Env{body: body}, module) do
|
||||||
OpenapiPetstore.Deserializer.jason_decode(body, module)
|
OpenapiPetstore.Deserializer.json_decode(body, module)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,7 +5,7 @@ defmodule OpenapiPetstore.Mixfile do
|
|||||||
[
|
[
|
||||||
app: :openapi_petstore,
|
app: :openapi_petstore,
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
elixir: "~> 1.10",
|
elixir: "~> 1.18",
|
||||||
build_embedded: Mix.env() == :prod,
|
build_embedded: Mix.env() == :prod,
|
||||||
start_permanent: Mix.env() == :prod,
|
start_permanent: Mix.env() == :prod,
|
||||||
package: package(),
|
package: package(),
|
||||||
@ -36,7 +36,6 @@ defmodule OpenapiPetstore.Mixfile do
|
|||||||
defp deps do
|
defp deps do
|
||||||
[
|
[
|
||||||
{:tesla, "~> 1.7"},
|
{:tesla, "~> 1.7"},
|
||||||
{:jason, "~> 1.4"},
|
|
||||||
{:ex_doc, "~> 0.30", only: :dev, runtime: false},
|
{:ex_doc, "~> 0.30", only: :dev, runtime: false},
|
||||||
{:dialyxir, "~> 1.3", only: [:dev, :test], runtime: false}
|
{:dialyxir, "~> 1.3", only: [:dev, :test], runtime: false}
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user