Notable breaking changes:
- The swagger output is a single object (JSON response) served
at /explorer/swagger.json
- Methods with a single return arg without "root:true" flag
are expected to produce an object response with a single property now,
i.e. `{ data: arg }`.
In v1.x, we were treating such arg as if "root:true" was specified.
The new behaviour matches the actual implementation in strong-remoting.
- The property constraint "length" is translated to "maxLength" now.
- `operationId` includes model name now, because ids must be unique
- X-Forwarded-* headers are no longer processed, Swagger Spec 2.0
has a way how to specify "use the scheme + host where the doc is served"
- opts.omitProtocolInBaseUrl was removed for the same reasons as
X-Forwarded-* headers
- The deprecated opts.swaggerDistRoot was removed.
Rework the exported function to conform to the component convention:
var loopback = require('loopback');
var explorer = require('loopback-explorer');
var app = loopback();
explorer(app, options);
Allow users to mount explorer as a middleware too:
app.use('/explorer', explorer.routes(app, options));
- drop dependency on express
- drop support for loopback 1.x
- add a new option "mountPath" to specify where to mount the explorer UI
and swagger metadata
- describe upgrading from v1.x in README
This change trims 134 modules from the dependency tree, many of which
were duplicate depdencies between the 4 lodash.function modules used
and their sub-dependencies.
Before:
$ npm ls | wc -l
494
$ du -sch node_modules/lodash*
432K node_modules/lodash.assign
660K node_modules/lodash.clonedeep
96K node_modules/lodash.defaults
980K node_modules/lodash.pick
2.1M total
After:
$ npm ls | wc -l
360
$ du -sch node_modules/lodash*
964K node_modules/lodash
964K total
The `uiDirs` option allows users to provide their own set of directories
with UI files, e.g. to provide a custom swagger-ui fork and a custom
set of style/font overrides:
explorer(app, {
uiDirs: [
path.resolve(__dirname, 'public'),
path.resolve(__dirname, 'node_modules', 'swagger-ui')
]
});
The existing option `swaggerDistRoot` is deprecated now.
This removes the hardcoded local `node_modules` lookup for swagger-ui,
which will break if the parent installs swagger-ui itself.
This is useful if, for example, the latest swagger-ui breaks
loopback-explorer, and the parent project wants to install a fixed
version in its root.
This completes the migration of swagger processing from strong-remoting
into loopback-explorer.
Added additional usage instructions to README and additional testing.
This commit introduces a change into where resource descriptors
are hosted. They are no longer hosted under /swagger, but instead
under the same path as the Explorer, wherever that may be.
Generally, the resource listing will be available at
/explorer/resources, and api listings under
/explorer/resources/{modelName}.
Loopback-explorer loads express and strong-remoting from loopback's
`node_modules` folder. This fails when one of those dependencies
was installed to the parent project, e.g. as a peer dependency.
app/node_modules
+- express # <- express installed as peer to loopback
+- loopback
+- node_modules # <- express is not there
As of this commit, loopback-explorer will retry the `require()` call
without `loopback/node_modules` prefix if the first require fails.
1. `require('loopback/node_modules/express')`
2. `require('express')`
The change should fix (some of) unit-tests failures in
https://github.com/strongloop/loopback-workspace