forked from loafle/openapi-generator-original
[elixir] Properly map AnyType (#14497)
This commit is contained in:
parent
82ac92aed6
commit
5047273f1e
@ -45,6 +45,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## LANGUAGE PRIMITIVES
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>AnyType</li>
|
||||
<li>Atom</li>
|
||||
<li>Boolean</li>
|
||||
<li>DateTime</li>
|
||||
@ -56,6 +57,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>PID</li>
|
||||
<li>String</li>
|
||||
<li>Tuple</li>
|
||||
<li>any()</li>
|
||||
<li>map()</li>
|
||||
</ul>
|
||||
|
||||
@ -103,7 +105,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|Uuid|✗|
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Null|✗|OAS3
|
||||
|AnyType|✗|OAS2,OAS3
|
||||
|AnyType|✓|OAS2,OAS3
|
||||
|Object|✓|OAS2,OAS3
|
||||
|Maps|✓|ToolingExtension
|
||||
|CollectionFormat|✓|OAS2
|
||||
|
@ -88,6 +88,9 @@ public class ElixirClientCodegen extends DefaultCodegen {
|
||||
.includeClientModificationFeatures(
|
||||
ClientModificationFeature.BasePath
|
||||
)
|
||||
.includeDataTypeFeatures(
|
||||
DataTypeFeature.AnyType
|
||||
)
|
||||
);
|
||||
|
||||
// set the output folder here
|
||||
@ -188,10 +191,12 @@ public class ElixirClientCodegen extends DefaultCodegen {
|
||||
"List",
|
||||
"Atom",
|
||||
"Map",
|
||||
"AnyType",
|
||||
"Tuple",
|
||||
"PID",
|
||||
"DateTime",
|
||||
"map()" // This is a workaround, since the DefaultCodeGen uses our elixir TypeSpec datetype to evaluate the primitive
|
||||
"map()", // This is a workaround, since the DefaultCodeGen uses our elixir TypeSpec datetype to evaluate the primitive
|
||||
"any()"
|
||||
)
|
||||
);
|
||||
|
||||
@ -575,6 +580,8 @@ public class ElixirClientCodegen extends DefaultCodegen {
|
||||
return "String.t";
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
return "String.t";
|
||||
} else if (p.getType() == null) {
|
||||
return "any()";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
@ -785,8 +792,13 @@ public class ElixirClientCodegen extends DefaultCodegen {
|
||||
returnEntry.append(moduleName);
|
||||
returnEntry.append(".Model.");
|
||||
}
|
||||
returnEntry.append(exResponse.baseType);
|
||||
returnEntry.append(".t");
|
||||
|
||||
if (exResponse.baseType.equals("AnyType")) {
|
||||
returnEntry.append("any()");
|
||||
}else {
|
||||
returnEntry.append(exResponse.baseType);
|
||||
returnEntry.append(".t");
|
||||
}
|
||||
} else {
|
||||
if (exResponse.containerType.equals("array") ||
|
||||
exResponse.containerType.equals("set")) {
|
||||
@ -795,8 +807,13 @@ public class ElixirClientCodegen extends DefaultCodegen {
|
||||
returnEntry.append(moduleName);
|
||||
returnEntry.append(".Model.");
|
||||
}
|
||||
returnEntry.append(exResponse.baseType);
|
||||
returnEntry.append(".t)");
|
||||
|
||||
if (exResponse.baseType.equals("AnyType")) {
|
||||
returnEntry.append("any())");
|
||||
}else {
|
||||
returnEntry.append(exResponse.baseType);
|
||||
returnEntry.append(".t)");
|
||||
}
|
||||
} else if (exResponse.containerType.equals("map")) {
|
||||
returnEntry.append("map()");
|
||||
}
|
||||
|
@ -14,15 +14,13 @@ defmodule OpenapiPetstore.Model.AllOfWithSingleRef do
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:username => String.t | nil,
|
||||
:SingleRefType => SingleRefType | nil
|
||||
:SingleRefType => any() | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenapiPetstore.Model.AllOfWithSingleRef do
|
||||
import OpenapiPetstore.Deserializer
|
||||
def decode(value, options) do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
|> deserialize(:SingleRefType, :struct, OpenapiPetstore.Model.SingleRefType, options)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user