Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct way to define an array of one or more strings using the OpenAPI v3 Specification [duplicate]

I wish to POST an array containing a variable number of strings, such as

["string1", "string2", ... "stringN"]

My present OpenAPI document defines it this way:

schema:
  type: array
    items:
      description: networkIds
      type: string

Is this the correct way to code to the OpenAPi v3 spec, or is there a more precise way to indicate one or more strings within the array?

like image 725
Mike Avatar asked Dec 20 '17 17:12

Mike


1 Answers

The indentation is wrong – type and items must be on the same level.

If the array cannot be empty and always has at least 1 item, you can add minItems: 1 as an additional constraint. If all items must be unique, add uniqueItems: true.

schema:
  type: array
  items:
    description: networkIds
    type: string
  minItems: 1
like image 63
Helen Avatar answered Sep 22 '22 21:09

Helen