title: Swagger json, block "definitions" - different required fields in specific methods
body: <p>I have a simple swagger.json file, Product rest api with 2 methods: post (add new product) and put (update) and I want to define &quot;name&quot;, &quot;price&quot; fields of Product definition as required for POST method but not for a PUT method.</p>
  <p>How can i do that without code duplication?</p>
  <p>There is my swagger.json file</p>
  <pre><code>{ 
    &quot;paths&quot; : {
      &quot;/products&quot; : {
        &quot;post&quot; : {
          &quot;summary&quot; : &quot;Add a new product&quot;,
          &quot;operationId&quot; : &quot;addProduct&quot;,
          &quot;consumes&quot; : [ &quot;application/json&quot; ],
          &quot;produces&quot; : [ &quot;application/json&quot; ],
          &quot;parameters&quot; : [ {
            &quot;in&quot; : &quot;body&quot;,
            &quot;name&quot; : &quot;data&quot;,
            &quot;description&quot; : &quot;Product object that needs to be added to the store&quot;,
            &quot;required&quot; : true,
            &quot;schema&quot; : {
              &quot;$ref&quot; : &quot;#/definitions/Product&quot;,
              &quot;required&quot;: [&quot;name&quot;, &quot;price&quot;] // &lt;-------- not working
            }
          } ]
        },
      },
      &quot;/products/{id}&quot; : {
        &quot;put&quot; : {
          &quot;summary&quot; : &quot;Update a product&quot;,
          &quot;operationId&quot; : &quot;updateProduct&quot;,
          &quot;consumes&quot; : [ &quot;application/json&quot;, &quot;multipart/form-data&quot; ],
          &quot;produces&quot; : [ &quot;application/json&quot; ],
          &quot;parameters&quot; : [
            {
              &quot;in&quot; : &quot;path&quot;,
              &quot;name&quot; : &quot;id&quot;,
              &quot;description&quot; : &quot;Product id&quot;,
              &quot;required&quot; : true,
              &quot;type&quot;: &quot;integer&quot;,
              &quot;format&quot;: &quot;uint&quot;
            },
            {
              &quot;in&quot; : &quot;body&quot;,
              &quot;name&quot; : &quot;data&quot;,
              &quot;description&quot; : &quot;Product data for update&quot;,
              &quot;required&quot; : true,
              &quot;schema&quot; : {
                &quot;$ref&quot; : &quot;#/definitions/Product&quot;
              }
            }
          ]
        }
      }
    },
    &quot;definitions&quot; : {
      &quot;Product&quot;: {
        &quot;type&quot;: &quot;object&quot;,
        &quot;required&quot;: [&quot;name&quot;],
        &quot;properties&quot;: {
          &quot;name&quot; : {
            &quot;type&quot; : &quot;string&quot;
          },
          &quot;price&quot;: {
            &quot;type&quot;: &quot;number&quot;,
            &quot;format&quot;: &quot;float&quot;
          }
        }
      }
    }
  }
  </code></pre>