|
| 1 | +openapi: 3.1.0 |
| 2 | +info: |
| 3 | + title: AllOf Test Service |
| 4 | + description: Test specification for various allOf scenarios |
| 5 | + version: 1.0.0 |
| 6 | + contact: |
| 7 | + name: 'AllOf Test Service' |
| 8 | + license: |
| 9 | + name: Apache 2.0 |
| 10 | + url: https://www.apache.org/licenses/LICENSE-2.0.html |
| 11 | + x-twilio: |
| 12 | + apiStandards: v1.0 |
| 13 | +servers: |
| 14 | + - url: https://allof.test.com |
| 15 | +paths: |
| 16 | + /v1/basic-allof: |
| 17 | + post: |
| 18 | + operationId: CreateBasicAllOf |
| 19 | + summary: Test basic allOf with multiple schemas |
| 20 | + requestBody: |
| 21 | + required: true |
| 22 | + content: |
| 23 | + application/json: |
| 24 | + schema: |
| 25 | + allOf: |
| 26 | + - type: object |
| 27 | + required: [ id ] |
| 28 | + properties: |
| 29 | + id: |
| 30 | + type: string |
| 31 | + example: "123" |
| 32 | + - type: object |
| 33 | + required: [ name ] |
| 34 | + properties: |
| 35 | + name: |
| 36 | + type: string |
| 37 | + example: "Test Entity" |
| 38 | + - type: object |
| 39 | + properties: |
| 40 | + timestamp: |
| 41 | + type: string |
| 42 | + format: date-time |
| 43 | + responses: |
| 44 | + '200': |
| 45 | + description: Success |
| 46 | + content: |
| 47 | + application/json: |
| 48 | + schema: |
| 49 | + $ref: '#/components/schemas/BasicAllOf' |
| 50 | + |
| 51 | + /v1/nested-allof: |
| 52 | + post: |
| 53 | + operationId: CreateNestedAllOf |
| 54 | + summary: Test nested allOf |
| 55 | + requestBody: |
| 56 | + required: true |
| 57 | + content: |
| 58 | + application/json: |
| 59 | + schema: |
| 60 | + $ref: '#/components/schemas/NestedAllOf' |
| 61 | + responses: |
| 62 | + '200': |
| 63 | + description: Success |
| 64 | + |
| 65 | + /v1/allof-with-refs: |
| 66 | + post: |
| 67 | + operationId: CreateAllOfWithRefs |
| 68 | + summary: Test allOf with schema references |
| 69 | + requestBody: |
| 70 | + required: true |
| 71 | + content: |
| 72 | + application/json: |
| 73 | + schema: |
| 74 | + $ref: '#/components/schemas/AllOfWithRefs' |
| 75 | + responses: |
| 76 | + '200': |
| 77 | + description: Success |
| 78 | + content: |
| 79 | + application/json: |
| 80 | + schema: |
| 81 | + $ref: '#/components/schemas/AllOfWithRefs' |
| 82 | + |
| 83 | + /v1/allof-inline-and-ref: |
| 84 | + post: |
| 85 | + operationId: CreateMixedAllOf |
| 86 | + summary: Test allOf mixing inline schemas and refs |
| 87 | + requestBody: |
| 88 | + required: true |
| 89 | + content: |
| 90 | + application/json: |
| 91 | + schema: |
| 92 | + allOf: |
| 93 | + - $ref: '#/components/schemas/BaseEntity' |
| 94 | + - type: object |
| 95 | + required: [ specificField ] |
| 96 | + properties: |
| 97 | + specificField: |
| 98 | + type: string |
| 99 | + extraData: |
| 100 | + type: object |
| 101 | + responses: |
| 102 | + '200': |
| 103 | + description: Success |
| 104 | + |
| 105 | + /v1/allof-with-oneof: |
| 106 | + post: |
| 107 | + operationId: CreateAllOfWithOneOf |
| 108 | + summary: Test allOf combined with oneOf |
| 109 | + requestBody: |
| 110 | + required: true |
| 111 | + content: |
| 112 | + application/json: |
| 113 | + schema: |
| 114 | + $ref: '#/components/schemas/AllOfWithOneOf' |
| 115 | + responses: |
| 116 | + '200': |
| 117 | + description: Success |
| 118 | + |
| 119 | +components: |
| 120 | + schemas: |
| 121 | + # Basic allOf with refs |
| 122 | + BasicAllOf: |
| 123 | + allOf: |
| 124 | + - $ref: '#/components/schemas/Identifiable' |
| 125 | + - $ref: '#/components/schemas/Nameable' |
| 126 | + - $ref: '#/components/schemas/Timestamped' |
| 127 | + |
| 128 | + # Nested allOf |
| 129 | + NestedAllOf: |
| 130 | + allOf: |
| 131 | + - type: object |
| 132 | + properties: |
| 133 | + outerField: |
| 134 | + type: string |
| 135 | + - allOf: |
| 136 | + - $ref: '#/components/schemas/BaseEntity' |
| 137 | + - type: object |
| 138 | + properties: |
| 139 | + nestedField: |
| 140 | + type: string |
| 141 | + |
| 142 | + # AllOf with multiple schema refs |
| 143 | + AllOfWithRefs: |
| 144 | + allOf: |
| 145 | + - $ref: '#/components/schemas/BaseEntity' |
| 146 | + - $ref: '#/components/schemas/Auditable' |
| 147 | + - $ref: '#/components/schemas/Versioned' |
| 148 | + |
| 149 | + # AllOf combined with oneOf |
| 150 | + AllOfWithOneOf: |
| 151 | + allOf: |
| 152 | + - type: object |
| 153 | + required: [ entityType ] |
| 154 | + properties: |
| 155 | + entityType: |
| 156 | + type: string |
| 157 | + commonField: |
| 158 | + type: string |
| 159 | + - oneOf: |
| 160 | + - $ref: '#/components/schemas/TypeA' |
| 161 | + - $ref: '#/components/schemas/TypeB' |
| 162 | + |
| 163 | + # AllOf with additionalProperties |
| 164 | + AllOfWithAdditionalProps: |
| 165 | + allOf: |
| 166 | + - $ref: '#/components/schemas/BaseEntity' |
| 167 | + - type: object |
| 168 | + properties: |
| 169 | + knownField: |
| 170 | + type: string |
| 171 | + additionalProperties: |
| 172 | + type: string |
| 173 | + |
| 174 | + # AllOf with discriminator |
| 175 | + AllOfWithDiscriminator: |
| 176 | + allOf: |
| 177 | + - type: object |
| 178 | + required: [ objectType ] |
| 179 | + properties: |
| 180 | + objectType: |
| 181 | + type: string |
| 182 | + discriminator: |
| 183 | + propertyName: objectType |
| 184 | + mapping: |
| 185 | + cat: '#/components/schemas/Cat' |
| 186 | + dog: '#/components/schemas/Dog' |
| 187 | + - oneOf: |
| 188 | + - $ref: '#/components/schemas/Cat' |
| 189 | + - $ref: '#/components/schemas/Dog' |
| 190 | + |
| 191 | + # Base schemas |
| 192 | + Identifiable: |
| 193 | + type: object |
| 194 | + required: [ id ] |
| 195 | + properties: |
| 196 | + id: |
| 197 | + type: string |
| 198 | + |
| 199 | + Nameable: |
| 200 | + type: object |
| 201 | + required: [ name ] |
| 202 | + properties: |
| 203 | + name: |
| 204 | + type: string |
| 205 | + |
| 206 | + Timestamped: |
| 207 | + type: object |
| 208 | + properties: |
| 209 | + createdAt: |
| 210 | + type: string |
| 211 | + format: date-time |
| 212 | + updatedAt: |
| 213 | + type: string |
| 214 | + format: date-time |
| 215 | + |
| 216 | + BaseEntity: |
| 217 | + type: object |
| 218 | + required: [ id, createdAt ] |
| 219 | + properties: |
| 220 | + id: |
| 221 | + type: string |
| 222 | + createdAt: |
| 223 | + type: string |
| 224 | + format: date-time |
| 225 | + |
| 226 | + Auditable: |
| 227 | + type: object |
| 228 | + properties: |
| 229 | + createdBy: |
| 230 | + type: string |
| 231 | + modifiedBy: |
| 232 | + type: string |
| 233 | + |
| 234 | + Versioned: |
| 235 | + type: object |
| 236 | + properties: |
| 237 | + version: |
| 238 | + type: integer |
| 239 | + |
| 240 | + TypeA: |
| 241 | + type: object |
| 242 | + required: [ fieldA ] |
| 243 | + properties: |
| 244 | + fieldA: |
| 245 | + type: string |
| 246 | + dataA: |
| 247 | + type: integer |
| 248 | + |
| 249 | + TypeB: |
| 250 | + type: object |
| 251 | + required: [ fieldB ] |
| 252 | + properties: |
| 253 | + fieldB: |
| 254 | + type: boolean |
| 255 | + dataB: |
| 256 | + type: array |
| 257 | + items: |
| 258 | + type: string |
| 259 | + |
| 260 | + Cat: |
| 261 | + type: object |
| 262 | + properties: |
| 263 | + objectType: |
| 264 | + type: string |
| 265 | + enum: [cat] |
| 266 | + meow: |
| 267 | + type: boolean |
| 268 | + |
| 269 | + Dog: |
| 270 | + type: object |
| 271 | + properties: |
| 272 | + objectType: |
| 273 | + type: string |
| 274 | + enum: [dog] |
| 275 | + bark: |
| 276 | + type: boolean |
0 commit comments