Ask questionsRequest for clarification around allOf and required fields
I am unclear on the behavior of allOf as it relates to required fields.
If I have one schema that includes another via allOf, how are required fields calculated?
Are they the union of the required fields of the two schemas? Are they JUST the required fields of the encapsulating schema? Are they something else?
For example, let's say I have the following schemas:
PaymentInitiationRecipientGetResponse: additionalProperties: true description: PaymentInitiationRecipientGetResponse defines the response schema for `/payment_initiation/recipient/get` allOf: - $ref: '#/components/schemas/PaymentInitiationRecipient' - type: object properties: request_id: $ref: '#/components/schemas/RequestID' required: - request_id - name PaymentInitiationRecipient: type: object additionalProperties: true description: PaymentInitiationRecipient defines a payment initiation recipient properties: recipient_id: type: string description: The ID of the recipient. name: type: string description: The name of the recipient. required: - recipient_id
In this example, what would be the required fields for
Answer questions karenetheridge
Most JSON Schema keywords are evaluated in isolation from each other, so the effect is cumulative. There is one keyword that asserts that 'request_id' and 'name' are required, and then later on another keyword asserts that 'recipient_id' is required. These are all considered separately, so the end result is that all three properties are required.