[erlang-questions] cowboy-swagger newbie question

Brujo Benavides fernando.benavides@REDACTED
Thu Feb 11 23:00:46 CET 2016


Of course! I missed that part as well. The keys for the metada are the
verbs. You can find examples of that on https://github.com/inaka/lsl and
https://github.com/inaka/canillita
If you have 'list' and 'played' as parts of your paths (i.e. Urls) then you
have multiple trails (one for each) possibly served by the same handler
(although I strongly recommend you to use 2 different ones).
On Feb 11, 2016 7:50 PM, "Mark Geib" <mark.geib.44@REDACTED> wrote:

> 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 <
> fernando.benavides@REDACTED> 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" <mark.geib.44@REDACTED> 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
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160211/bdbb8e0b/attachment.htm>


More information about the erlang-questions mailing list