Loopback-next: [API Explorer] Self-hosted API Explorer

Created on 5 Sep 2017  路  8Comments  路  Source: strongloop/loopback-next

As an API developer, I would like to see the OpenAPI spec of my APIs created with LoopBack and have the web UI to visualize the API endpoints and allow me to play with the APIs.

It's important for the API Explorer to be available offline (as opposed to a version hosted on loopback.io):

  • Many enterprise users are behind a restrictive firewall/proxy that disallows access to loopback.io
  • A big part of world's population lives in places with poor/no internet access
  • People often don't have internet access when traveling (on board of a plane, etc.)

Acceptance criteria

  • [x] Expose endpoints for OpenAPI specs in various combinations of versions and formats, such as:

    • versions: 2.0, 3.0.0
    • formats: json, yaml
  • ~Allow such specs to be rendered with http://editor.swagger.io/ with appropriate CORS settings.~

  • [ ] Have the option to install a component to enable built-in web UI for the API explorer

Build a (new) LoopBack4 extension based on the approach we have already implemented in loopback-component-explorer. Use the latest version of swagger-ui to make sure we support both Swagger (v2) and OpenAPI (v3), see https://github.com/strongloop/loopback-component-explorer/pull/209

Possibly related, but not strictly required: https://github.com/strongloop/loopback-next/issues/691

API Explorer TOB epic

Most helpful comment

My preference would be to have an API explorer built in since it provides a better DX in my opinion just like it's included in LB3.

All 8 comments

I am proposing to enhance RestServer/RestApplication with an API allowing consumers to mount static files, for example app.static(path, options). This API should leverage Express middleware server-static as an implementation detail. (See https://github.com/strongloop/loopback-next/issues/691)

With this new API in place, we can either write an API Explorer component bundling swagger-ui and calling app.static(pathToSwaggerUI), or preferably write a short guide explaining LB4 users how to add swagger-ui to their project themselves.

My preference would be to have an API explorer built in since it provides a better DX in my opinion just like it's included in LB3.

since it's an epic, moving to the backlog

I really need this!
I am currently using https://github.com/Rebilly/ReDoc serving it statically from a docApi controller using app.static.
Is this the right way to achieve self hosted api explorer right now, or do you recommend another way?
Thanks

@lsemerini We have a WIP pull request - https://github.com/strongloop/loopback-next/pull/1664

@lsemerini BTW, https://github.com/Rebilly/ReDoc seems to be cool. Serving it via app.static is good for now.

@raymondfeng should we use ReDoc for our API Explorer extension too, replacing swagger-ui we have in LB 3.x?

Closing as done. All the tasks in this epic are completed.

Was this page helpful?
0 / 5 - 0 ratings