Forum Discussion

wfreitag's avatar
wfreitag
New Contributor
3 years ago

anyOf together with type

Having a schema definition like:

 

components:
    schemas:
       MySchema:
          properties:
             myProp:
                anyOf:
                   - type: string
                         format: uri
                   - type: array
                         items:
                            type: string
                            format: uri

                type: integer

           mySecondProp:

               ...

In Swagger Editor, this is valid. In OpenAPI 3.0.0 I have found nothing about having both, 'type' (integer in the above sample) and 'anyOf' ('oneOf', 'allOf').

My interpretation is, that 'type' is ignored here. Is that correct? And if so, where do I find that "type is ignored if anyOf/oneOf/ is present" in the specification and if this is NOT correct, how do I handle this...what if the string cannot be evaluated to integer (what is obviously very likely)?

 

So the final question:

If a property has both, 'type' AND 'anyOf' ('oneOf'/'allOf'), which one wins?

No RepliesBe the first to reply