-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix and update Elixir generator #15746
base: master
Are you sure you want to change the base?
Changes from all commits
3d49082
fd81598
f687a94
5b51f17
83ce726
ca39c92
7ef55ac
cc1da88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,34 +4,15 @@ | |
{{&description}} | ||
""" | ||
|
||
@derive [Poison.Encoder] | ||
@derive Jason.Encoder | ||
defstruct [ | ||
{{#vars}}{{#atom}}{{&baseName}}{{/atom}}{{^-last}}, | ||
{{#vars}}{{#atom}}{{name}}{{/atom}}{{^-last}}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changes the name and writing of the payload, which results in breaking the spec due to diverging of the property name. see generated examples. |
||
{{/-last}}{{/vars}} | ||
] | ||
|
||
@type t :: %__MODULE__{ | ||
{{#vars}}{{#atom}}{{&baseName}}{{/atom}} => {{{datatype}}}{{#isNullable}} | nil{{/isNullable}}{{^isNullable}}{{^required}} | nil{{/required}}{{/isNullable}}{{^-last}}, | ||
{{#vars}}{{#atom}}{{name}}{{/atom}} => {{{datatype}}}{{#isNullable}} | nil{{/isNullable}}{{^isNullable}}{{^required}} | nil{{/required}}{{/isNullable}}{{^-last}}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, changing the properiename (or cases) breaks the openapi spec |
||
{{/-last}}{{/vars}} | ||
} | ||
end | ||
|
||
defimpl Poison.Decoder, for: {{&moduleName}}.Model.{{&classname}} do | ||
{{#hasComplexVars}} | ||
import {{&moduleName}}.Deserializer | ||
def decode(value, options) do | ||
value | ||
{{#vars}} | ||
{{^isPrimitiveType}} | ||
{{#baseType}}|> deserialize({{#atom}}{{&baseName}}{{/atom}}, {{#isArray}}:list, {{&moduleName}}.Model.{{{items.baseType}}}{{/isArray}}{{#isMap}}:map, {{&moduleName}}.Model.{{{items.baseType}}}{{/isMap}}{{#isDate}}:date, nil{{/isDate}}{{#isDateTime}}:date, nil{{/isDateTime}}{{^isDate}}{{^isDateTime}}{{^isMap}}{{^isArray}}:struct, {{moduleName}}.Model.{{baseType}}{{/isArray}}{{/isMap}}{{/isDateTime}}{{/isDate}}, options) | ||
{{/baseType}} | ||
{{/isPrimitiveType}} | ||
{{/vars}} | ||
{{/hasComplexVars}} | ||
{{^hasComplexVars}} | ||
def decode(value, _options) do | ||
value | ||
{{/hasComplexVars}} | ||
end | ||
end | ||
{{/model}}{{/models}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,19 +6,13 @@ defmodule OpenapiPetstore.Model.SpecialModelName do | |
|
||
""" | ||
|
||
@derive [Poison.Encoder] | ||
@derive Jason.Encoder | ||
defstruct [ | ||
:"$special[property.name]" | ||
:dollar_special_left_square_bracket_property_period_name_right_square_bracket | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
] | ||
|
||
@type t :: %__MODULE__{ | ||
:"$special[property.name]" => integer() | nil | ||
:dollar_special_left_square_bracket_property_period_name_right_square_bracket => integer() | nil | ||
} | ||
end | ||
|
||
defimpl Poison.Decoder, for: OpenapiPetstore.Model.SpecialModelName do | ||
def decode(value, _options) do | ||
value | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Samples will fail, due to
packageVersion
being undefined.