A tutorial on using @loopback/rest-explorer
to add a self-hosted REST API ExplorerNote: This page was generated from the loopback-next/packages/rest-explorer/README.md.
@loopback/rest-explorer
This module contains a component adding a self-hosted REST API Explorer toLoopBack applications.
Installation
npm install --save @loopback/rest-explorer
Basic use
The component should be loaded in the constructor of your custom Applicationclass. Applications scaffolded by recent versions of our lb4
CLI tool have theself-hosted REST API Explorer pre-configured out of the box.
Start by importing the component class:
import {RestExplorerComponent} from '@loopback/rest-explorer';
In the constructor, add the component to your application:
this.component(RestExplorerComponent);
By default, API Explorer is mounted at /explorer
. This path can be customizedvia RestExplorer configuration as follows:
this.configure(RestExplorerBindings.COMPONENT).to({
path: '/openapi/ui',
});
Or:
this.bind(RestExplorerBindings.CONFIG).to({
path: '/openapi/ui',
});
NOTE: The Explorer UI’s visual style is not customizable yet. Our recommendedsolution is to create a fork of this module, make any style changes in the forkand publish the modified module under a different name. TheGitHub issue #2023 isrequesting a configuration option for customizing the visual style, pleaseup-vote the issue and/or join the discussion if you are interested in thisfeature.
Contributions
Tests
Run npm test
from the root folder.
Contributors
Seeall contributors.
License
MIT