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
SwaggerUI builds resource URL by concatenating basePath + resourcePath.
Since the resource paths are always startign with a slash, if the
basePath ends with a slash too, an incorrect URL is produced.
This was typically happenning when `restApiRoot` was '/'.
This commit modifies the code producing the base path to remove
the trailing slash.
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 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 REST adapter owns the whole URL space and does not let other
middleware handle same URLs. It's possible to circumvent this measure
by installing the explorer middleware before the REST middleware.