Required parameters from multiple schemas
- 6 years ago
The use of `anyOf` means that the input would need to match one (or more) of the sub-schemas described in it.
The problem is that you have `anyOf` with two different types - `object` and `array`. The `required` and `properties` are at the same level of the `anyOf` - that means that they would only be applied `check_single` as its type is `object`. When you put type `array` alongside `required` or `properties`, the latter two would have no impact as they have no meaning with tpe `array`.
So what can you do to solve this?
Take the 'single' object definition and extract it to a model. For our purpose, let's call it `MyObject`.
So:
MyObject: type: object required: [...] properties: ...
And then you can define `check` as this:
check: anyOf: - $ref: '#/components/schemas/MyObject' - type: array items:
$ref: '#/components/schemas/MyObjectIn this case, you may want to use `oneOf` instead, because there will never be case where a compared input will have both.