Repository: glennjones/hapi-swagger (js)

Issue:
x-meta fields after response field merge
#### Context

* *hapi-swgger version*: 7.7.0
* *any other relevant information*: 

#### What are you trying to achieve or the steps to reproduce ?

Create a route as below, with a somple Joi schema, and an extra meta data tag

```js
method:...,
path:...,
config: {
  response: {
        status: {
          201: MyJoiSchema,
        },
      },
      plugins: {
        'hapi-swagger': {
          responses: {
            201: {
              'x-meta': 'some meta data',
            },
          },
        },
      },
  },
},
handler: ...
```

#### What result did you get?

It seems if a schema is provided as normal, along with 'extra' fields in the 'hapi-swagger' plugin, the extra fields are lost in the generated swagger json. In the example above, the 'x-meta' field will be lost.

If the 'MyJoiSchema' is removed, the 'x-meta' field will not be lost.

#### What did you expect ?

I expected the 'x-meta' field to not be lost, even if a Joi schema is given

Pull request description:
Fixes #403

Patch:
diff --git a/lib/responses.js b/lib/responses.js
index 48da5f0..92477ae 100644
--- a/lib/responses.js
+++ b/lib/responses.js
@@ -94,6 +94,8 @@ internals.responses.prototype.optionOverride = function (discoveredSchemas, user
         if (Hoek.reach(userDefindedSchemas[key], 'schema.isJoi') && userDefindedSchemas[key].schema.isJoi === true) {
             out = this.getResponse(key, userDefindedSchemas[key].schema, useDefinitions, isAlt);
             out.description = userDefindedSchemas[key].description;
+        } else if (!out.description) {
+            out.description = HTTPStatus[key].replace('OK', 'Successful');
         }
 
 
@@ -101,14 +103,17 @@ internals.responses.prototype.optionOverride = function (discoveredSchemas, user
         if (!discoveredSchemas[key] && out) {
             // if it does not exist create it
             discoveredSchemas[key] = out;
-        } else {
-            // add description to schema
-            if (out.description) {
-                discoveredSchemas[key].description = out.description;
-            }
-            // overwrite schema
-            if (out.schema) {
-                discoveredSchemas[key].schema = out.schema;
+        }
+        else {
+            // override all user defined values
+
+            for (let item in out) {
+
+                const value = out[item];
+
+                if (value !== undefined) {
+                    discoveredSchemas[key][item] = value;
+                }
             }
         }
         discoveredSchemas[key] = Utilities.deleteEmptyProperties(discoveredSchemas[key]);


Test patch:
diff --git a/test/Integration/responses-tests.js b/test/Integration/responses-tests.js
index 61222ec..3e677aa 100644
--- a/test/Integration/responses-tests.js
+++ b/test/Integration/responses-tests.js
@@ -322,7 +322,8 @@ lab.experiment('responses', () => {
                     'hapi-swagger': {
                         responses: {
                             '200': {
-                                description: 'Success its a 200'
+                                description: 'Success its a 200',
+                                'x-meta': 'x-meta test data'
                             }
                         }
                     }
@@ -334,25 +335,54 @@ lab.experiment('responses', () => {
             server.inject({ url: '/swagger.json' }, function(response) {
                 expect(err).to.equal(null);
                 //console.log(JSON.stringify(response.result));
-                expect(
-                    response.result.paths['/store/'].post.responses[200].schema
-                ).to.exist();
-                expect(
-                    response.result.paths['/store/'].post.responses[200]
-                        .description
-                ).to.equal('Success its a 200');
-                expect(
-                    response.result.paths['/store/'].post.responses[200].schema
-                ).to.equal({
-                    $ref: '#/definitions/Result',
-                    type: 'object'
+                expect(response.result.paths['/store/'].post.responses[200].schema).to.exist();
+                expect(response.result.paths['/store/'].post.responses[200].description).to.equal('Success its a 200');
+                expect(response.result.paths['/store/'].post.responses[200]['x-meta']).to.equal('x-meta test data');
+                expect(response.result.paths['/store/'].post.responses[200].schema).to.equal({
+                    '$ref': '#/definitions/Result',
+                    'type': 'object'
                 });
                 Helper.validate(response, done, expect);
             });
         });
     });
 
-    lab.test('using route base plugin override - array', done => {
+  
+    lab.test('test a default response description is provided when no description is given', (done) => {
+
+        const routes = {
+            method: 'POST',
+            path: '/store/',
+            handler: Helper.defaultHandler,
+            config: {
+                tags: ['api'],
+                plugins: {
+                    'hapi-swagger': {
+                        responses: {
+                            '200': {
+                                'x-meta': 'x-meta test data'
+                            }
+                        }
+                    }
+                }
+            }
+        };
+
+        Helper.createServer({}, routes, (err, server) => {
+
+            server.inject({ url: '/swagger.json' }, function (response) {
+
+                expect(err).to.equal(null);
+                //console.log(JSON.stringify(response.result));
+                expect(response.result.paths['/store/'].post.responses[200].description).to.equal('Successful');
+                Helper.validate(response, done, expect);
+            });
+        });
+
+    });
+
+
+    lab.test('using route base plugin override - array', (done) => {
         const routes = {
             method: 'POST',
             path: '/store/',