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
|
## LANGUAGE PRIMITIVES
|
||||||
|
|
||||||
<ul class="column-ul">
|
<ul class="column-ul">
|
||||||
|
<li>AnyType</li>
|
||||||
<li>Atom</li>
|
<li>Atom</li>
|
||||||
<li>Boolean</li>
|
<li>Boolean</li>
|
||||||
<li>DateTime</li>
|
<li>DateTime</li>
|
||||||
@ -56,6 +57,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
<li>PID</li>
|
<li>PID</li>
|
||||||
<li>String</li>
|
<li>String</li>
|
||||||
<li>Tuple</li>
|
<li>Tuple</li>
|
||||||
|
<li>any()</li>
|
||||||
<li>map()</li>
|
<li>map()</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@ -103,7 +105,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|Uuid|✗|
|
|Uuid|✗|
|
||||||
|Array|✓|OAS2,OAS3
|
|Array|✓|OAS2,OAS3
|
||||||
|Null|✗|OAS3
|
|Null|✗|OAS3
|
||||||
|AnyType|✗|OAS2,OAS3
|
|AnyType|✓|OAS2,OAS3
|
||||||
|Object|✓|OAS2,OAS3
|
|Object|✓|OAS2,OAS3
|
||||||
|Maps|✓|ToolingExtension
|
|Maps|✓|ToolingExtension
|
||||||
|CollectionFormat|✓|OAS2
|
|CollectionFormat|✓|OAS2
|
||||||
|
@ -88,6 +88,9 @@ public class ElixirClientCodegen extends DefaultCodegen {
|
|||||||
.includeClientModificationFeatures(
|
.includeClientModificationFeatures(
|
||||||
ClientModificationFeature.BasePath
|
ClientModificationFeature.BasePath
|
||||||
)
|
)
|
||||||
|
.includeDataTypeFeatures(
|
||||||
|
DataTypeFeature.AnyType
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// set the output folder here
|
// set the output folder here
|
||||||
@ -188,10 +191,12 @@ public class ElixirClientCodegen extends DefaultCodegen {
|
|||||||
"List",
|
"List",
|
||||||
"Atom",
|
"Atom",
|
||||||
"Map",
|
"Map",
|
||||||
|
"AnyType",
|
||||||
"Tuple",
|
"Tuple",
|
||||||
"PID",
|
"PID",
|
||||||
"DateTime",
|
"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";
|
return "String.t";
|
||||||
} else if (ModelUtils.isStringSchema(p)) {
|
} else if (ModelUtils.isStringSchema(p)) {
|
||||||
return "String.t";
|
return "String.t";
|
||||||
|
} else if (p.getType() == null) {
|
||||||
|
return "any()";
|
||||||
}
|
}
|
||||||
return super.getTypeDeclaration(p);
|
return super.getTypeDeclaration(p);
|
||||||
}
|
}
|
||||||
@ -785,8 +792,13 @@ public class ElixirClientCodegen extends DefaultCodegen {
|
|||||||
returnEntry.append(moduleName);
|
returnEntry.append(moduleName);
|
||||||
returnEntry.append(".Model.");
|
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 {
|
} else {
|
||||||
if (exResponse.containerType.equals("array") ||
|
if (exResponse.containerType.equals("array") ||
|
||||||
exResponse.containerType.equals("set")) {
|
exResponse.containerType.equals("set")) {
|
||||||
@ -795,8 +807,13 @@ public class ElixirClientCodegen extends DefaultCodegen {
|
|||||||
returnEntry.append(moduleName);
|
returnEntry.append(moduleName);
|
||||||
returnEntry.append(".Model.");
|
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")) {
|
} else if (exResponse.containerType.equals("map")) {
|
||||||
returnEntry.append("map()");
|
returnEntry.append("map()");
|
||||||
}
|
}
|
||||||
|
@ -14,15 +14,13 @@ defmodule OpenapiPetstore.Model.AllOfWithSingleRef do
|
|||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
:username => String.t | nil,
|
:username => String.t | nil,
|
||||||
:SingleRefType => SingleRefType | nil
|
:SingleRefType => any() | nil
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
defimpl Poison.Decoder, for: OpenapiPetstore.Model.AllOfWithSingleRef do
|
defimpl Poison.Decoder, for: OpenapiPetstore.Model.AllOfWithSingleRef do
|
||||||
import OpenapiPetstore.Deserializer
|
def decode(value, _options) do
|
||||||
def decode(value, options) do
|
|
||||||
value
|
value
|
||||||
|> deserialize(:SingleRefType, :struct, OpenapiPetstore.Model.SingleRefType, options)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user