Commit Graph

59 Commits

Author SHA1 Message Date
bkniffler fa3035c4bb Fix model description getting lost 2015-04-20 16:04:44 +02:00
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
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š 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š 2decdcc234 swagger: Deprecate `opts.swaggerVersion`
Users of loopback-explorer should not override the swagger version,
as it's the explorer who decides what version of the Swagger Spec
it implements.
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
Miroslav Bajtoš 42dedfcacc Move `convertText` to `typeConverter`
Create a new module `lib/type-converter.js`.

Move `routeHelper.convertText` to this new module.
2014-10-16 08:46:37 +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š be36f11629 Use `1.0.0` as the default app version.
Change the default version number returned when the version number
cannot be read from `package.json` in CWD.
2014-10-13 17:30:19 +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
Shelby Sanders 37179f3e61 Pull model description from ctor.settings first 2014-10-13 15:27:15 +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
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 0d182939a0 Merge pull request #38 from STRML/form-encoding
Newest Swagger UI requires application/x-www-form-urlencoded.
2014-08-15 23:36:34 -07:00
Samuel Reed d98a7877d4 Newest Swagger UI requires application/x-www-form-urlencoded.
UI will fail to POST if this consumes type is not specified.
2014-08-12 12:45:38 -04:00
Navid Nikpour bda9e5f627 Fixed undefined modelClass when using polymorphic relations 2014-08-10 08:46:24 +02: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
Raymond Feng 689a2f6a86 Merge pull request #29 from strongloop/feature/workaround-lb-issue-432
Set up default consumes/produces media types
2014-08-04 08:37:45 -07:00
Ritchie Martori e30df1de93 Merge pull request #27 from strongloop/fix/array-items-any
Add required swagger 1.2 items property for property type array
2014-08-04 08:34:59 -07:00
Raymond Feng 0aa476a682 Set up default consumes/produces media types
See:

https://github.com/strongloop/loopback/issues/432
https://github.com/wordnik/swagger-js/issues/107
2014-08-03 21:48:16 -07:00
Raymond Feng df459ffc8b Fix the default opts 2014-07-31 16:47:47 -07:00
Raymond Feng 3c8f3b1dd0 Merge branch 'protocol' of github.com:STRML/loopback-explorer into STRML-protocol 2014-07-31 16:45:32 -07:00
Ritchie Martori f7734fe5b3 Add required swagger 1.2 items property for property type array 2014-07-31 16:33:02 -07:00
Geoffroy f6970db749 res.send deprecated - updated to res.status
Used to get warning: 'express deprecated res.send(status, body): Use
res.status(status).send(body) instead
node_modules/loopback-explorer/lib/swagger.js:105:9'
2014-07-28 17:40:08 -05: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 a9ecfecde5 Remove hidden properties from definition. 2014-07-26 12:15:47 -05:00
Raymond Feng 078649f990 Ensure models from relations are included 2014-07-24 13:35:02 -07:00
Miroslav Bajtoš 536fa4c577 model-helper: handle arrays with undefined items 2014-07-22 21:52:25 +02:00
Miroslav Bajtoš a92450eaf0 model-helper: handle array types with no item type 2014-07-22 21:34:42 +02:00
Samuel Reed 84e9486062 Properly convert complex return types.
Attached tests.
2014-07-20 20:04:10 -05:00
Samuel Reed 6319572a55 Fix up loopback.rest() model definition hack.
In its previous form, array return types were being returned simply
as {type: 'array'}, with their `items` definition forgotten.
2014-07-18 17:31:43 -05:00
Samuel Reed 5c130a4b3d Fix debug namespace, express version. 2014-07-11 14:22:18 -04:00
Samuel Reed 4b3785c0b2 Simplify `accepts` and `returns` hacks. 2014-07-11 10:03:58 -04:00
Samuel Reed 75713f16f2 Add url-join so path.join() doesn't break windows 2014-07-10 14:09:57 -05:00
Samuel Reed 781ac2bd12 Rename translateKeys to translateDataTypeKeys. 2014-07-10 14:09:57 -05:00