Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[BUG] Failure To Generate `from_json` Method Using Defined Schema Objects

Đang mở
#73 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
julia, openapi
Lĩnh vực
api, tooling

Hướng nghiên cứu

Bắt đầu với src/json.jl và src/client.jl, các tệp OpenAPI được hiển thị trong stack trace, rồi tái hiện lỗi bằng MWE của IPUMS.jl và các đối tượng schema đã tạo. So sánh các phương thức đã tạo với các phương thức tự-pirate trong IPUMS.jl/src/piracy.jl. Hoàn tất khi các client đã tạo có thể deserialize các đối tượng schema được báo cáo mà không cần các phương thức bổ sung đó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

stale

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]:1

or

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]:1

Here'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.

Ngôn ngữ chính
Julia
Star
56
Fork
16
Merge trung bình
1 ngày 51 phút
Pull request đã merge (30 ngày)
12

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của JuliaComputing/OpenAPI.jl

Tất cả issue của JuliaComputing/OpenAPI.jl

Issue tương tự

Thêm issue về Julia

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.