Commit Graph

72 Commits

Author SHA1 Message Date
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
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š 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
cndreiter c47d8c9189 Add `opts.host` to customize host of resource URLs 2015-08-04 15:48:49 +02:00
Raymond Feng 89d48f609a Merge branch 'master' of https://github.com/shelbys/loopback-explorer into shelbys-master 2015-07-30 13:52:07 -07:00
Shelby Sanders a4b96c33e2 Corrected accidental duplication of responseMessages from merge 2015-07-03 00:33:40 -07:00
Shelby Sanders 1294b53f5c Merge remote-tracking branch 'upstream/master' into validate_param_enum
* upstream/master: (53 commits)
  1.8.0
  Add opts.omitProtocolInBaseUrl
  Fix tests broken by fa3035c (#96)
  Fix model description getting lost
  1.7.2
  Allow submitting token input with empty value to remove token.
  Fix duplicate stylesheet issue
  Fix explorer tests for different line endings on Windows
  1.7.1
  Remove unused external font "Droid Sans".
  1.7.0
  Made API doc of class use the http.path of the class if available, or the name of the class as a fallback
  v1.6.4
  Prevent double slash in the resource URLs
  v1.6.3
  Allow `uiDirs` to be defined as a String
  Fix bad CLA URL in CONTRIBUTING.md
  Add X-UA-Compatible tag
  v1.6.2
  Move 200 response to `type` on the operation object. See #75.
  ...
2015-07-02 11:19:18 -07:00
Shelby Sanders 1bf7c27a56 Merge remote-tracking branch 'upstream/master' into validate_param_enum 2015-07-02 11:03:27 -07:00
Miroslav Bajtoš 5462ce9aac Add opts.omitProtocolInBaseUrl 2015-06-23 16:36:19 +02:00
Ying Tang c001bd6b01 add more tests 2015-04-07 15:53:56 -07:00
Ying Tang 3f8c3b7c04 back out changes of id to URI 2015-04-06 19:57:57 -07:00
Ying Tang b9001a3130 Uri id and $ref, join description 2015-04-06 17:00:32 -07:00
Ying Tang 27e5895aa5 add $ref and remove type for models 2015-03-26 22:23:24 -07:00
Pradnya Baviskar 297086fb55 Fix explorer tests for different line endings on Windows 2015-02-27 15:20:10 +05:30
gandrianakis 16c54c038e Made API doc of class use the http.path of the class if available, or the name of the class as a fallback 2015-02-17 17:23:32 +02:00
Miroslav Bajtoš c6693f8725 Prevent double slash in the resource URLs
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.
2015-01-09 14:45:46 +01:00
Simon Ho e825c4b49f Allow `uiDirs` to be defined as a String 2014-12-31 13:49:06 -08:00
Samuel Reed 28a5a2619a Move 200 response to `type` on the operation object. See #75. 2014-12-12 13:48:58 +01: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
Samuel Reed fe434e7ee9 Merge pull request #73 from STRML/nickname
Remove model name from nickname, swagger spec understands op context.
2014-12-01 21:29:27 +01:00
Samuel Reed 8147ba5821 Remove model name from nickname, swagger spec understands op context.
This removes the redundancy from paths in swagger-ui such as
`/api/user/user_login`. It will now be displayed simply as
`/api/user/login`.

This is consistent with how `nickname` is used in Swagger examples.

Added tests to route nickname processing.
2014-11-29 12:07:58 +01:00
Miroslav Bajtoš 4e5cbe43f9 model-helper: ignore unknown property types 2014-11-29 12:05:12 +01:00
Miroslav Bajtoš 0daf2d3dc4 Merge pull request #68 from strongloop/feature/custom-swagger-ui
Add options `overridesDist` and `swaggerUiDist`
2014-10-24 19:29:25 +02: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
Miroslav Bajtoš a4179e454a swagger: honour X-Forwarded-Proto header
Improve the algorithm building `baseUrl` to honour `X-Forwarded-Proto`
header when it is present.
2014-10-22 11:10:15 +02:00
Miroslav Bajtoš 6fb81c279b Add integration tests for included models
Add tests verifying that Swagger docs include model description for
recursively nested references to Models and Arrays of Models in
properties, modelTo and modelThrough relations, accepts,
returns and errors.

Fix bugs discovered along the way.
2014-10-16 14:43:59 +02:00
Miroslav Bajtoš d05dcb71df route-helper: add `responseMessages`
Add a default "success" response message, the status code is 200 or 204
depending on whether the method returns any data.

Append any error messages as specified in the `errors` property
of method's remoting metadata.

Move the description of operation's return type to the "success"
response message.

Include error message models in the API models.
2014-10-16 14:04:02 +02:00
Miroslav Bajtoš 9a6bd35df7 model-helper: support anonymous object types
Accepts/returns arguments allow anonymous object types, e.g.

    { 'arg': 'kvp', type: { 'name': 'string', 'value': 'string' } }

As of this commit, these types are converted to Swagger type 'object'.
2014-10-16 13:51:53 +02:00
Miroslav Bajtoš aa7cb0b118 swagger: include models from accepts/returns args
Models not attached to the app are included too.
2014-10-16 10:34:41 +02:00
Miroslav Bajtoš 6838087a5c swagger: use X-Forwarded-Host for basePath 2014-10-16 10:34:41 +02:00
Miroslav Bajtoš 060354cff8 models: include model's `description` 2014-10-16 08:47:18 +02:00
Miroslav Bajtoš dc815a8421 Refactor conversion of data types
Refactor the way how loopback types are converted to swagger data types.

 - `modelHelper.LDLPropToSwaggerDataType` is responsible for
   producing a valid Swagger Data Type object from LDL object
   (be it a property, accepts item or returns item).

 - LDLPropToSwaggerDataType picks only fields that are part
   of the swagger spec, everything else is excluded from the result.
   It's up to the caller to add extra fields like `description`.

 - refactor `routeHelper.extendWithType` to accept an additional arg:
   the original LDL object. This way it's possible to copy all
   type-specific fields to the output object and don't add anything
   else.
2014-10-16 08:47:18 +02:00
Krishna Raman 856d34b9d4 Add support for `context` and `res` param types 2014-10-15 09:37:03 -07:00
Miroslav Bajtoš 705776517b Support multi-line array `description` and `notes`
When a string value is expected and the user supplied an array,
convert the value to a single string by joining all array items.
2014-10-13 19:32:09 +02:00
Miroslav Bajtoš 622f6176f3 Extend `consumes` and `produces` metadata
- Include XML content-types for both input and output
 - Include JSONP (javascript) content-types for output
2014-10-13 17:29:37 +02:00
Miroslav Bajtoš 4d0e711087 route-helper: include `notes` and `deprecated` 2014-10-13 16:32:12 +02:00
Miroslav Bajtoš f645c6db0d swagger: allow cross-origin requests
Add CORS middleware to the swagger app.

Add a configuration option allowing developers to disable CORS.
2014-10-08 07:57:50 +02:00
Shelby Sanders 7f4e8b3f87 Corrected merge issues 2014-10-07 15:27:49 -07:00
Raymond Feng 282b70e1e4 Fix how the array of models is iterated
https://github.com/strongloop/loopback-explorer/issues/49
2014-09-19 09:35:11 -07:00
Clark Wang acf00f3254 Make sure nested/referenced models in array are mapped to swagger
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2014-08-29 16:06:05 +08:00
Raymond Feng d083feab36 Make sure nested/referenced models are mapped to swagger 2014-08-28 15:20:03 -07:00
Raymond Feng bf3a2c9764 Fix the type name for a property if model class is used
See https://github.com/strongloop/loopback-explorer/issues/32
2014-08-04 23:22:41 -07:00