title: Jackson annotation for Json Schema-04/07 generation
body: <p>I have a requirement to autogerate Json schema with dependencies ( one attribute is required or not based on other attribute value ).</p>
  <p>My exact situation has been asked and answered in <a href="https://stackoverflow.com/questions/38717933/jsonschema-attribute-conditionally-required">jsonSchema attribute conditionally required</a>.</p>
  <p>However, my requirement doesn't allow manual changes to schema directly. I'm creating schema using POJO's with Jackson annotations. In a nutshell, I need Jackson annotation to achieve this.</p>
  <pre><code>{
    &quot;type&quot;: &quot;object&quot;,
    &quot;properties&quot;: {
      &quot;foo&quot;: { &quot;type&quot;: &quot;string&quot; },
      &quot;bar&quot;: { &quot;type&quot;: &quot;string&quot; }
    },
    &quot;if&quot;: {
       &quot;properties&quot;: {
         &quot;foo&quot;: { &quot;const&quot;: &quot;bar&quot; }
       },
     &quot;required&quot;: [&quot;foo&quot;]
    },
    &quot;then&quot;: { &quot;required&quot;: [&quot;bar&quot;] }
  }
  </code></pre>
  <p>(or)</p>
  <pre><code>{
    &quot;type&quot;: &quot;object&quot;,
    &quot;properties&quot;: {
      &quot;foo&quot;: { &quot;enum&quot;: [&quot;bar&quot;, &quot;baz&quot;] },
      &quot;bar&quot;: { &quot;type&quot;: &quot;string&quot; },
      &quot;baz&quot;: { &quot;type&quot;: &quot;string&quot; }
    },
    &quot;anyOf&quot;: [
      {
        &quot;properties&quot;: {
          &quot;foo&quot;: { &quot;const&quot;: &quot;bar&quot; }
        },
        &quot;required&quot;: [&quot;bar&quot;]
      },
      {
        &quot;properties&quot;: {
          &quot;foo&quot;: { &quot;const&quot;: &quot;baz&quot; }
        },
        &quot;required&quot;: [&quot;baz&quot;]
      }
    ]
  }
  </code></pre>
  <p>I have experimented with Jackson annotations like @JsonProperty, @JsonFilter, @JsonSerialize etc. Please do nudge me in right direction.</p>
  <p>Thanks.</p>