1

As you might now, Loopbackjs framework displays a swagger-based explorer interface exposing your API endpoints and briefly explaining the methods. The problem it's that this interface it a little too much interactive.

I need to provide an api-docs (ish) documentation for my API, and I'm currently adding @annotations in /common/models js files, but I suspect I'm reinventing the wheel here. For swagger-ui / loopback-explorer to display its interface, the endpoints must be already exposing some kind of metadata, right?

I'd like to get that and complete it with description, examples, custom status codes and without "try it" buttons. The users that will see this wouldn't appreciate so much interactivity.

ffflabs
  • 17,166
  • 5
  • 51
  • 77

1 Answers1

2

You can access the "swagger" for your LoopBack Models by clicking the "raw" button at the far right of any Model in LoopBack Explorer and you'll see the swagger JSON that describes you Model.

If you really want to customize your API explorer interface, check out this article:

http://www.podstud.io/blog/angular-swagger-jacking/

Then you'd access the Model Swagger Resources and provide any sort of slick interface you want...

Hope this starts you in the right direction...

tonyStrong
  • 188
  • 3
  • Yes, it does help. It needs a bit of work to map the raw properties to Apidocs keys (path to url, summary to title, method to type, etc etc). I'll dig around to see how to modify descriptions and add other verbosity to default routes – ffflabs Oct 08 '14 at 20:18
  • If you look at your Model.json file, you'll notice "Methods: []" near the bottom. Someday (soon?), that will be the place to modify your descriptions for various Methods. Until now, I'd just build another JSON File the Maps Descriptions to the Methods you find in Swagger and maintain that parallel to the Model JSON. Given that you'll be mapping to Apidocs anyway, this will just add a little more work for your transform. – tonyStrong Oct 08 '14 at 21:22
  • I'd like to see that :), currently, even after my data transformations, nicknames such as ```Dataset_prototype___findById__filter``` are a bit unnatural – ffflabs Oct 09 '14 at 15:04
  • I made a working example of a Loopback - apiDoc bridge (it's just a template) at https://github.com/amenadiel/loopback-apidoc-bridge – ffflabs Oct 13 '14 at 15:01