title: Selecting an Object type based on its type with JSON conditional if then logic
body: <p>I have an object with properties that can be on 3 types. However, it should only display the property of the JSON document presented. Here is the schema with all the product options:</p>
  <pre><code>               {
        
                 &quot;#schema&quot;: &quot;https://json-schema.org/draft-07/schema#&quot;,
                 &quot;$id&quot;: &quot;https://healthpartners.com/branch-schema&quot;,
                 &quot;type&quot;: &quot;object&quot;,
                 &quot;product&quot;: {
                    &quot;type&quot;: &quot;object&quot;,
                    &quot;properties&quot;: {
                    &quot;productInfo&quot;: {
                    &quot;$ref&quot;: &quot;#/$defs/productDetail&quot;
                 },
                   &quot;unavailable&quot;: {
                    &quot;$ref&quot;: &quot;#/$defs/alternateProducts&quot;
                 },
                    &quot;productSummary&quot;: {
                    &quot;$ref&quot;: &quot;#/$defs/productSummary&quot;
                 }
               }
              },
                &quot;$defs&quot;: {
                &quot;productDetail&quot;: {
                 &quot;type&quot;: &quot;object&quot;,
                 &quot;properties&quot;: {
                 &quot;description&quot;: {&quot;type&quot;: &quot;string&quot;} ,
                 &quot;name&quot;: {&quot;type&quot;: &quot;string&quot;},
                 &quot;productCode&quot;: {&quot;type&quot;: &quot;string&quot; },
                 &quot;category&quot;: {&quot;type&quot;: &quot;string&quot; }
                }
              },
                 &quot;alternateProducts&quot;: {
                 &quot;type&quot;: &quot;array&quot;,
                 &quot;items&quot;: {
                   &quot;searchResult&quot;: {&quot;enum&quot;: [&quot;Product not found&quot;]
                 },
                  &quot;alternateProducts&quot;: {&quot;type&quot;: &quot;string&quot;}
               }
             },
                &quot;productSummary&quot;: {
                &quot;type&quot;: &quot;object&quot;,
                &quot;summary&quot;: {&quot;type&quot;: &quot;string&quot;}
              }
            }
          }
  </code></pre>
  <p>I want to be able to display only a summary document or a alternateProducts or productInfo at any one time. I have seen logic using if.. then .. else to pick what to display based on the json document properties, but the examples I have seen only if  { &quot;const&quot; : &quot;some_enumeration_value&quot; }.  Is it possible to use if logic to accomplish, displaying only one of the 3 properties or is my only option to use oneOf? I am trying understand how to apply the conditional if logic to object types and properties but there a no examples of doing it without using a oneOf option</p>