-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Description
The MIME string formats for JSON are hardcoded here:
Line 261 in 6c820c5
is_json_mime(mime::T) where {T <: AbstractString} = ("*/*" == mime) || occursin(r"(?i)application/json(;.*)?", mime) || occursin(r"(?i)application/(.*)-patch\+json(;.*)?", mime) |
but some servers like Phylopic respond in their own application-specific MIME types that are nevertheless JSON. There needs to be some form of switch to control which MIME type is accepted for JSON parsing. Otherwise, OpenAPI calls fail with inscrutable errors like:
julia> APIClient.get_image(APIClient.ImagesApi(c), "abb918ae-6d3d-4dd3-a6eb-e5457199f25f")
ERROR: MethodError: Cannot `convert` an object of type Vector{UInt8} to an object of type Main.APIClient.ImageWithEmbedded
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] response(::Type{Main.APIClient.ImageWithEmbedded}, data::Vector{UInt8})
@ OpenAPI.Clients ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:427
[2] response(::Type{Main.APIClient.ImageWithEmbedded}, is_json::Bool, body::Vector{UInt8})
@ OpenAPI.Clients ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:417
[3] response(::Type{Main.APIClient.ImageWithEmbedded}, resp::Downloads.Response, body::Vector{UInt8})
@ OpenAPI.Clients ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:412
[4] exec(ctx::OpenAPI.Clients.Ctx, stream_to::Nothing)
@ OpenAPI.Clients ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:634
[5] exec
@ ~/.julia/packages/OpenAPI/GMeGW/src/client.jl:614 [inlined]
[6] #get_image#186
@ ~/.julia/dev/SpeciesDistributionToolkit/Phylopic/gen/src/apis/api_ImagesApi.jl:56 [inlined]
[7] get_image(_api::Main.APIClient.ImagesApi, uuid::String)
@ Main.APIClient ~/.julia/dev/SpeciesDistributionToolkit/Phylopic/gen/src/apis/api_ImagesApi.jl:54
cc @TheCedarPrince who is possibly having the same issue.
TheCedarPrince
Metadata
Metadata
Assignees
Labels
No labels