0

I'm trying to define a schema in openAPI where the value can be one or more from a pre-set list of values. For example, something like below. I know it's invalid but, hopefully, it conveys the idea.

components:
  schema:
    ingest-rules:
      type: string
      oneOrMoreOf: 
        - "rule1, rule2, rule3 rule4, rule5"

Where ingest-rules is an array of one or more values from the list of possible values. It would be similar to an enum but where multiple values can be selected.

How can I do this in openAPI v >= 3.0

Thanks.

Steve G
  • 73
  • 10
  • Is this schema used as a query parameter or in a request body? If the latter - is the value of `ingest-rules` supposed to be an array of enum, e.g. `"ingest-rules": ["rule2", "rule5"]`? Or it supposed to be a comma-separated string e.g. `"ingest-rules": "rule2, rule5"` where the individual values are predefined? – Helen Aug 22 '22 at 07:05
  • @Helen Thanks for the response. "ingest-rules" will be supplied in the requestBody and the value is supposed to be an array of strings. "ingest-rults" : ["rule1","rule3"] – Steve G Aug 22 '22 at 19:12
  • See the linked Q&A. (Even though its title says "Swagger 2.0", the answer applies to OpenAPI 3 too.) – Helen Aug 22 '22 at 20:02

0 Answers0