Commit Graph

39 Commits

Author SHA1 Message Date
Raymond Feng c17252e99a Refresh swagger on remoteMethodAdded
See https://github.com/strongloop/loopback-component-explorer/pull/208
2017-09-15 10:44:45 -07:00
Samuel Reed 3e8636c0ac Update to mainline swagger-ui
Revert #107
https://github.com/strongloop/loopback-component-explorer/pull/107
2016-10-14 15:27:43 +02:00
Miroslav Bajtoš d78f1344e2 Deprecate built-in CORS middleware
Push the responsibility of enabling/configuring CORS back to the
application developer.
2016-09-21 11:08:49 +02:00
Simon Ho 35c93eb59f Add globalization 2016-08-04 00:47:24 -07:00
Ryan Graham cb6eafd592
update copyright notices and license 2016-05-05 17:10:55 -07:00
Supasate Choochaisri ff60f8bf91 Add feature to hide disabled remote methods after explorer is initialized
Signed-off-by: Supasate Choochaisri <supasate.c@gmail.com>
2016-04-30 04:08:17 +07:00
Miroslav Bajtoš 45e0bf85e9 More fixes of indentation in index.js 2016-04-29 16:21:07 +02:00
Miroslav Bajtoš 67f48d5dcb Fix broken indentation
Partially revert 298765547
2016-04-29 15:36:44 +02:00
Amir Jafarian c923710ce2 Fix linting errors 2016-04-22 17:18:04 -04:00
Amir Jafarian 2987655479 Auto-update by eslint --fix 2016-04-22 17:09:48 -04:00
Raymond Feng 63f446511d Add `swaggerUI` option to enable/disable UI serving 2016-03-08 10:13:08 -08:00
Pradeep Kumar Tippa 2186b69885 Update swaggerObject when a new model was added
Listen for loopback app's event "modelRemoted" to detect when a new
model was added, and re-run "createSwaggerObject" to get an updated
version.
2016-01-05 10:45:11 +01:00
Rand McKinney 8dae3c7330 Rename the module to loopback-component-explorer 2015-09-17 10:54:02 +02:00
Miroslav Bajtoš 42b9f2d7c0 Use loopback-swagger to generate swagger.json 2015-09-03 10:37:09 +02:00
Miroslav Bajtoš e75d8bb353 Merge pull request #117 from hacksparrow/feature/register-self
Register loopback-explorer to app
2015-08-31 10:58:43 +02:00
Hage Yaapa e509dabf21 Register loopback-explorer to app
This patch registers loopback-explorer to the app object with its
options, making its mountPath property available at
app.get('loopback-explorer').
2015-08-28 23:52:04 +05:30
Miroslav Bajtoš 0b17811546 Generate Swagger Spec 2.0 documentation
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.
2015-08-21 18:55:32 +02:00
Miroslav Bajtoš 30017c8242 Upgrade to strong-swagger-ui@21.0 (swagger-ui@2.1) 2015-08-13 15:58:35 +02:00
Miroslav Bajtoš 7ee8703ff5 Rework the module to a loopback component
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
2015-08-10 16:51:03 +02:00
Miroslav Bajtoš 073beebcb7 Use strong-swagger-ui instead of swagger-ui 2015-07-10 14:00:52 +02:00
Simon Ho e825c4b49f Allow `uiDirs` to be defined as a String 2014-12-31 13:49:06 -08:00
Ryan Graham 6b5a016c59 Use full lodash instead of lodash components
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
2014-12-02 19:14:58 -08:00
Miroslav Bajtoš 2ec096a278 Add an option `uiDirs`
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.
2014-10-24 19:24:34 +02:00
Samuel Reed e7efa82640 Use `dist` property from swagger-ui package.
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.
2014-08-12 09:47:53 -04:00
Samuel Reed cefbdb361e Fix resources if the explorer is at a deep path. 2014-07-11 14:56:32 -04:00
Samuel Reed 6224243791 Remove preMiddleware.
Not necessary since this can easily be done with an app.use() before
calling loopback-explorer.
2014-07-10 14:16:10 -05:00
Samuel Reed cbf768f0b8 Remove peerDependencies, use express directly. 2014-07-10 14:09:57 -05:00
Samuel Reed 75713f16f2 Add url-join so path.join() doesn't break windows 2014-07-10 14:09:57 -05:00
Samuel Reed 70dddef296 Use express routes instead of modifying remoting.
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}.
2014-07-09 18:13:47 -05:00
Samuel Reed 5f22982200 Allow easy setting of accessToken in explorer UI. 2014-07-09 11:45:44 -05:00
Samuel Reed 4c0ce42001 Refactoring swagger 1.2 rework.
Added comments, api version, and better Swagger 1.2 compat.
2014-07-05 14:32:00 -05:00
Samuel Reed eb31787fbc Swagger 1.2 compatability. Moved strong-remoting/ext/swagger to this module.
Will now correctly return model schemas.

Moved swagger.js tests to this module.
2014-07-04 17:09:03 -05:00
Samuel Reed 56003f0178 Load swagger ui from `swagger-ui` package instead.
Added option `swaggerDistRoot` for specific file overrides.
2014-07-04 14:28:47 -05:00
Alex Pica ee79c4bf5d Make sure X-Powered-By header is disabled 2014-04-21 05:29:01 +03:00
Miroslav Bajtoš 8b6fc55de8 Use `app.get('restApiRoot')` as default basePath 2014-01-07 16:56:58 +01:00
Miroslav Bajtoš 6c4e780ab8 Replace strong-remoting ext/swagger with app.docs
Use `app.docs()` to expose Swagger specs. This way we don't have to
depend on loopback's dependency strong-remoting.
2014-01-07 16:13:34 +01:00
Miroslav Bajtos eb06404157 Fix loading of loopback dependencies.
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
2013-12-09 11:37:38 +01:00
Miroslav Bajtos a33c067ffa Support custom basePath
Recognize the `basePath` passed to swagger extension and use it in
the webpage to construct the correct `discoveryUrl`.
2013-11-29 16:26:16 +01:00
Ritchie Martori f3d6cb9b54 Initial explorer 2013-11-05 11:16:59 -08:00