Skip to content

Commit 9b6bf34

Browse files
authored
handle Any types that can hold vectors also (#63)
handle case where a property is declared as `object` but response contains a vector.
1 parent a63766e commit 9b6bf34

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ keywords = ["Swagger", "OpenAPI", "REST"]
44
license = "MIT"
55
desc = "OpenAPI server and client helper for Julia"
66
authors = ["JuliaHub Inc."]
7-
version = "0.1.19"
7+
version = "0.1.20"
88

99
[deps]
1010
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

src/json.jl

+6
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ end
8989
function from_json(o::T, name::Symbol, v::Vector) where {T <: APIModel}
9090
# in Julia we can not support JSON null unless the element type is explicitly set to support it
9191
ftype = property_type(T, name)
92+
93+
if ftype === Any
94+
setfield!(o, name, v)
95+
return o
96+
end
97+
9298
vtype = isa(ftype, Union) ? ((ftype.a === Nothing) ? ftype.b : ftype.a) : (ftype <: Vector) ? ftype : Union{}
9399
veltype = eltype(vtype)
94100
(Nothing <: veltype) || filter!(x->x!==nothing, v)

0 commit comments

Comments
 (0)