Commit Graph

17 Commits

Author SHA1 Message Date
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
Miroslav Bajtoš 5462ce9aac Add opts.omitProtocolInBaseUrl 2015-06-23 16:36:19 +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š 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š 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š 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
Samuel Reed 32f0f5e37d Allow passing a custom protocol.
This allows swagger definitions to work properly when the API is behind
an SSL terminator.
2014-07-27 21:44:14 -05:00
Samuel Reed 34b3983b9d Remove swagger.test.js license 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 77f01670de LDL to Swagger fixes & extensions.
- Supports all three LDL array type specifications.
- Added model-helper tests.
- translate-keys no longer modifies the incoming object.
- Non-primitive types are now correctly converted into a primitive
  with a `format` attribute.
- `id` properties are not assumed to be required if they are generated.
2014-07-10 12:07:19 -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 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