title: Swagger UI seems to not handle optional keys with POST json body
body: <h2>Packages :</h2>
  
  <pre><code>hapi-swagger: 9.0.1
  joi: 13.0.2
  </code></pre>
  
  <h2>Context :</h2>
  
  <p>I use the <code>swagger-ui</code> with a <code>swagger.json</code> file generated by <code>hapi-swagger</code>.</p>
  
  <p>I use for <code>hapi-swagger</code> the <code>jsonEditor</code> option set to <code>true</code>.
  Which means that i don't enter myself the body in a single text area but i use directly the generated inputs of the UI.</p>
  
  <h2>Issue :</h2>
  
  <p>Only the key <code>"name"</code> is required in the payload, the other ones are optional by default if i refer to the <code>Joi</code> doc.</p>
  
  <p>Actually the <code>Swagger-UI</code> sends :</p>
  
  <pre><code>curl -X POST
  --header 'Content-Type: application/json' 
  --header 'Accept: application/json' 
  -d '{
   "name":"fzef",
  
   "idsUser": [],
  
   "idsUsergroup":[]
  }'
  </code></pre>
  
  <p>Instead i want that the <code>Swagger-UI</code> to send a request like :</p>
  
  <pre><code>curl -X POST 
  --header 'Content-Type: application/json' 
  --header 'Accept: application/json' 
  -d '{
   "name":"fzef",
   }'
  </code></pre>
  
  <h2>Swagger UI</h2>
  
  <p><a href="https://i.stack.imgur.com/us6cq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/us6cq.png" alt="enter image description here"></a></p>
  
  <h2>Joi Schema</h2>
  
  <pre><code>Joi.object().keys({
  
   request: Joi.object().keys({
  
       name: Joi.string().required(),
  
       idsUser: Joi.array().items(Joi.string()),
  
       idsUsergroup: Joi.array().items(Joi.string()),
     }),
    }),
   });
  </code></pre>
  
  <h2>Swagger.json</h2>
  
  <pre><code>...
  "paths": {
    "/addCompany": {
      "post": {
        "operationId": "postAddcompany",
  
         "parameters": [{
            "type": "string",
            "default": "1",
            "pattern": "/^v[0-9]+$/",
            "name": "apiVersion",
            "in": "path",
            "required": true
          },
          {
            "in": "body",
            "name": "body",
            "schema": {
              "$ref": "#/definitions/Model 208"
             }
           }
         ],
  
        "tags": ["api", "CompanyCommandsAPIPart"],
  
        "responses": {
          "default": {
            "schema": {
              "type": "string"
            },
           "description": "Successful"
          },
        }
      }
    }
  }
  
  "definitions": {
    ...
    "Model 208": {
      "type": "object",
  
      "properties": {
        "name": {
          "type": "string"
        },
  
        "idsUser": {
           "$ref": "#/definitions/Model 13",
          "type": "array",
          "x-alternatives": [{
            "$ref": "#/x-alt-definitions/idsFunctionality",
            "type": "array"
          }, {
            "type": "string"
          }]
        },
  
        "idsUsergroup": {
           "$ref": "#/definitions/Model 13",
           "type": "array",
          "x-alternatives": [{
            "$ref": "#/x-alt-definitions/idsFunctionality",
            "type": "array"
          }, {
            "type": "string"
          }]
        },
      },
  
      "required": ["name"]
    },
    ...
  }
  </code></pre>
  
  <hr>
  
  <p>What can i do to get this request body ?</p>
  
  <p>Do i need to precise a <code>joi</code> method in order that the <code>hapi-swagger</code> parser add a parameter like <code>'optional'</code> to the <code>swagger.json</code> ?</p>
  
  <p>I found the same issue for the query of a GET method but found no solution:</p>
  
  <p><a href="https://i.stack.imgur.com/OtbHK.png" rel="nofollow noreferrer">https://github.com/swagger-api/swagger-editor/issues/684</a></p>