Ask a Question

How to document multiple data types array in OpenAPI Definition

lnash94
Visitor

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: 

let's assume I have an array called `arry` with two data types integer and string, when I receive `arry`, It can be contained items only one type. It can be an integer array(arry[] -> [integer, integer, integer]) or string array (arry[]-> [string, string, string]).

 

If I use oneOf data model :

....

arry:

  type: array

  items:

    oneOf:

          - type: string

          - type: integer

it will return the mixed type array arry[]->[integer, string, integer, integer, string] 

Could you please let me know, how can I represent array arry[] -> [integer, integer, integer] or arry[]-> [string, string, string]  in the OpenAPI definition?

 

cancel
Showing results for 
Search instead for 
Did you mean: