From 4e5cbe43f98ea8159e02cbe7f75e643aa1d135b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Sat, 29 Nov 2014 12:05:12 +0100 Subject: [PATCH 1/2] model-helper: ignore unknown property types --- lib/model-helper.js | 9 ++++++++- test/model-helper.test.js | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/model-helper.js b/lib/model-helper.js index 598f0f1..faee5b4 100644 --- a/lib/model-helper.js +++ b/lib/model-helper.js @@ -21,8 +21,15 @@ var modelHelper = module.exports = { */ generateModelDefinition: function generateModelDefinition(modelClass, definitions) { var def = modelClass.definition; - var name = def.name; var out = definitions || {}; + + if (!def) { + // The model does not have any definition, it was most likely + // created as a placeholder for an unknown property type + return out; + } + + var name = def.name; if (out[name]) { // The model is already included return out; diff --git a/test/model-helper.test.js b/test/model-helper.test.js index 1fb6414..abe8586 100644 --- a/test/model-helper.test.js +++ b/test/model-helper.test.js @@ -198,6 +198,18 @@ describe('model-helper', function() { expect(Object.keys(defs)).has.property('length', 1); }); + // https://github.com/strongloop/loopback-explorer/issues/71 + it('should skip unknown types', function() { + var Model8 = loopback.createModel('Model8', { + patient: { + model: 'physician', + type: 'hasMany', + through: 'appointment' + } + }); + var defs = modelHelper.generateModelDefinition(Model8, {}); + expect(Object.keys(defs)).to.not.contain('hasMany'); + }); }); describe('hidden properties', function() { From 22cf27dac8008d0fe930c99b592d5c53567d8a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Sat, 29 Nov 2014 12:11:31 +0100 Subject: [PATCH 2/2] v1.5.2 --- CHANGES.md | 265 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 CHANGES.md diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..e2d2e22 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,265 @@ +2014-11-29, Version 1.5.2 +========================= + + * model-helper: ignore unknown property types (Miroslav Bajtoš) + + +2014-10-24, Version 1.5.1 +========================= + + + +2014-10-24, Version 1.5.0 +========================= + + * Add an option `uiDirs` (Miroslav Bajtoš) + + * swagger: honour X-Forwarded-Proto header (Miroslav Bajtoš) + + +2014-10-21, Version 1.4.0 +========================= + + * Bump version (Raymond Feng) + + * Add integration tests for included models (Miroslav Bajtoš) + + * route-helper: add `responseMessages` (Miroslav Bajtoš) + + * model-helper: support anonymous object types (Miroslav Bajtoš) + + * swagger: include models from accepts/returns args (Miroslav Bajtoš) + + * loopbackStyles: improve spacing in small window (Miroslav Bajtoš) + + * swagger: Deprecate `opts.swaggerVersion` (Miroslav Bajtoš) + + * swagger: use X-Forwarded-Host for basePath (Miroslav Bajtoš) + + * example: use PersistedModel instead of Model (Miroslav Bajtoš) + + * models: include model's `description` (Miroslav Bajtoš) + + * Refactor conversion of data types (Miroslav Bajtoš) + + * Move `convertText` to `typeConverter` (Miroslav Bajtoš) + + * Add support for `context` and `res` param types (Krishna Raman) + + * package: update devDependencies (Miroslav Bajtoš) + + * gitignore: add .idea, *.tgz, *.iml (Miroslav Bajtoš) + + * Support multi-line array `description` and `notes` (Miroslav Bajtoš) + + * Use `1.0.0` as the default app version. (Miroslav Bajtoš) + + * Extend `consumes` and `produces` metadata (Miroslav Bajtoš) + + * route-helper: include `notes` and `deprecated` (Miroslav Bajtoš) + + * Pull model description from ctor.settings first (Shelby Sanders) + + +2014-10-08, Version 1.3.0 +========================= + + * swagger: allow cross-origin requests (Miroslav Bajtoš) + + * Sort endpoints by letter. (Samuel Reed) + + * Add syntax highlighting styles & highlight threshold. (Samuel Reed) + + * Add contribution guidelines (Ryan Graham) + + +2014-09-22, Version 1.2.11 +========================== + + * Bump version (Raymond Feng) + + * Fix how the array of models is iterated (Raymond Feng) + + +2014-09-05, Version 1.2.10 +========================== + + * Bump version (Raymond Feng) + + * Make sure nested/referenced models in array are mapped to swagger (Clark Wang) + + * Make sure nested/referenced models are mapped to swagger (Raymond Feng) + + +2014-08-15, Version 1.2.9 +========================= + + * Bump version (Raymond Feng) + + * Newest Swagger UI requires application/x-www-form-urlencoded. (Samuel Reed) + + * Use `dist` property from swagger-ui package. (Samuel Reed) + + * Fixed undefined modelClass when using polymorphic relations (Navid Nikpour) + + +2014-08-08, Version 1.2.8 +========================= + + * Bump version (Raymond Feng) + + * Fix the type name for a property if model class is used (Raymond Feng) + + +2014-08-04, Version 1.2.7 +========================= + + * Bump version (Raymond Feng) + + * Set up default consumes/produces media types (Raymond Feng) + + * Fix the default opts (Raymond Feng) + + * Add required swagger 1.2 items property for property type array (Ritchie Martori) + + * Allow passing a custom protocol. (Samuel Reed) + + +2014-07-29, Version 1.2.6 +========================= + + * Bump version (Raymond Feng) + + * res.send deprecated - updated to res.status (Geoffroy) + + * Remove hidden properties from definition. (Samuel Reed) + + +2014-07-25, Version 1.2.5 +========================= + + * Bump version (Raymond Feng) + + * Ensure models from relations are included (Raymond Feng) + + +2014-07-22, Version 1.2.4 +========================= + + * model-helper: handle arrays with undefined items (Miroslav Bajtoš) + + +2014-07-22, Version 1.2.3 +========================= + + * model-helper: handle array types with no item type (Miroslav Bajtoš) + + +2014-07-20, Version 1.2.2 +========================= + + * Bump version (Raymond Feng) + + * Properly convert complex return types. (Samuel Reed) + + +2014-07-18, Version 1.2.1 +========================= + + * Bump version (Raymond Feng) + + * Fix up loopback.rest() model definition hack. (Samuel Reed) + + +2014-07-14, Version 1.2.0 +========================= + + * Bump version and update deps (Raymond Feng) + + * s/accessToken/access_token in authorization key name (Samuel Reed) + + * Fix resources if the explorer is at a deep path. (Samuel Reed) + + * Fix debug namespace, express version. (Samuel Reed) + + * Remove forgotten TODO. (Samuel Reed) + + * Simplify `accepts` and `returns` hacks. (Samuel Reed) + + * More consise type tests (Samuel Reed) + + * Remove preMiddleware. (Samuel Reed) + + * Remove swagger.test.js license (Samuel Reed) + + * Remove peerDependencies, use express directly. (Samuel Reed) + + * Add url-join so path.join() doesn't break windows (Samuel Reed) + + * Rename translateKeys to translateDataTypeKeys. (Samuel Reed) + + * Refactor route-helper & add tests. (Samuel Reed) + + * LDL to Swagger fixes & extensions. (Samuel Reed) + + * Use express routes instead of modifying remoting. (Samuel Reed) + + * Fix missing strong-remoting devDependency. (Samuel Reed) + + * Restore existing styles. (Samuel Reed) + + * Allow easy setting of accessToken in explorer UI. (Samuel Reed) + + * Refactor key translations between LDL & Swagger. (Samuel Reed) + + * Refactoring swagger 1.2 rework. (Samuel Reed) + + * Make sure body parameter is shown. (Raymond Feng) + + * Some swagger 1.2 migration cleanup. (Samuel Reed) + + * Fix api resource path and type ref to models. (Raymond Feng) + + * Swagger 1.2 compatability. Moved strong-remoting/ext/swagger to this module. (Samuel Reed) + + * Load swagger ui from `swagger-ui` package instead. (Samuel Reed) + + +2014-05-28, Version 1.1.1 +========================= + + * package.json: add support for loopback 2.x (Miroslav Bajtoš) + + * Make sure X-Powered-By header is disabled (Alex Pica) + + * Fix license url (Raymond Feng) + + * Update to dual MIT/StrongLoop license (Raymond Feng) + + +2014-01-14, Version 1.1.0 +========================= + + * Bump up loopback min version to 1.5 (Miroslav Bajtoš) + + * Use `app.get('restApiRoot')` as default basePath (Miroslav Bajtoš) + + * Replace strong-remoting ext/swagger with app.docs (Miroslav Bajtoš) + + +2014-01-13, Version 1.0.2 +========================= + + * Bump version (Raymond Feng) + + * README: mount REST at /api in the sample code (Miroslav Bajtos) + + * Reorder middleware to fix unit-test failures. (Miroslav Bajtos) + + * Fix loading of loopback dependencies. (Miroslav Bajtos) + + +2013-12-04, Version 1.0.1 +========================= + + * First release! diff --git a/package.json b/package.json index 8e8065a..1a8d628 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "loopback-explorer", - "version": "1.5.1", + "version": "1.5.2", "description": "Browse and test your LoopBack app's APIs", "main": "index.js", "scripts": {