-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Hi folks,
I am seeing an error in my IPUMS.jl package where when I used the OpenAPI definition for IPUMS (also see here for the reference documentation: https://developer.ipums.org/docs/v2/reference/nhgis/), the methods to handle from_json definitions being generated by OpenAPI do not exist to handle the schema objects defined in the original OpenAPI definition for IPUMS.
Instead, what I am forced to do is to basically, self-pirate these generated methods within my package to get things working. Otherwise, I get errors such as these:
ERROR: MethodError: no method matching from_json(::Vector{IPUMS.TimeSeriesTableSimple}, ::Dict{String, Any})
Closest candidates are:
from_json(::Vector{IPUMS.DatasetSimple}, ::Any)
@ IPUMS ~/FOSS/IPUMS.jl/src/piracy.jl:7
from_json(::Vector{IPUMS.TimeSeriesTableFull}, ::Any)
@ IPUMS ~/FOSS/IPUMS.jl/src/piracy.jl:12
from_json(::Vector{IPUMS.Shapefile}, ::Any)
@ IPUMS ~/FOSS/IPUMS.jl/src/piracy.jl:16
...
Stacktrace:
[1] from_json(::Type{Vector{IPUMS.TimeSeriesTableSimple}}, json::Dict{String, Any})
@ OpenAPI ~/.julia/packages/OpenAPI/GMeGW/src/json.jl:40
[2] response(::Type{Vector{IPUMS.TimeSeriesTableSimple}}, data::Dict{String, Any})
@ OpenAPI.Clients ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:428
[3] response(::Type{Vector{IPUMS.TimeSeriesTableSimple}}, is_json::Bool, body::Vector{UInt8})
@ OpenAPI.Clients ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:417
[4] response(::Type{Vector{IPUMS.TimeSeriesTableSimple}}, resp::Downloads.Response, body::Vector{UInt8})
@ OpenAPI.Clients ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:412
[5] exec(ctx::OpenAPI.Clients.Ctx, stream_to::Nothing)
@ OpenAPI.Clients ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:634
[6] exec
@ ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:614 [inlined]
[7] #metadata_nhgis_time_series_tables_get#61
@ ~/FOSS/IPUMS.jl/src/apis/api_DefaultApi.jl:315 [inlined]
[8] metadata_nhgis_time_series_tables_get(_api::DefaultApi, version::String)
@ IPUMS ~/FOSS/IPUMS.jl/src/apis/api_DefaultApi.jl:313
[9] top-level scope
@ REPL[11]:1or
ERROR: MethodError: Cannot `convert` an object of type Vector{Any} to an object of type IPUMS.DatasetFullBreakdowns
Closest candidates are:
convert(::Type{T}, ::T) where T
@ Base Base.jl:84
convert(::Type{T}, ::Dict{String, Any}) where T<:OpenAPI.APIModel
@ OpenAPI ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:715
convert(::Type{T}, ::Nothing) where T<:OpenAPI.APIModel
@ OpenAPI ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:716
...
Stacktrace:
[1] convert(::Type{Union{Nothing, IPUMS.DatasetFullBreakdowns}}, x::Vector{Any})
@ Base ./some.jl:37
[2] from_json(o::IPUMS.DatasetFull, name::Symbol, v::Vector{Any})
@ OpenAPI ~/.julia/packages/OpenAPI/GMeGW/src/json.jl:103
[3] from_json(o::IPUMS.DatasetFull, json::Dict{String, Any})
@ OpenAPI ~/.julia/packages/OpenAPI/GMeGW/src/json.jl:58
[4] from_json
@ ~/.julia/packages/OpenAPI/GMeGW/src/json.jl:40 [inlined]
[5] response
@ ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:428 [inlined]
[6] response(::Type{IPUMS.DatasetFull}, is_json::Bool, body::Vector{UInt8})
@ OpenAPI.Clients ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:417
[7] response(::Type{IPUMS.DatasetFull}, resp::Downloads.Response, body::Vector{UInt8})
@ OpenAPI.Clients ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:412
[8] exec(ctx::OpenAPI.Clients.Ctx, stream_to::Nothing)
@ OpenAPI.Clients ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:634
[9] exec
@ ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:614 [inlined]
[10] #metadata_nhgis_datasets_dataset_get#52
@ ~/FOSS/IPUMS.jl/src/apis/api_DefaultApi.jl:216 [inlined]
[11] metadata_nhgis_datasets_dataset_get(_api::DefaultApi, dataset::String, version::String)
@ IPUMS ~/FOSS/IPUMS.jl/src/apis/api_DefaultApi.jl:214
[12] top-level scope
@ REPL[13]:1Here's a mostly working MWE minus an API key (that you can generate here):
julia> using IPUMS
julia> using OpenAPI.Clients
julia> import OpenAPI.Clients: Client
julia> client = Client("https://api.ipums.org", headers = Dict("Authorization" => "API_KEY")
julia> api = DefaultApi(client)And this would be after you generate the API with the openapi-cli tool. Happy to provide further information.
Metadata
Metadata
Assignees
Labels
No labels