title: swagger "Response validation failed: value expected to be an array/object but is not"
body: <p>I am trying to get the "out of the box" hello world project generated by <code>swagger project create</code> to return an xml response instead of json.  Here are the steps I've taken:</p>
  
  <p>1)  ran <code>swagger project create</code> and chose the express option.</p>
  
  <p>2)  opened swagger.yaml and made the following change:</p>
  
  <pre><code># format of the responses to the client (Accepts)
  produces:
    - application/xml
  </code></pre>
  
  <p>Here is the entire swagger.yaml, if you're interested:</p>
  
  <pre><code>swagger: "2.0"
  info:
    version: "0.0.1"
    title: Hello World App
  # during dev, should point to your local machine
  host: localhost:10010
  # basePath prefixes all resource paths 
  basePath: /
  # 
  schemes:
    # tip: remove http to make production-grade
    - http
    - https
  # format of bodies a client can send (Content-Type)
  consumes:
    - application/json
  # format of the responses to the client (Accepts)
  produces:
    - application/xml
  paths:
    /hello:
      # binds a127 app logic to a route
      x-swagger-router-controller: hello_world
      get:
        description: Returns 'Hello' to the caller
        # used as the method name of the controller
        operationId: hello
        parameters:
          - name: name
            in: query
            description: The name of the person to whom to say hello
            required: false
            type: string
        responses:
          "200":
            description: Success
            schema:
              # a pointer to a definition
              $ref: "#/definitions/HelloWorldResponse"
          # responses may fall through to errors
          default:
            description: Error
            schema:
              $ref: "#/definitions/ErrorResponse"
    /swagger:
      x-swagger-pipe: swagger_raw
  # complex objects have schema definitions
  definitions:
    HelloWorldResponse:
      required:
        - message
      properties:
        message:
          type: string
    ErrorResponse:
      required:
        - message
      properties:
        message:
          type: string
  </code></pre>
  
  <p>3)  opened the hello_world.js controller and changed the res object to not be json and set the type to <code>application/xml</code>.  I also added jstoxml to the project to turn the object into xml.  Here is the code:</p>
  
  <pre><code>'use strict';
  
  var util = require('util');
  const { toXML } = require('jstoxml');
  
  module.exports = {
    hello: hello
  };
  
  function hello(req, res) {
    // variables defined in the Swagger document can be referenced using req.swagger.params.{parameter_name}
    var name = req.swagger.params.name.value || 'stranger';
    var hello = {message: 'hello'};
    var xml = toXML(hello);
    res.type('application/xml');
    res.end(xml);
  }
  </code></pre>
  
  <p>4)  ran <code>swagger project start</code> and then ran the following curl request:</p>
  
  <p><code>curl -X GET "http://127.0.0.1:10010/hello?name=Scott" -H "accept: application/xml"</code></p>
  
  <p>5)  Got the following response:</p>
  
  <p><code>{"message":"Response validation failed: value expected to be an array/object but is not","failedValidation":true,"originalResponse":"&lt;message&gt;hello&lt;/message&gt;"}</code></p>
  
  <p>The server outputs the following error:</p>
  
  <pre><code>SyntaxError: Response validation failed: value expected to be an array/object but is not
      at JSON.parse (&lt;anonymous&gt;)
      at validateValue (/Users/seanroberts/projects/hello-xml/node_modules/swagger-tools/middleware/swagger-validator.js:125:20)
      at ServerResponse.res.end (/Users/seanroberts/projects/hello-xml/node_modules/swagger-tools/middleware/swagger-validator.js:252:9)
      at hello (/Users/seanroberts/projects/hello-xml/api/controllers/hello_world.js:45:7)
      at swaggerRouter (/Users/seanroberts/projects/hello-xml/node_modules/swagger-tools/middleware/swagger-router.js:407:20)
      at swagger_router (/Users/seanroberts/projects/hello-xml/node_modules/swagger-node-runner/fittings/swagger_router.js:31:5)
      at Runner.&lt;anonymous&gt; (/Users/seanroberts/projects/hello-xml/node_modules/bagpipes/lib/bagpipes.js:171:7)
      at bound (domain.js:301:14)
      at Runner.runBound (domain.js:314:12)
      at Runner.pipeline (/Users/seanroberts/projects/hello-xml/node_modules/pipeworks/pipeworks.js:72:17)
  </code></pre>
  
  <p>What am I doing wrong?</p>