|
| 1 | +--- |
| 2 | +title: All-of |
| 3 | +description: Example schema to demonstrate the use of the allOf keyword |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | + |
| 8 | +# All-of |
| 9 | + |
| 10 | +<p>Example schema to demonstrate the use of the allOf keyword</p> |
| 11 | + |
| 12 | +<table> |
| 13 | +<tbody> |
| 14 | +<tr><th>$id</th><td>allof.yml</td></tr> |
| 15 | +<tr><th>$schema</th><td>http://json-schema.org/draft-07/schema#</td></tr> |
| 16 | +</tbody> |
| 17 | +</table> |
| 18 | + |
| 19 | +## Properties |
| 20 | + |
| 21 | +<table class="jssd-properties-table"><thead><tr><th colspan="2">Name</th><th>Type</th></tr></thead><tbody><tr><td rowspan="2">allOfExample</td><td rowspan="2">All of:</td><td>Object</td></tr><tr><td>Object</td></tr></tbody></table> |
| 22 | + |
| 23 | + |
| 24 | +## Example |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +``` |
| 29 | +{ |
| 30 | + "allOfExample": { |
| 31 | + "propertyA": "With a string value", |
| 32 | + "propertyB": 123 |
| 33 | + } |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | + |
| 38 | +## Example |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +``` |
| 43 | +{ |
| 44 | + "allOfExample": { |
| 45 | + "propertyA": "Another string value", |
| 46 | + "propertyB": 456, |
| 47 | + "propertyC": 789 |
| 48 | + } |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | +<hr /> |
| 55 | + |
| 56 | + |
| 57 | +## allOfExample |
| 58 | + |
| 59 | + |
| 60 | +<table class="jssd-property-table"> |
| 61 | + <tbody> |
| 62 | + <tr> |
| 63 | + <th>Title</th> |
| 64 | + <td colspan="2">All Of Example</td> |
| 65 | + </tr> |
| 66 | + <tr> |
| 67 | + <th>Description</th> |
| 68 | + <td colspan="2">Property that demonstrates allOf</td> |
| 69 | + </tr> |
| 70 | + <tr><tr><td rowspan="2">Type</td><td rowspan="2">All of:</td><td>Object</td></tr><tr><td>Object</td></tr></tr> |
| 71 | + <tr> |
| 72 | + <th>Required</th> |
| 73 | + <td colspan="2">Yes</td> |
| 74 | + </tr> |
| 75 | + |
| 76 | + </tbody> |
| 77 | +</table> |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | +### allOfExample.0 |
| 82 | + |
| 83 | + |
| 84 | +<table class="jssd-property-table"> |
| 85 | + <tbody> |
| 86 | + <tr> |
| 87 | + <th>Title</th> |
| 88 | + <td colspan="2">allOfExample option 0 with a single property</td> |
| 89 | + </tr> |
| 90 | + |
| 91 | + |
| 92 | + </tbody> |
| 93 | +</table> |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | +### allOfExample.0.propertyA |
| 98 | + |
| 99 | + |
| 100 | +<table class="jssd-property-table"> |
| 101 | + <tbody> |
| 102 | + <tr> |
| 103 | + <th>Title</th> |
| 104 | + <td colspan="2">Property A</td> |
| 105 | + </tr> |
| 106 | + <tr><th>Type</th><td colspan="2">String</td></tr> |
| 107 | + |
| 108 | + </tbody> |
| 109 | +</table> |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +### allOfExample.1 |
| 116 | + |
| 117 | + |
| 118 | +<table class="jssd-property-table"> |
| 119 | + <tbody> |
| 120 | + <tr> |
| 121 | + <th>Title</th> |
| 122 | + <td colspan="2">allOfExample option 1 with two properties</td> |
| 123 | + </tr> |
| 124 | + |
| 125 | + |
| 126 | + </tbody> |
| 127 | +</table> |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | +### allOfExample.1.propertyB |
| 132 | + |
| 133 | + |
| 134 | +<table class="jssd-property-table"> |
| 135 | + <tbody> |
| 136 | + <tr> |
| 137 | + <th>Title</th> |
| 138 | + <td colspan="2">Property B</td> |
| 139 | + </tr> |
| 140 | + <tr><th>Type</th><td colspan="2">Integer</td></tr> |
| 141 | + |
| 142 | + </tbody> |
| 143 | +</table> |
| 144 | + |
| 145 | + |
| 146 | + |
| 147 | + |
| 148 | +### allOfExample.1.propertyC |
| 149 | + |
| 150 | + |
| 151 | +<table class="jssd-property-table"> |
| 152 | + <tbody> |
| 153 | + <tr> |
| 154 | + <th>Title</th> |
| 155 | + <td colspan="2">Property C</td> |
| 156 | + </tr> |
| 157 | + <tr><th>Type</th><td colspan="2">Integer</td></tr> |
| 158 | + |
| 159 | + </tbody> |
| 160 | +</table> |
| 161 | + |
| 162 | + |
| 163 | + |
| 164 | + |
| 165 | + |
| 166 | + |
| 167 | + |
| 168 | + |
| 169 | + |
| 170 | + |
| 171 | + |
| 172 | +<hr /> |
| 173 | + |
| 174 | +## Schema |
| 175 | +``` |
| 176 | +{ |
| 177 | + "$id": "allof.yml", |
| 178 | + "$schema": "http://json-schema.org/draft-07/schema#", |
| 179 | + "title": "All-of", |
| 180 | + "description": "Example schema to demonstrate the use of the allOf keyword", |
| 181 | + "type": "object", |
| 182 | + "examples": [ |
| 183 | + { |
| 184 | + "allOfExample": { |
| 185 | + "propertyA": "With a string value", |
| 186 | + "propertyB": 123 |
| 187 | + } |
| 188 | + }, |
| 189 | + { |
| 190 | + "allOfExample": { |
| 191 | + "propertyA": "Another string value", |
| 192 | + "propertyB": 456, |
| 193 | + "propertyC": 789 |
| 194 | + } |
| 195 | + } |
| 196 | + ], |
| 197 | + "properties": { |
| 198 | + "allOfExample": { |
| 199 | + "title": "All Of Example", |
| 200 | + "description": "Property that demonstrates allOf", |
| 201 | + "type": "object", |
| 202 | + "allOf": [ |
| 203 | + { |
| 204 | + "title": "allOfExample option 0 with a single property", |
| 205 | + "properties": { |
| 206 | + "propertyA": { |
| 207 | + "type": "string", |
| 208 | + "title": "Property A" |
| 209 | + } |
| 210 | + }, |
| 211 | + "additionalProperties": false, |
| 212 | + "required": [ |
| 213 | + "propertyA" |
| 214 | + ] |
| 215 | + }, |
| 216 | + { |
| 217 | + "title": "allOfExample option 1 with two properties", |
| 218 | + "properties": { |
| 219 | + "propertyB": { |
| 220 | + "type": "integer", |
| 221 | + "title": "Property B" |
| 222 | + }, |
| 223 | + "propertyC": { |
| 224 | + "type": "integer", |
| 225 | + "title": "Property C" |
| 226 | + } |
| 227 | + }, |
| 228 | + "additionalProperties": false, |
| 229 | + "required": [ |
| 230 | + "propertyB" |
| 231 | + ] |
| 232 | + } |
| 233 | + ] |
| 234 | + } |
| 235 | + }, |
| 236 | + "additionalProperties": false, |
| 237 | + "required": [ |
| 238 | + "allOfExample" |
| 239 | + ] |
| 240 | +} |
| 241 | +``` |
| 242 | + |
| 243 | + |
0 commit comments