Forum Discussion

lnash94's avatar
lnash94
Champion Level 0
3 years ago
Solved

How to document multiple data types array in OpenAPI Definition

Hi all, I'm looking for an OpenAPI representation for an array type when the array has one specific data type item at one time, the array data type can be multiple types. That means as an example:  ...
  • HKosova's avatar
    3 years ago

    You are almost there. Here's how to define a non-mixed array:

     

    arry:
      oneOf:
        - type: array
          items:
            type: integer
        - type: array
          items:
            type: string

     

     

    Depending on how well your tooling handles "oneOf", this can be simplified into:

     

    arry:
      type: array
      oneOf:
        - items:
            type: integer
        - items:
            type: string