You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thanks for developing maru and maru_swagger.
I am currently trying to add a swagger documentation for my maru web service and I am struggling with the following error:
16:28:05.906 [error] #PID<0.488.0> running MaruSwaggerTest.Api (connection #PID<0.487.0>, stream id 1) terminated
Server: 0.0.0.0:3456 (http)
Request: GET /swagger
** (exit) an exception was raised:
** (Protocol.UndefinedError) protocol Jason.Encoder not implemented for {:list, "string"} of type Tuple, Jason.Encoder protocol must always be explicitly implemented. This protocol is implemented for the following type(s): Date, BitString, Jason.Fragment, Any, Map, NaiveDateTime, List, Integer, Time, DateTime, Decimal, Atom, Float
(jason) lib/jason.ex:150: Jason.encode!/2
(maru_swagger) lib/maru_swagger/plug.ex:12: MaruSwagger.Plug.call/2
(maru_compile) lib/api.ex:1: anonymous fn/1 in MaruSwaggerTest.Api.call/2
(plug_cowboy) lib/plug/cowboy/handler.ex:12: Plug.Cowboy.Handler.init/2
(cowboy) deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
(cowboy) deps/cowboy/src/cowboy_stream_h.erl:300: :cowboy_stream_h.execute/3
(cowboy) deps/cowboy/src/cowboy_stream_h.erl:291: :cowboy_stream_h.request_process/3
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Apparently, Swagger is trying to encode the tuple {:list, "string"} into a json and that does not work. My api file looks like this:
defmodule MaruSwaggerTest.Api do
use MaruSwaggerTest.Server
use MaruSwagger
plug Plug.Logger
swagger(
at: "/swagger",
pretty: true,
swagger_inject: [
host: "myapp",
basePath: "/api",
schemes: [ "https" ],
consumes: [ "application/json" ],
produces: [ "application/json" ]
])
params do
optional :foo, type: List[String]
end
get "/" do
IO.inspect(params[:foo])
conn
|> send_resp(200, "hello world")
|> halt()
end
end
The error occurs at runtime when I call the /swagger endpoint.
Is this a bug or am I missing something here?
What would be a possible workaround?
The text was updated successfully, but these errors were encountered:
I think the issue is that List[String] is not supported as a parameter type for get requests as of now. I created a pull request where I try to address this issue.
Hello,
thanks for developing maru and maru_swagger.
I am currently trying to add a swagger documentation for my maru web service and I am struggling with the following error:
Apparently, Swagger is trying to encode the tuple {:list, "string"} into a json and that does not work. My api file looks like this:
The error occurs at runtime when I call the /swagger endpoint.
Is this a bug or am I missing something here?
What would be a possible workaround?
The text was updated successfully, but these errors were encountered: