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
By route definition like this I end up with having two index functions inside VideoController that are pattern matching different params.
# VideoController.exdefVideoControllerdouseHelloWeb,:controllerusePhoenixSwaggerswagger_path:indexdoget("/api/v1/video-channels/{video_channel_id}/videos")description("Returns videos filtered by video channel.")enddefindex(conn,%{"video_channel_id"=>video_channel_id}=params})do..listofvideosfilteredbyvideochannelID..endswagger_path:indexdoget("/api/v1/videos")description("Returns videos filtered by video channel.")enddefindex(conn,params)do..listofvideos...endend
Then during the compilation I get:
$ mix phx.swagger.generate
Compiling 2 files (.ex)
warning: this clause cannot match because a previous clause at line 20 always matches
*/video_controller.ex:87
The problem is that both swagger_paths are using the same action :index, although they handle completely different urls. Is this scenario supported? If it's not supported, is there some recommended workaround for nested resources then ?
Thank you
The text was updated successfully, but these errors were encountered:
The only workaround so far I could come up with is not using nested resources, but rather define urls in router statically and use defdelegate to keep backward compatibility with nested resources if utilized again in the future:
# VideoController.exdefVideoControllerdouseHelloWeb,:controllerusePhoenixSwaggerdefdelegateindex_by_video_channel(conn,params),to: VideoController,as: :indexswagger_path:index_by_video_channeldoget("/api/v1/video-channels/{video_channel_id}/videos")description("Returns videos filtered by video channel.")enddefindex(conn,%{"video_channel_id"=>video_channel_id}=params})do..listofvideosfilteredbyvideochannelID..endswagger_path:indexdoget("/api/v1/videos")description("Returns videos filtered by video channel.")enddefindex(conn,params)do..listofvideos...endend
Hi,
I've intercepted a problem that I couldn't find solution to. It concerns nested phoenix resources and documenting them with swagger macros.
It is possible to define nested resources in your router.
By route definition like this I end up with having two
index
functions insideVideoController
that are pattern matching different params.Then during the compilation I get:
$ mix phx.swagger.generate Compiling 2 files (.ex) warning: this clause cannot match because a previous clause at line 20 always matches */video_controller.ex:87
The problem is that both
swagger_path
s are using the same action:index
, although they handle completely different urls. Is this scenario supported? If it's not supported, is there some recommended workaround for nested resources then ?Thank you
The text was updated successfully, but these errors were encountered: