From d0d9a21d44689a50c43e3e5f9fb6217b80fd9d1d Mon Sep 17 00:00:00 2001
From: Filirom1 <filirom1@gmail.com>
Date: Wed, 27 Mar 2013 19:01:07 +0100
Subject: [PATCH 1/4] be less restrictive

---
 src/generator.coffee | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/generator.coffee b/src/generator.coffee
index a9a1b1a..a107bde 100644
--- a/src/generator.coffee
+++ b/src/generator.coffee
@@ -74,7 +74,7 @@ validateModel = (model, id, models) ->
   # checks that model has an id
   if model.id isnt id
     throw new Error("model #{id} not declared with the same id") 
-  unless _.isObject(model.properties) and !_.isEmpty(model.properties)
+  unless _.isObject(model.properties) and !_.isEmpty(model.properties) || model.additionalProperties || model.items
     throw new Error("model #{id} does not declares properties")
   if models[id]?
     throw new Error("model #{id} has already been defined")
@@ -225,4 +225,4 @@ module.exports = (app, descriptor, resources, options = {}) ->
       
       return res.json(result)
     
-    next()
\ No newline at end of file
+    next()

From 0d3ad0cb8a217e46bcc42afa0ea9be949ecb1d77 Mon Sep 17 00:00:00 2001
From: Filirom1 <filirom1@gmail.com>
Date: Thu, 28 Mar 2013 12:06:37 +0100
Subject: [PATCH 2/4] respect coding style

---
 src/generator.coffee | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/generator.coffee b/src/generator.coffee
index a107bde..ce3dc8d 100644
--- a/src/generator.coffee
+++ b/src/generator.coffee
@@ -74,7 +74,7 @@ validateModel = (model, id, models) ->
   # checks that model has an id
   if model.id isnt id
     throw new Error("model #{id} not declared with the same id") 
-  unless _.isObject(model.properties) and !_.isEmpty(model.properties) || model.additionalProperties || model.items
+  unless !_.isEmpty(model.properties) or !_.isEmpty(model.additionalProperties) or !_.isEmpty(model.items)
     throw new Error("model #{id} does not declares properties")
   if models[id]?
     throw new Error("model #{id} has already been defined")

From 912c2f5dbdbf3b4b83a3c441f2992527676cddad Mon Sep 17 00:00:00 2001
From: Filirom1 <filirom1@gmail.com>
Date: Thu, 28 Mar 2013 12:20:23 +0100
Subject: [PATCH 3/4] add unit tests

---
 test/apiGeneration.coffee | 40 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/test/apiGeneration.coffee b/test/apiGeneration.coffee
index 76ca9a9..5f66b58 100644
--- a/test/apiGeneration.coffee
+++ b/test/apiGeneration.coffee
@@ -73,7 +73,7 @@ describe 'API generation tests', ->
       ]
     , /Response not declared with the same id/
 
-  it 'should fail on model with invalid id', ->
+  it 'should fail on model without properties', ->
     assert.throws ->
       swagger.generator express(), {}, [
         api:
@@ -84,6 +84,42 @@ describe 'API generation tests', ->
       ]
     , /Response1 does not declares properties/
 
+  it 'should not fail on model with properties', ->
+    swagger.generator express(), {}, [
+      api:
+        resourcePath: '/test'
+        apis: [path: '/test/1'],
+        models:
+          Response1:
+            id: 'Response1'
+            properties: name: type: 'string'
+      controller: require './fixtures/sourceCrud'
+    ]
+
+  it 'should not fail on model with additionalProperties', ->
+    swagger.generator express(), {}, [
+      api:
+        resourcePath: '/test'
+        apis: [path: '/test/1'],
+        models:
+          Response1:
+            id: 'Response1'
+            additionalProperties: type: 'string'
+      controller: require './fixtures/sourceCrud'
+    ]
+
+  it 'should not fail on model with items', ->
+    swagger.generator express(), {}, [
+      api:
+        resourcePath: '/test'
+        apis: [path: '/test/1'],
+        models:
+          Response1:
+            id: 'Response1'
+            items: type: 'string'
+      controller: require './fixtures/sourceCrud'
+    ]
+
   it 'should fail on model already defined', ->
     assert.throws ->
       swagger.generator express(), {}, [
@@ -682,4 +718,4 @@ describe 'API generation tests', ->
                 nickname: 'remove'
               ]
             ]
-          done()
\ No newline at end of file
+          done()

From ac07556533a7a614c4018086aff5fc4f5c23ec34 Mon Sep 17 00:00:00 2001
From: Filirom1 <filirom1@gmail.com>
Date: Thu, 28 Mar 2013 15:43:27 +0100
Subject: [PATCH 4/4] allow additionalProperties: {}

---
 src/generator.coffee      | 2 +-
 test/apiGeneration.coffee | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/generator.coffee b/src/generator.coffee
index ce3dc8d..2a3f304 100644
--- a/src/generator.coffee
+++ b/src/generator.coffee
@@ -74,7 +74,7 @@ validateModel = (model, id, models) ->
   # checks that model has an id
   if model.id isnt id
     throw new Error("model #{id} not declared with the same id") 
-  unless !_.isEmpty(model.properties) or !_.isEmpty(model.additionalProperties) or !_.isEmpty(model.items)
+  unless !_.isEmpty(model.properties) or model.additionalProperties or !_.isEmpty(model.items)
     throw new Error("model #{id} does not declares properties")
   if models[id]?
     throw new Error("model #{id} has already been defined")
diff --git a/test/apiGeneration.coffee b/test/apiGeneration.coffee
index 5f66b58..f636730 100644
--- a/test/apiGeneration.coffee
+++ b/test/apiGeneration.coffee
@@ -104,7 +104,7 @@ describe 'API generation tests', ->
         models:
           Response1:
             id: 'Response1'
-            additionalProperties: type: 'string'
+            additionalProperties: {}
       controller: require './fixtures/sourceCrud'
     ]