title: nullable fields in swagger on node.js
body: <p>I've spent a bunch of time trying to find a solution for creating swagger docs in Node.JS. The main library is swagger-node, in which you create a swagger yaml file and then add your controllers to it. It automatically provides swagger ui docs in your app and does validation on the request &amp; response against the models you specify in your yaml.</p>
  
  <p>This is neat, however I have a requirement that some fields I want to explicitly be able to return or accept <code>null</code> as a value, for instance:</p>
  
  <pre><code>{ 
    id: 123,
    description: "string",
    date_sent: null
  }
  </code></pre>
  
  <p>I don't want to delete the <code>date_sent</code> key, I want to explicitly state it as null.</p>
  
  <p>The swagger spec does not support <code>anyOf</code> which is how JSON schema normally does this I believe. </p>
  
  <p>I'm wondering if there's a workaround? Perhaps some library available for node that has a <code>x-nullable</code> vendor specific flag you can add, or some way of specifying that my not-required fields should all be nullable. </p>
  
  <p>Am I going to have to write something myself that takes my swagger file and then modifies it before the validator middleware runs, or is there some workaround someone can suggest?</p>