[erlang-questions] cowboy-swagger newbie question

Mark Geib <>
Thu Feb 11 22:50:37 CET 2016


Thanks for the reply.

However, I am a bit confused as to how I document the different operations then. I need to be able to provide metadata for more than one GET, one for “list” and and one for “played”. The parameters, for example, are different for each operation.

BTW, I am new to RESTful endpoints, so it could be a poor choice for an example.

Mark.


> On Feb 11, 2016, at 2:44 PM, Brujo Benavides <> wrote:
> 
> Hi Mark,
> 
> This email will be very brief (read: mostly useless :P) because I am on vacation and I can't actually try your example from here :(
> Surely someone from inaka (Harry, Carlos, I am looking at you guys) will give you a better answer soon.
> In any case, the problem with your example seems to be that you are trying to provide the whole swagger metadata when just the metadata for the current endpoint is needed.
> In other words, you don't have to provide the basepath (that comes from trails:root_path(), or similar function) and 'paths' is automatically generated by cowboy-swagger. You just need to provide the metadata (including the parameters, specifically those in your path) for your endpoints.
> Hope this helps.
> 
> On Feb 11, 2016 7:25 PM, "Mark Geib" < <mailto:>> wrote:
> I am trying to evaluate the cowboy-swagger library which runs on top of cowboy-trails. So far pretty interesting. However I need some help in how to provide the swagger metadata for an endpoint where I have a root url like /applicaiton/rest/file/[:op]/[arg1]/[arg2] that I want to provide documentation for. I assume that I want to use the swagger “basePath” and “paths” attributes but can’t seem to make that work. I have tried the following in all the forms I can image:
> 
> trails() ->
>   MsgTrailsMetadata =
>           #{basePath => “/application/rest/file/",
>                 paths => [#{<<"/list">> =>
>                                    #{get => #{tags => ["file"],
>                                                         description => “list available mpeg files",
>                                                         produces => ["application/json"]
>                                                    }}},
>                                   #{<<"/played">> =>
>                                    #{get => #{tags => ["file"],
>                                                         description => “list played mpeg files",
>                                                         produces => ["application/json"]}}}]
> 
>      },
>   [trails:trail(“/application/rest/file/:op/[:arg1/[:arg2]]", ?MODULE, [], MsgTrailsMetadata)].
> 
> Any ideas are appreciated.
> 
> Mark.
> 
> 
> _______________________________________________
> erlang-questions mailing list
>  <mailto:>
> http://erlang.org/mailman/listinfo/erlang-questions <http://erlang.org/mailman/listinfo/erlang-questions>
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160211/d9dacd72/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160211/d9dacd72/attachment-0001.bin>


More information about the erlang-questions mailing list